Create Database Syntax for MySQL
CREATE DATABASE [IF NOT EXISTS] db_name
[create_specification [, create_specification] …]
create_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name
CREATE DATABASE creates a database with the given name. To use CREATE DATABASE, you need
the CREATE privilege on the database.
Rules for allowable database names are “Database, Table, Index,
Column, and Alias Names.” An error occurs if the database already exists and you didn’t
specify IF NOT EXISTS.
As of MySQL 4.1.1, create_specification options can be given to specify database characteristics.
Database characteristics are stored in the db.opt file in the database directory. The
CHARACTER SET clause specifies the default database character set. The COLLATE clause specifies
the default database collation. Character set and collation names are discussed in
Chapter 3, “Character Set Support.”
Databases in MySQL are implemented as directories containing files that correspond to
tables in the database. Because there are no tables in a database when it is initially created,
the CREATE DATABASE statement only creates a directory under the MySQL data directory
(and the db.opt file, for MySQL 4.1.1 and up).
You can also use the mysqladmin program to create databases.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.










Comments
No comments yet.
Leave a comment