SQL Database

1. SQL CREATE DATABASE

  • A SQL CREATE statement is used to create a database.
  • In MYSQL, the initial step is to create a database and then table. But in Oracle, it is not necessary to create a database first. User can create a table without creating a database.
Syntax:
CREATE DATABASE Database Name;

Example:
To create a database for Employee.

CREATE DATABASE Employee;

2. SQL DROP DATABASE

  • SQL DROP statement is used to delete indexes from a table in the database.
  • User can delete an existing database in SQL schema by using SQL DROP DATABASE.
  • User needs to be careful while using this command as all the tables and views also get deleted.
Syntax:
DROP DATABASE Database Name;

Example:
To delete database Employee.

DROP DATABASE Employee;

3. SQL RENAME DATABASE

SQL RENAME DATABASE statement is used to change the name of existing database.

Syntax:
RENAME DATABASE old_database_name TO new_database_name;

Example:
To change the name of database from A to B.

RENAME DATABASE A TO B;

4. SQL SELECT Database

  • The SQL SELECT statement is used to retrieve data from a table in the database.
  • User can retrieve information from one specific column or all columns from table by using SQL SELECT query.
Syntax:
SELECT column or column list  FROM table_name;

Example:
To select different columns from table student, the following syntax is used.

SELECT first_name, last_name, marks FROM student;