How to create an SQLite table in 5 Minutes

  • by

SQLite ‘CREATE’ table statement

In this article, we will see how to create a table in SQLite with examples using dbHarbor.

SQL CREATE TABLE statement is used to create a new table in any of the given databases.

CREATE TABLE is the keyword telling the database system to create a new table. The unique name or identifier for the table follows the CREATE TABLE statement. Optionally, you can specify database_name along with table_name. Column names and their datatypes should follow the table_name. Each column can have one of these data types:

  • NULL — The value is a NULL value
  • INTEGER — a signed integer
  • REAL — a floating-point value
  • TEXT — a text string
  • BLOB — a blob of data

Let’s take a look at an example:

first_name TEXT(45) NOT NULL,
last_name TEXT(45) NOT NULL)

Using dbHarbor – visual table editor for SQLite database

There are two ways to create SQLite tables in dbHarbor.

Run SQL query

You can write the CREATE TABLE statement and run it from the query editor.

To open a new query window in dbHarbor press CMD+T or use the ‘+’ button in the top right corner beneath the toolbar.

Run CREATE TABLE sql statement in dbHarbor.

Now, after you defined a table with an SQL statement press the ‘Run’ button to execute the query. This is it. The table named ‘actor’ is created.

Use Table Schema Editor

It is really simple to define a table schema in dbHarbor because you don’t need to know the exact SQL syntax for creating a table. dbHarbor comes with the table schema editor.

  • Open a database in dbHarbor
  • Click on the ‘+’ button in the bottom left corner of database explorer
  • Select ‘New table…’ menu item
Create a table in dbHarbor SQLite

Now you can define column names and data types using the table editor. To add or remove columns use ‘+’ and ‘-‘ buttons underneath the editor view.

Important! The table is not immediately created. Press CMD+S to submit the designed table to SQLite.

If you don’t want to miss the latest news about our development journey or join the beta waiting list for an exclusive, early access version, signup for our newsletter. Promise not to SPAM😎

Leave a Reply

Your email address will not be published. Required fields are marked *