What Is a Table?
The most important concept in SQL is the table.
A table looks like a spreadsheet.
- Column: the type of data (example: name, age)
- Row: one record (example: “Alex”, 23)
Example:
| id | name | age |
|---|---|---|
| 1 | Alex | 23 |
| 2 | Juno | 19 |
Here:
id,name,ageare columns- Each student line is a row
Create a table (CREATE TABLE)
The basic form looks like this:
CREATE TABLE users (
id INTEGER,
name TEXT,
age INTEGER
);
This creates a table named users
with columns id, name, and age.
Wait, do you notice something interesting?
Unlike many other languages, CREATE, TABLE, and INTEGER are all written in uppercase.
We will talk briefly about this in the next chapter.