Using NOT NULL Constraint in SQL
📖 Scenario: You are creating a simple database table to store information about employees in a company. Each employee must have a unique ID and a name. The name cannot be empty because it is important to identify each employee.
🎯 Goal: Create a table called employees with two columns: id and name. The id column should be an integer and the primary key. The name column should be text and must not allow NULL values.
📋 What You'll Learn
Create a table named
employeesAdd an
id column of type INTEGER as the primary keyAdd a
name column of type TEXT with a NOT NULL constraint💡 Why This Matters
🌍 Real World
Ensuring important data fields like employee names are always filled in a company database.
💼 Career
Database developers and administrators use NOT NULL constraints to maintain data integrity and prevent missing critical information.
Progress0 / 4 steps