Create Table

The (columns), AS query, and EDIT SQL tabs allow you to create a table in various ways.

Create table dialog

Database

A combo box with databases attached. The temp database will be included even if it is not visible in the schema browser because it has not been referenced yet (this is an oddity in sqlite itself). If a database in the schema browser was selected, that database is preselected in this combo box.

Table Name

Name of new table. It must be nonempty to enable table creation.

(columns) tab

Use "Add" and "Remove" buttons to create columns for this table. Every column must have a table-unique name, chosen data type (prepared combo box), optional extra constraint, and optional DEFAULT value. Prepared data types are BLOB, INTEGER, REAL, and TEXT: if you want to use your own non-standard data type, you can type it into the combo box. Available extra constraints are (nothing), NOT NULL, PRIMARY KEY (implies NOT NULL), or AUTOINCREMENT (implies PRIMARY KEY and NOT NULL). The rules for admissible default values are complex and described in Appendix B. If a default value is not admissible it will be highlighted in red and the "Create" button will be disabled and grayed out.

Important

Consult Sqlite documentation for data type, NOT NULL, and DEFAULT handling specials, please.
AS query tab

This opens the query builder where you can create a table using a CREATE TABLE name AS SELECT ... statement.

Edit SQL tab

You can write any SQL CREATE TABLE statement here: the first line containing 'CREATE TABLE "schemaname"."tablename" [AS or (]' is not editable except by changing the Database name or Table Name in the fields above. When you first open this tab, it will make a CREATE TABLE statement from the information in the previously open (columns) or AS query tab. Every subsequent time you open this tab you will be asked if you want to keep the existing SQL or make it from the information in the previously open tab again.

If you omit the terminating semicolon, sqliteman will add it for you.

Without rowid

Check this box to create a WITHOUT ROWID table. It must have at least one PRIMARY KEY and no AUTOINCREMENT.

Create

Press this button to create the table. When the (columns) tab is selected, the Create button is only enabled when the new table name is nonempty, and the table name is different (ignoring case) from the name of any view or index or other table in the database, and all column names are different (ignoring case), and if there is an AUTOINCREMENT column its type is INTEGER and no other column is a PRIMARY KEY, and if Without rowid is checked there is at least one PRIMARY KEY column, and any column default values are admissible (see Appendix B). When the AS query tab or the Edit SQL tab is selected, the Create button is only enabled when the new table name is nonempty, and the table name is different (ignoring case) from the name of any view or index or other table in the database. The result of this operation is shown in the text area below, which will appear if it is needed and expand if it needs to contain a long error message.

Sqlite will permit a table to be created with a table name which contains non-alphanumeric characters or with an empty string as a column name, so sqliteman allows these. However in both of these cases it asks if you really want to do it, since the underlying library doesn't handle such tables correctly.

Close

Press this button to close the dialog. You can close the dialog without creating any tables or after creating one or several tables.