Database Commands


☞ Following are the topics to be covered :

1. Creating a Database
2. Opening a Database
3. Viewing a Database
4. Removing a Database

Creating a Database

☞ To create a database in RDBMS, we use CREATE DATABASE command.

Syntax :
CREATE DATABASE <database_name> ;

☞ Suppose we want to create a database named school

Example :
CREATE DATABASE school; ;
Output :
Query OK, 1 row affected

Viewing a Database

☞ To verify that a database is created in RDBMS, we use SHOW DATABASES command.

Syntax :
SHOW DATABASES ;

☞ To view all the databases.

Example :
SHOW DATABASES ;
Output :
Database
school

Opening a Database

☞ Once a database has been created, we need to open a database in RDBMS, we use USE command.

Syntax :
USE <database_name> ;

☞ Suppose we want to use the database named school.

Example :
USE school ;
Output :
Database changed

Removing a Database

☞ To remove/delete a database along with all its tables in RDBMS, we use DROP DATABASE command.

Syntax :
DROP DATABASE <database_name>;

☞ Suppose we want to remove the database named school.

Example :
DROP DATABASE school ;
Output :
Query OK, 0 row affected