Create Database in SQL

Rumman Ansari   Software Engineer   2023-03-25   7033 Share
☰ Table of Contents

Table of Content:


In Oracle

The SQL CREATE DATABASE statement is used to create a new SQL database.

  SQL> connect system/alone#i#4;
  Connected.
  SQL> GRANT ALL PRIVILEGES TO atnylaUser;

  Grant succeeded.

  SQL>

Create Database in Oracle

You don't need to create database in Oracle. In Oracle database, you can create tables directly.

Create Database in SQL Server

Syntax

The following SQL statement is the syntax for Creating a database.

      CREATE DATABASE databasename;
  

CREATE DATABASE Example

This is an example SQL statement for the above syntax.

SQL> CREATE DATABASE testDataBase;

Make sure you have the admin 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             |
| atnylaDB           |
| mysql              |
| orig               |
| test               |
| testDataBase       |
+--------------------+
7 rows in set (0.00 sec)

We should always remember that database name should be unique in the RDBMS.

Create Database in MySQL

In MySQL, same command is used to create a database.

Code:


CREATE DATABASE database_name;