SQL Default Constraint

1.What does the DEFAULT constraint do?
  • A. Forces entry of value
  • B. Allows NULLs
  • C. Assigns a default value if none is given
  • D. Disables indexing

Assigns a default value if none is given

Assigns a default value if none is given

2.What will country be?
CREATE TABLE customers ( name VARCHAR(50), country VARCHAR(50) DEFAULT 'India' ); INSERT INTO customers(name) VALUES ('Rahul');
  • A. NULL
  • B. India
  • C. USA
  • D. Error

India

India

3.Which of these defines a default value correctly?
  • A. DEFAULT ‘India’
  • B. SET DEFAULT = ‘India’
  • C. ADD DEFAULT(‘India’)
  • D. CONSTRAINT DEFAULT India

DEFAULT ‘India’

DEFAULT ‘India’

4.When is the default value used?
  • A. Always
  • B. When column is NULL
  • C. When no value is provided
  • D. When constraint fails

When no value is provided

When no value is provided

5.What will be the output of the given code?
CREATE TABLE orders ( id INT, status VARCHAR(10) DEFAULT 'Pending' ); INSERT INTO orders(id, status) VALUES (1, 'Shipped');
  • A. status = Pending
  • B. status = NULL
  • C. status = Shipped
  • D. Error

status = Shipped

status = Shipped