Challenge - 5 Problems
CREATE TABLE Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the result of this CREATE TABLE statement?
Consider this MySQL statement:
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), age INT);What will be the structure of the
employees table after running this?MySQL
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), age INT);
Attempts:
2 left
💡 Hint
Look at the data types and constraints defined for each column.
✗ Incorrect
The statement creates a table 'employees' with three columns: 'id' as integer primary key, 'name' as VARCHAR(50), and 'age' as integer.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this CREATE TABLE statement
Which option correctly identifies the syntax error in this statement?
CREATE TABLE products (product_id INT, product_name VARCHAR(100), price DECIMAL(10,2) NOT NULL,);
MySQL
CREATE TABLE products (product_id INT, product_name VARCHAR(100), price DECIMAL(10,2) NOT NULL,);
Attempts:
2 left
💡 Hint
Check punctuation carefully inside the parentheses.
✗ Incorrect
The trailing comma before the closing parenthesis is not allowed in MySQL CREATE TABLE syntax.
🧠 Conceptual
advanced2:00remaining
What does the following CREATE TABLE statement do?
Analyze this statement:
CREATE TABLE orders (order_id INT AUTO_INCREMENT PRIMARY KEY, order_date DATE DEFAULT CURRENT_DATE, customer_id INT, UNIQUE (customer_id, order_date));What is the purpose of the UNIQUE constraint here?
MySQL
CREATE TABLE orders (order_id INT AUTO_INCREMENT PRIMARY KEY, order_date DATE DEFAULT CURRENT_DATE, customer_id INT, UNIQUE (customer_id, order_date));
Attempts:
2 left
💡 Hint
Think about what UNIQUE means when applied to multiple columns.
✗ Incorrect
The UNIQUE constraint on (customer_id, order_date) prevents duplicate pairs of these values, ensuring each customer can have only one order per date.
🔧 Debug
advanced2:00remaining
Why does this CREATE TABLE statement fail?
Given this statement:
CREATE TABLE inventory (item_id INT PRIMARY KEY, quantity INT DEFAULT 'ten');Why will this cause an error?
MySQL
CREATE TABLE inventory (item_id INT PRIMARY KEY, quantity INT DEFAULT 'ten');
Attempts:
2 left
💡 Hint
Check the data type compatibility of default values.
✗ Incorrect
The DEFAULT value must match the column's data type. 'ten' is a string and cannot be used as default for an INT column.
❓ optimization
expert2:00remaining
Which CREATE TABLE option optimizes storage for a large table with many NULL values?
You want to create a table with many optional columns that often have NULL values. Which option best optimizes storage in MySQL?
Attempts:
2 left
💡 Hint
Think about how NULL values are stored in MySQL.
✗ Incorrect
Allowing columns to be NULL without default values saves space because NULLs do not store data, unlike default values which consume space.