0% found this document useful (0 votes)
63 views1 page

SQL - CREATE Database

The SQL CREATE DATABASE statement is used to create a new SQL database. The basic syntax is CREATE DATABASE DatabaseName;. The database name must be unique within the RDBMS and the user needs the necessary privileges to create a database otherwise an error will occur. Once created, the new database can be viewed in the list of databases and used with the SQL USE statement.

Uploaded by

Marlon Magtibay
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
63 views1 page

SQL - CREATE Database

The SQL CREATE DATABASE statement is used to create a new SQL database. The basic syntax is CREATE DATABASE DatabaseName;. The database name must be unique within the RDBMS and the user needs the necessary privileges to create a database otherwise an error will occur. Once created, the new database can be viewed in the list of databases and used with the SQL USE statement.

Uploaded by

Marlon Magtibay
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 1

SQL - CREATE Database

he SQL CREATE DATABASE statement is used to create a new SQL database. If you are


creating your database on Linux or Unix, then database names are case-sensitive though SQL
keywords are case-insensitive. If you are working on Windows then this restriction does not
apply.

Syntax
The basic syntax of this CREATE DATABASE statement is as follows −
CREATE DATABASE DatabaseName;
Always the database name should be unique within the RDBMS.
While creating a database, you may encounter an error such as ERROR 1044 (42000): Access denied
for user 'krishna'@'localhost' to database 'DatabaseName', this means that you do not have the
necessary privileges to create a database.

Example
If you want to create a new database <testDB>, then the CREATE DATABASE statement would
be as shown below −
SQL> CREATE DATABASE testDB;
Make sure you have the necessary privilege before creating any database. Once a database is
created, you can check it in the list of databases as follows −
SQL> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| AMROOD |
| TUTORIALSPOINT |
| mysql |
| orig |
| test |
| testDB |
+--------------------+
7 rows in set (0.00 sec)
Once you have created a database, you can use it using the SQL USE statement as shown below:
SQL> USER testDB;
Database changed

You might also like