< Sql Tutorial

Sql Database Command

← Previous Next →


SQL CREATE Database

The SQL CREATE DATABASE statement is used by a developer to create a database.

Syntax:

CREATE DATABASE DatabaseName;

If you want to add tables in that database, you can use CREATE TABLE statement. In MySQL, you need to create database first then table. But, you don't need to create database in Oracle. In Oracle database, you can create table directly.


SQL DROP Database

SQL DROP statement is used to delete or remove indexes from a table in the database. If you want to delete or drop an existing database in a SQL schema, you can use SQL DROP DATABASE

Syntax:

DROP DATABASE DatabaseName;

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

Sometimes you need to change the name of your database because of the original name was not more relevant to the data. Or, you just want to give a temporary name to that data. SQL RENAME DATABASE statement is used to change the name of a database.

RENAME DATABASE old_db_name TO new_db_name;

SQL SELECT Database

SQL select statement is used to query or retrieve data from a table in the database. It is the most commonly used statement in SQL command. If you want to retrieve information from specified column or all columns from a table, use SQL SELECT query.

Syntax:

SELECT column_list FROM table_name
[WHERE Clause]
[GROUP BY Clause]
[HAVING Clause]
[ORDER BY Clause];
The example of select statement is given below:

SELECT firstname,lastname,salary FROM employee;
← Previous Next →