0
0
SQLquery~10 mins

INSERT and auto-generated keys in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to insert a new row into the users table.

SQL
INSERT INTO users (name, email) VALUES ([1], 'user@example.com');
Drag options to blanks, or click blank then click option'
Aname
B'user@example.com'
C'Alice'
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the name in quotes.
Using column names instead of values.
2fill in blank
medium

Complete the code to insert a new product with a price into the products table.

SQL
INSERT INTO products (product_name, price) VALUES ('Book', [1]);
Drag options to blanks, or click blank then click option'
A20
B'price'
Cproduct_name
D'20'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numeric values inside quotes.
Using column names instead of values.
3fill in blank
hard

Fix the error in the INSERT statement to add a new employee with auto-generated ID.

SQL
INSERT INTO employees ([1], name) VALUES (NULL, 'John');
Drag options to blanks, or click blank then click option'
Aname
Bid
Cemployee_id
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name for the auto-generated key.
Inserting a value instead of NULL for the auto-generated key.
4fill in blank
hard

Fill both blanks to insert a new order with auto-generated order_id and a customer name.

SQL
INSERT INTO orders ([1], customer_name) VALUES ([2], 'Emma');
Drag options to blanks, or click blank then click option'
Aorder_id
BNULL
C'order_id'
D'NULL'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around NULL value.
Using wrong column name for the auto-generated key.
5fill in blank
hard

Fill all three blanks to insert a new record with auto-generated id, product name, and price.

SQL
INSERT INTO inventory ([1], [2], [3]) VALUES (NULL, 'Laptop', 1500);
Drag options to blanks, or click blank then click option'
Aid
Bproduct_name
Cprice
Dquantity
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column names like 'quantity'.
Not matching columns with values.