Skip to content

SQL CREATE DATABASE Statement

CREATE DATABASE creates a new, empty database on a database server. Tables, and the data in them, are added to it afterwards.

CREATE DATABASE database_name;

To create a database for the production company’s accounts:

CREATE DATABASE ProductionAccounts;

The new database holds no tables yet; CREATE TABLE adds them. You may need to switch to the new database before working in it, with USE ProductionAccounts; in MySQL and SQL Server, or by connecting to it in PostgreSQL.

Each database has its own way of listing what exists on the server:

Database Command
MySQL SHOW DATABASES;
SQL Server SELECT name FROM sys.databases;
PostgreSQL SELECT datname FROM pg_database;, or \l in the psql tool

SQLite has no server and no CREATE DATABASE. A SQLite database is a single file, created the first time you open it, for example with sqlite3 ProductionAccounts.db at the command line.