Introduction SQL

Basic SQL

SQL Constraints

Advance SQL

SQL Joins

SQL Function


SQL CREATE / SHOW / USE / DROP DATABASE Statement


SQL CREATE DATABASE Statement

SQL CREATE DATABASE statement to create new database. Oracle SQL you have to first create new database. Before you learn how to create new database you must have to know about SQL structure.

SQL structure is hierarchically, You first create database. Select database for USE. Now you are in selected database are. you are access all table as well as make new table and so many things you can done.

Syntax

You have to create new database use following SQL CREATE DATABASE syntax,

CREATE DATABASE database_name;

Example

SQL> CREATE DATABASE user_db;

SQL SHOW DATABASE Statement

SQL SHOW DATABASE statement to display list of all created database.

SQL> SHOW DATABASES;

+---------------------+
| Database            |
+---------------------+
| information_schema  |
| scott               |
| user_db		      |
| demodb              |
+---------------------+ 
4 rows in set (0.01 sec)

SQL USE Statement

IN your SQL number of database exist. So whenever you work with database you must have to select (USE) on database at a time. and you can switch over any time using USE statement.

SQL USE statement to switch your existing selected database with another define database.

Syntax

USE database_name;

Example

SQL> USE user_db;

Database changed

SQL DROP DATABASE Statement

SQL DROP DATABASE statement to drop the existing database any time.

Syntax

DROP DATABASE database_name;

Example

SQL> DROP DATABASE user_db;

Now you can again execute SHOW DATABASE statement. user_db database deleted.

SQL> SHOW DATABASES;

+---------------------+
| Database            |
+---------------------+
| information_schema  |
| scott               |
| demodb              |
+---------------------+ 
3 rows in set (0.00 sec)