Bird
0
0

Consider the table products with column price DECIMAL(10,2) NOT NULL. What will be the result of this query?

medium📝 query result Q5 of 15
SQL - Table Constraints

Consider the table products with column price DECIMAL(10,2) NOT NULL. What will be the result of this query?

INSERT INTO products (price) VALUES (NULL);
AThe row is inserted with price set to 0.00
BThe query fails due to NOT NULL constraint violation
CThe price column is set to its default value
DThe query inserts NULL ignoring the constraint
Step-by-Step Solution
Solution:
  1. Step 1: Understand the NOT NULL constraint on price

    The price column cannot accept NULL values.
  2. Step 2: Analyze the insert statement

    Inserting NULL violates the NOT NULL constraint, causing the query to fail.
  3. Final Answer:

    The query fails due to NOT NULL constraint violation -> Option B
  4. Quick Check:

    NOT NULL rejects NULL inserts causing failure [OK]
Quick Trick: NOT NULL columns reject NULL inserts [OK]
Common Mistakes:
MISTAKES
  • Assuming NULL converts to zero
  • Expecting default value without DEFAULT clause
  • Ignoring constraint errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes