Krivalar Tutorials 
Krivalar Tutorials



SQL CREATE DATABASE

<<Previous - SQL Data Types

Next - Drop Database >>





SQL commands are available for creating a new database and changing or modifying structure of the tables in the database. The set of SQL commands are collectively called Data Definition Language (DDL).

Features of the DDL.

  1. DDL allow us to define and create new database and tables.
  2. DDL allows us to remove the tables from the database and we can easily change the table's structure.
  3. By using DDL, we can control the physical storage of the data in database.
  4. It allows us to define the virtual tables of data (ex :views)
  5. We can easily make the security related control over on the databases.
  6. We can build an index for on table so that we can access those table faster.

In DDL, there are three main SQL verbs which act as the basic core of the DDL. Most of the SQL based DBMS products support these three SQL verbs that are

  1. CREATE used to create database and tables.
  2. DROP used to drop the tables as well as databases.
  3. ALTER used to change the structure of the tables.

CREATE Database

This statement is used to create the new database.

	Syntax

	CREATE DATABASE database-name;
	
Note. If you want to create new database, first you will get the administrator privileges. Otherwise you don't allow to create a database.

Example SQL query: Here we create a database as collegeDB


mysql> CREATE DATABASE collegeDB;
Query OK, 1 row affected (0.31 sec)

SHOW database

Once database is created, we can visually see it by using the 'SHOW databases' SQL statement.

mysql> SHOW databases;

The above statement will display the all databases created in the RDBMS server.

+--------------------+
| Database           |
+--------------------+
| collegedb          |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| world              |
+--------------------+
6 rows in set (0.11 sec)


Using database

Now we are ready to use that database. Further, you can define the tables inside the selected database. 'Use database' can be used to select the specific database.

Use Database Syntax and example

USE database-name;

For Example:

mysql> USE collegeDB;
Database changed

<<Previous - SQL Data Types

Next - Drop Database >>








Searching using Binary Search Tree