SQL Not Null Constraint

1.What is the purpose of NOT NULL constraint?
  • A. To accept NULL values
  • B. To enforce unique values
  • C. To ensure a column must have a value
  • D. To remove default values

To ensure a column must have a value

To ensure a column must have a value

2.Which columns can use NOT NULL?
  • A. Only primary keys
  • B. Only integers
  • C. Any data type
  • D. Only foreign keys

Any data type

Any data type

3.What happens if you insert NULL into a NOT NULL column?
  • A. It inserts default
  • B. It updates old value
  • C. Error
  • D. Skips the row

Error

Error

4.Which of the following constraints is always NOT NULL?
  • A. UNIQUE
  • B. PRIMARY KEY
  • C. FOREIGN KEY
  • D. CHECK

PRIMARY KEY

PRIMARY KEY

5.What happens to the below given code?
CREATE TABLE books ( id INT NOT NULL ); INSERT INTO books VALUES (NULL);
  • A. NULL inserted
  • B. Error: NOT NULL violation
  • C. ID auto-generated
  • D. Default = 0

Error: NOT NULL violation

Error: NOT NULL violation