C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQL Create DatabaseIn SQL, the 'Create Database' statement is a first step for storing the structured data in the database. The database developers and the users use this statement in SQL for creating the new database in the database systems. It creates the database with the name which has been specified in the Create Database statement. Syntax of Create Database statement in SQLCREATE DATABASE Database_Name; In this syntax, Database_Name specifies the name of the database which we want to create in the system. We have to type the database name in query just after the 'Create Database' keyword. Following are the most important points which are required to learn while creating a database:
Syntax of Create Database statement in MySQLThe same command is used in MySQL to create the new database for storing the structured data. CREATE DATABASE Database_Name; Syntax of Create Database in OracleThere is no need to create the database in Oracle systems. In the Oracle database, we can directly create the database tables. Examples of Create Database statement in SQLIn this article, we took the following two examples which will help how to run and perform the Create Database query in SQL: Example 1: This example creates the Student database. To create the Student database, you have to type the following command in Structured Query Language: CREATE DATABASE Student ; When this query is executed successfully, then it will show the following output: Database created successfully You can also verify that your database is created in SQL or not by using the following query: SHOW DATABASE ; SQL does not allow developers to create the database with the existing database name. Suppose if you want to create another Student database in the same database system, then the Create Database statement will show the following error in the output: Can't create database 'Student'; database exists So, firstly you have to delete the existing database by using the Drop Statement. You can also replace the existing database with the help of Replace keyword. If you want to replace the existing Student database, then you have to type the following SQL query: CREATE OR REPLACE DATABASE Student ; Example 2: Suppose, we want to create the Employee database in the system. Firstly, we have to type the following command in Structured Query Language: CREATE DATABASE Employee ; When this query is executed successfully, then it will show the following output: Database created successfully You can also check that your database is created in SQL by typing the following query: SHOW DATABASE ; We know that SQL does not allow developers to create the database with the existing database name. Suppose, we want to create another Employee database in the same database system, firstly, we have to delete the existing database using a drop statement, or we have to replace the existing Employee database with the help of the 'replace' keyword. To replace the existing Employee database with a new Employee database, we have to type the following query in SQL: CREATE OR REPLACE DATABASE Employee;
Next TopicSql DROP Database
|