employeesid column of type INTEGER as the primary keyname column of type TEXT with a NOT NULL constraintJump into concepts and practice - no test required
employeesid column of type INTEGER as the primary keyname column of type TEXT with a NOT NULL constraintemployees with one column id of type INTEGER that is the primary key.Use CREATE TABLE employees and define id INTEGER PRIMARY KEY.
employees table creation statement to add a name column of type TEXT that has a NOT NULL constraint.Add name TEXT NOT NULL as a column definition.
id 1 and name 'Alice' into the employees table.Use INSERT INTO employees (id, name) VALUES (1, 'Alice').
id 2 and name as NULL into the employees table. This should fail because of the NOT NULL constraint.Use INSERT INTO employees (id, name) VALUES (2, NULL) to see the NOT NULL constraint in action.
What does the NOT NULL constraint do in a database table?
Which of the following is the correct syntax to add a NOT NULL constraint to a column named email when creating a table?
CREATE TABLE users (
id INT PRIMARY KEY,
email ???
);
Given the table employees with columns id INT PRIMARY KEY and name VARCHAR(100) NOT NULL, what happens when you run this query?
INSERT INTO employees (id, name) VALUES (1, NULL);
Consider this table creation statement:
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(50) NOT NULL,
price DECIMAL(5,2)
);
Which of the following statements will cause an error?
You have a table orders with columns order_id INT PRIMARY KEY, customer_id INT NOT NULL, and order_date DATE NOT NULL. You want to add a new column status that must always have a value and defaults to 'pending'. Which is the correct way to add this column?