SQL Check Constraint

1.What does the CHECK constraint do?
  • A. Checks for NULL values
  • B. Validates values based on a condition
  • C. Checks table structure
  • D. Ensures foreign key integrity

Validates values based on a condition

Validates values based on a condition

2.Which of the following defines a CHECK constraint correctly?
  • A. CHECK (age > 0)
  • B. CHECK age > 0
  • C. CHECK age = NULL
  • D. age > 0 CHECK

CHECK age > 0

CHECK age > 0

3.What would be the result of the given code?
CREATE TABLE marks ( student_id INT, score INT CHECK (score <= 100) ); INSERT INTO marks VALUES (1, 105);
  • A. Row inserted
  • B. score becomes 100
  • C. Error
  • D. Rounds down

Error

Error

4.What happens if the CHECK condition fails during INSERT?
  • A. It skips the row
  • B. It inserts NULL
  • C. It throws an error
  • D. It updates old row

It throws an error

It throws an error

5.What is the result of CHECK (salary >= 3000)?
  • A. Rejects rows with salary < 3000
  • B. Accepts all rows
  • C. Accepts NULL salaries
  • D. Deletes such rows

Rejects rows with salary < 3000

Rejects rows with salary < 3000