CREATE DATABASE (often shortened informally to CREATE DB) is a Data Definition Language (DDL) statement that establishes a brand-new logical database on the target server. Executing it allocates catalog entries, default system schemas, and the physical storage required for future tables, indexes, and other objects. The exact side effects, default settings, and optional clauses vary by SQL dialect, but the core behavior is the same: after a successful run, the database name becomes available for connections and object creation. Because it changes global server state, CREATE DATABASE usually demands elevated privileges (e.g., CREATEDB, sysadmin, or root) and cannot run inside an open transaction block in some engines. Attempting to create a database that already exists without the proper conditional clause raises an error.
database_name
(identifier) - Name of the database to create.IF NOT EXISTS
(keyword, MySQL/SQLite) - Skip creation if the database already exists.OWNER
(identifier, PostgreSQL) - Role that will own the database.TEMPLATE
(identifier, PostgreSQL) - Template database to clone.ENCODING / CHARACTER SET
(string) - Default character set.COLLATE / LC_COLLATE / LC_CTYPE
(string) - Default collation rules.ON PRIMARY, FILENAME
(SQL Server) - Filegroup and physical file options.CREATE SCHEMA, DROP DATABASE, ALTER DATABASE, CREATE TABLE, GRANT
SQL-92 standard; earlier vendor support existed in Sybase/SQL Server.
Most systems demand elevated rights. In PostgreSQL you need the CREATEDB attribute, in MySQL the CREATE privilege at the global level, and in SQL Server membership in the sysadmin or dbcreator role.
Yes. MySQL uses DEFAULT CHARACTER SET and DEFAULT COLLATE. PostgreSQL offers ENCODING, LC_COLLATE, and LC_CTYPE. Choosing correctly at creation avoids data-integrity issues later.
In MySQL include IF NOT EXISTS. In other engines write a conditional wrapper or drop the database beforehand. Failing to do so triggers a duplicate-object error.
SQLite treats each file as a self-contained database. Opening or creating a new file automatically provides a database, so the statement is unnecessary and unsupported.