The CREATE DATABASE statement in SQL is used to create a new database in a relational database management system (RDBMS). Here's the basic syntax for creating a new database:
CREATE DATABASE database_name;
Example:
CREATE DATABASE my_database;
This command will create a new database called my_database.
Additional Options:
Some RDBMS allow you to specify options such as character sets, collations, etc. For example, in MySQL, you can specify the character set and collation like this:
CREATE DATABASE my_database
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
This creates the my_database with the utf8mb4 character set and the utf8mb4_unicode_ci collation.
Notes:
- The user running the
CREATE DATABASEcommand typically needs to have appropriate permissions, such asCREATEprivilege. - The name of the database should be unique within the RDBMS.
- Some RDBMS might have specific syntax or options, so it's always a good idea to consult the documentation for the specific system you are using (e.g., MySQL, PostgreSQL, SQL Server, etc.).
No comments:
Post a Comment