Building tables
The next step is to create tables to hold your data. From here onwards, we are going to execute database queries using the SQL editor to practice SQL syntax.
- Open the SQL editor:
Your SQLiteStudio interface should look like this:
- Create a table to store data about academic programs. Name the table "programs" and give it two fields (aka, columns): one for "id", the other for "program_name":
The syntax for creating a table in SQLite is:
CREATE TABLE table_name ( field_name data_type constraints )
The data type will affect the behavior of the data in that field. For example, whether the data itself is treated as text or a number.
The constraints will affect the behavior of that field. For example, a field with a
NOT NULL
constraint means that each record must have some data in this field.
CREATE TABLE programs (
id INTEGER PRIMARY KEY,
program_name VARCHAR
);
Highlight the code you just entered in the SQL editor and click the blue triangle to execute it.