SQL CREATE DATABASE Statement

SQL CREATE DATABASE Statement

SQL CREATE DATABASE Statement

The SQL CREATE DATABASE statement is used to create a new database in a SQL server. Here is the basic syntax for the CREATE DATABASE statement:

				
					CREATE DATABASE database_name;
				
			

In this syntax, database_name is the name of the new database you want to create.

Here is an example of using the CREATE DATABASE statement:

				
					CREATE DATABASE my_database;
				
			

In this example, a new database named “my_database” is created. You can verify that the database was created by using the following command:

				
					SHOW DATABASES;
				
			

This will display a list of all the databases on the SQL server, including the new one you just created.

There are also additional parameters that can be used with the CREATE DATABASE statement to specify the character set, collation, and other settings for the new database. Here is an example of using the CREATE DATABASE statement with additional parameters:

				
					CREATE DATABASE my_database
  CHARACTER SET utf8
  COLLATE utf8_general_ci;

				
			

In this example, the “utf8” character set and “utf8_general_ci” collation are specified for the new database.

It’s important to note that the CREATE DATABASE statement may require administrative privileges to execute, depending on the configuration of the SQL server.

Join To Get Our Newsletter
Spread the love