SQL Reference

Quick Reference

The NOT NULL keywords enforces a column to NOT accept NULL values (a record cannot be inserted/updated without adding a value to that field).

The following ensures that the employee_id, last_name, and first_name columns will NOT accept NULL values when the Employees table is created.

CREATE TABLE Employees (
    employee_id int NOT NULL,
    last_name varchar(255) NOT NULL,
    first_name varchar(255) NOT NULL,
    age int
);

The following ensures that the age column will NOT accept a NULL value when the Employees table already exists.

ALTER TABLE Employees
MODIFY age int NOT NULL;

SQL Notes:

  • Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.