We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Creating a Table

To create a new table in a database, use the CREATE TABLE statement followed by the name of the table and the fields you want in the table.

CREATE TABLE employees (id INTEGER, name TEXT, age INTEGER, is_manager BOOLEAN, salary INTEGER);

Each field name is followed by its datatype. We'll get to data types in a minute.

It's also acceptable and common to break up the CREATE TABLE statement with some whitespace like this:

CREATE TABLE employees(
  id INTEGER,
  name TEXT,
  age INTEGER,
  is_manager BOOLEAN,
  salary INTEGER
);

Assignment

Let's begin building a table for the CashPal database! Create the people table with the following fields:

Use INTEGER instead of INT before submitting your code.

While the two notations are functionally identical, INTEGER is the fully standard-compliant keyword. We prefer INTEGER in this course for clarity, consistency, and better portability across SQL dialects.

Tip

If you're curious, the PRAGMA TABLE_INFO(TABLENAME); command in the test file returns information about a table and its fields.