MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:CREATE TABLE
Current Quiz Count:30
Progress
0%
Q1
Single Choice

What is the primary keyword used to create a new table in MySQL?

Q2
Single Choice

Which data type would you use for a column storing integer values in MySQL?

Q3
Single Choice

What is the correct syntax to create a table named 'employees' with columns 'id' (integer) and 'name' (varchar)?

Q4
Single Choice

Which statement is correct when creating a table with a primary key in MySQL?

Q5
Single Choice

How do you specify a default value for a column in a MySQL CREATE TABLE statement?

Q6
Single Choice

How can you ensure a column cannot have NULL values in MySQL?

Q7
Single Choice

What is the purpose of the AUTO_INCREMENT attribute in MySQL?

Q8
Single Choice

How would you create a table with a composite primary key in MySQL?

Q9
Single Choice

Which of the following is a correct statement to create a foreign key constraint in MySQL?

Q10
Single Choice

In MySQL, how would you create a table that stores text data efficiently for large amounts of text?

Q11
True / False

In MySQL, the CREATE TABLE statement is used to create a new database.

Q12
True / False

The VARCHAR datatype in MySQL requires a length specification when creating a table.

Q13
True / False

You can use the CREATE TABLE statement in MySQL to create a table without specifying any columns.

Q14
True / False

In MySQL, the PRIMARY KEY constraint can be applied to more than one column in a table.

Q15
True / False

The DEFAULT keyword in MySQL is used to set a default value for a column when creating a table.

Q16
True / False

In MySQL, columns defined with the NOT NULL constraint can accept NULL values.

Q17
True / False

In MySQL, the AUTO_INCREMENT attribute can be used on any column type.

Q18
True / False

In MySQL, you can create a table with a FOREIGN KEY constraint that references a column in the same table.

Q19
True / False

The ENGINE keyword in MySQL is used in the CREATE TABLE statement to specify the storage engine for the table.

Q20
True / False

In MySQL, creating a table with a TEXT column is more efficient than using a VARCHAR column for large text data.

Q21
Multiple Choice

Identify the correct CREATE TABLE statement for defining a table with a primary key and a unique constraint.

SQL Code
CREATE TABLE employees (
 employee_id INT PRIMARY KEY,
 first_name VARCHAR(50),
 last_name VARCHAR(50),
 email VARCHAR(100) UNIQUE
);
Q22
Multiple Choice

Select the correct CREATE TABLE statement that includes a foreign key constraint.

SQL Code
CREATE TABLE orders (
 order_id INT PRIMARY KEY,
 customer_id INT,
 order_date DATE,
 FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
Q23
Multiple Choice

Choose the correct CREATE TABLE statement that sets a default value for a column.

SQL Code
CREATE TABLE products (
 product_id INT PRIMARY KEY,
 product_name VARCHAR(100),
 category VARCHAR(50) DEFAULT 'General',
 price DECIMAL(10, 2)
);
Q24
Multiple Choice

Which CREATE TABLE statement correctly defines a table with a composite primary key?

SQL Code
CREATE TABLE order_items (
 order_id INT,
 product_id INT,
 quantity INT,
 PRIMARY KEY (order_id, product_id)
);
Q25
Multiple Choice

Determine the correct CREATE TABLE statement that includes a check constraint.

SQL Code
CREATE TABLE employees (
 employee_id INT PRIMARY KEY,
 first_name VARCHAR(50),
 last_name VARCHAR(50),
 salary DECIMAL(10, 2),
 CHECK (salary > 0)
);
Q26
Multiple Choice

Select the correct CREATE TABLE statement that defines a table with an auto-incrementing primary key.

SQL Code
CREATE TABLE invoices (
 invoice_id INT AUTO_INCREMENT PRIMARY KEY,
 customer_id INT,
 invoice_date DATE,
 amount DECIMAL(10, 2)
);
Q27
Multiple Choice

Which CREATE TABLE statement correctly specifies a table with multiple foreign keys?

SQL Code
CREATE TABLE student_courses (
 student_id INT,
 course_id INT,
 enrollment_date DATE,
 PRIMARY KEY (student_id, course_id),
 FOREIGN KEY (student_id) REFERENCES students(student_id),
 FOREIGN KEY (course_id) REFERENCES courses(course_id)
);
Q28
Multiple Choice

Identify the CREATE TABLE statement that includes a column with a NOT NULL constraint.

SQL Code
CREATE TABLE departments (
 department_id INT PRIMARY KEY,
 department_name VARCHAR(100) NOT NULL,
 manager_id INT
);
Q29
Multiple Choice

Choose the CREATE TABLE statement that defines a table with a column using the ENUM data type.

SQL Code
CREATE TABLE employees (
 employee_id INT PRIMARY KEY,
 first_name VARCHAR(50),
 last_name VARCHAR(50),
 employment_status ENUM('Active', 'Inactive', 'On Leave')
);
Q30
Multiple Choice

Determine the CREATE TABLE statement that correctly uses a column alias within the statement.

SQL Code
CREATE TABLE inventory (
 product_id INT PRIMARY KEY,
 product_name VARCHAR(100),
 quantity_in_stock INT AS qty_stock,
 price DECIMAL(10, 2)
);