Syntax
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints
);
Common Constraints
- PRIMARY KEY — unique identifier
- NOT NULL — cannot be empty
- UNIQUE — no duplicates
- DEFAULT — fallback value
Lesson 12 of 22 · SQLite
Create tables with SQL CREATE TABLE, PRIMARY KEY, NOT NULL and DEFAULT, then insert rows.
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints
);
Create a table called pets with three columns, in this order: id (integer primary key), name (text, NOT NULL) and species (text). Then add a dog named Rex and a cat named Tom.
Solve it in your browserFree, no sign-up. The SQLite database runs in your browser; your answer is checked instantly, with hints if you need them. Plus a 2-question quiz.