Complete the code to define a column named 'age' as an integer.
CREATE TABLE Persons (age [1]);The INT data type is used to define integer columns in MySQL.
Complete the code to add a NOT NULL constraint to the 'name' column.
CREATE TABLE Employees (name VARCHAR(50) [1]);
The NOT NULL constraint ensures the column cannot have NULL values.
Fix the error in the code to set 'id' as the primary key.
CREATE TABLE Orders (id INT [1], order_date DATE);The PRIMARY KEY constraint uniquely identifies each record in the table.
Fill all three blanks to define a 'salary' column as decimal with 10 digits total and 2 decimal places, and ensure it cannot be NULL.
CREATE TABLE Staff (salary [1]([2], 2) [3]);
DECIMAL(10, 2) defines a number with 10 digits total and 2 after the decimal point. NOT NULL ensures the column must have a value.
Fill all three blanks to define a 'username' column as VARCHAR(30), make it UNIQUE, and set a default value 'guest'.
CREATE TABLE Users (username [1]([2]) DEFAULT 'guest' [3]);
VARCHAR(30) defines a text column with max 30 characters. UNIQUE ensures no two users have the same username. DEFAULT 'guest' sets the default username if none is provided.