Chapter2:SQL Database

SQL CREATE Database

To create a database developer used SQL CREATE DATABASE statement.

syntax of SQL CREATE DATABASE:

CREATE DATABASE database_name;  

CREATE TABLE statement, is use to add tables in database.

Create Database in Oracle

In Oracle you don’t need to create database, you can create tables directly.

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

SQL DROP Database

To delete or remove indexes from a table in the database we used SQL DROP statement.

Syntax of SQL DROP DATABASE:

DROP DATABASE database_name;
Note:If you delete or drop the database, all the tables and views will also be deleted. So be careful while using this command.

SQL RENAME Database

When you need to change the name of your database, SQL RENAME DATABASE is used . Sometimes it is used because you want to give a temporary name to that database or you think that the original name is not more relevant to the database.

Let’s find how to rename MySql and SQL Server databases.

Rename MySQL database

Syntax of rename the mysql database:

RENAME DATABASE old_db_name TO new_db_name;  

SQL SELECT Database

In MySQL database,before executing any query on table you need to select a database first, view etc.For this, we use following query:

USE DATABASE database_name;  

In oracle, you don’t need to select database.