Name
CREATE DATABASE
Synopsis
CREATE {DATABASE|SCHEMA} [IF NOT EXISTS] database [options]This statement creates a new database with the name given. As
of version 5.0.2 of MySQL, the keyword DATABASE is
synonymous with SCHEMA wherever used in any SQL
statement. You can use the IF NOT EXISTS flag to
suppress an error message when the statement fails if a database with
the same name already exists.
A database name cannot be longer than 64 bytes (not characters)
in size. The system uses Unicode (UTF-8), so any character that is
part of the UTF-8 character set may be used. The name cannot be the
ASCII value of 0 (0x00) or 255
(0xff)—these are reserved. Database names should
not include single or double quotation marks or end with a space. If
you want a database name to include quotes, though, you will have to
enable the SQL mode of ANSI_QUOTES. This can be
done with the --sql-mode server option. As of
version 5.1.6 of MySQL, database names can contain backslashes,
forward slashes, periods, and other characters that may not be
permitted in a directory name at the filesystem level. If you use a
name that is a reserved word, you must always enclose it in quotes
when referring to it.
Special characters in the name are encoded in the filesystem
names. If you upgrade your system to a new version of MySQL and you
have a database that has special characters in its name, the database
will be displayed with a prefix of #mysql50#. For
instance, a database named human-resources will be displayed as ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access