Creating & Editing Tables
To add a table, use the button in the bottom-left corner of the database window.
To alter an existing table, select it in the sidebar, the click the
button and select Alter…
from the menu that appears.
Info
For details on the language behind creating tables, see the SQLite documentation
The table editor
From top to bottom, the table editor shows:
- The table name
- Columns within this table, along with types and column-level constraints
- Table-level constraints
- Table options
Columns
Table columns have a name, usually a type, and optionally constraints.
To add or remove columns, use the plus () and minus () icons below the list of columns.
The name can be any text. Commonly used types are provided, but can be overridden if desired.
Constraints are represented by a row of coloured icons. From left-to-right these are:
- P: Primary Key
- N: Not Null
- U: Unique
- C: Check
- D: Default
- C: Collate
- F: Foreign Key
- G: Generated
Constraints that are not used will be shown as faded out. Active ones with be shown in bolder colors.
Clicking on a constraint icon will pop open an options view, where you can set the properties for that constraint as needed.
Table constraints
Some constraints can be specified at the table level rather than as part of the column definition.
Much like columns, you can add or remove columns, using the plus () and minus () icons below the list of table constraints. Once added, you can select the constraint type, and click the options icon to adjust options as needed.
You can read more in the SQLite documentation.
Table options
SQLite allows the setting of additional options for tables. At the time of writing, the available options are: