Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:58:20+00:00 2026-06-13T07:58:20+00:00

I wanna create a table in SQL, and if the I wanna set the

  • 0

I wanna create a table in SQL, and if the I wanna set the attributes to NULL, how do I do it?
For example, I wanna create a table named Courses and its attributes “CourseNo” and “Title” must not be null. I created one below:

CREATE TABLE Courses(
    CourseNo INTEGER CHECK(100<=CourseNo<=999) PRIMARY KEY,
    Title VARCHAR(100),
    )

ALTER TABLE Courses
ALTER COLUMN CourseNo INTEGER NOT NULL
ALTER COLUMN Title VARCHAR(100) NOT NULL

Is this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:58:21+00:00Added an answer on June 13, 2026 at 7:58 am

    whatever you wrote that one correct but good practice is to write not null at a time of defining table.
    do like this:

    CREATE TABLE Courses(
        CourseNo INTEGER CHECK(100<=CourseNo<=999) PRIMARY KEY,
        Title VARCHAR(100) NOT NULL,
        )
    

    primary key is by default NOT NULL always, hence you no need to declare it as NOT NULL

    NOT NULL in alter is used when u want to make change in column definations of table later

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna change dynamicaly name of table in sql query. For example I have
CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) unsigned NOT NULL auto_increment, `user_id`
when i wanna create a new contact, i think i must set a RAW_CONTACT_ID.
I wanna create a Boolean field in my oracle table but I seen there
I wanna create table in database with column of type date. But I can't
I got some trouble with the TableLayout Android. I wanna create a table with
I'm using LINQ to SQL. I wanna create a database with LINQ but the
I use SQL Server and when I create a new table I make a
I wanna put the results from sql query into a table but if i
I wanna create a table in my PhpMyAdmin to be able to use this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.