SQL CREATE DATABASE

SQL Tutorial

Here is a clear and practical guide to the SQL CREATE DATABASE statement, with syntax for MySQL, PostgreSQL, SQL Server, and Oracle.

What SQL CREATE DATABASE Does

CREATE DATABASE creates a new database on the server.
Inside it, you can then create tables, views, stored procedures, etc.

 ANSI SQL Basic Syntax

Most SQL engines support this form with small variations.

MySQL — CREATE DATABASE

Create with charset and collation:

Check if database exists:

 PostgreSQL

Create with owner and encoding:

List databases:

l

 SQL Server

Create with file configuration:

Oracle — CREATE DATABASE

(Usually done via DBCA or admin tools, but SQL is possible.)

  •  Oracle database creation is complex and typically done by DBAs.

 Selecting / Switching Databases

MySQL:

PostgreSQL:

SQL Server:

Best Practices

  •  Use meaningful names (e.g., hr_db, inventory, analytics)
  •  Choose consistent character sets (UTF8/UTF8MB4 recommended)
  •  Ensure permissions for the database owner
  •  Follow naming conventions (no spaces, lowercase recommended)
  •  Avoid using reserved keywords as database names

You may also like...