CREATE DATABASE
The CREATE DATABASE statement creates a new, empty database. A single SereneDB server can host many independent databases (the default is postgres); switch between them with USE or by connecting to one directly.
Examples
Create a database named app_production:
Query
DROP DATABASE IF EXISTS app_production;
CREATE DATABASE app_production;Use IF NOT EXISTS so the statement succeeds even when the database already exists, instead of raising an error:
Query
CREATE DATABASE IF NOT EXISTS app_production;Once created, you can connect to it like any other database — for example with psql:
psql -h localhost -p 7890 -d app_production
As an alternative to reconnecting, switch to the new database within the current session with the USE statement:
Query
USE app_production;See also
- ATTACH / DETACH — attach an existing database file
- USE — switch the active database