SQL CREATE Database:
The SQL CREATE RENAME and SELECT DATABASE statements is used by a developer to create rename and select database.
Let’s see the syntax of SQL CREATE DATABASE:
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.
CREATE DATABASE CyberZonec;
Where “Employee” is the name of database.
SQL DROP or DELETE 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
Let’s see the syntax of SQL DROP DATABASE:
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.
Example:If you want to delete an existing database <Employee>, then DROP DATABASE statement would be as follows:
SQL> DROP DATABASE Employee;
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. Let’s see how to rename MySql and SQL Server databases.
Rename MySQL database
To rename the mysql database, you need to follow the following syntax:
RENAME DATABASE old_db_name TO new_db_name;
Rename SQL server database using T-SQL
This command is useful for SQL server 2005, 2008, 2008R2 and 2012.
ALTER DATABASE old_name MODIFY NAME = new_name
If you are using SQL server 2000, you can also use this command to rename the database. But, Microsoft phased out it.
EXEC sp_renamedb ‘old_name’ , ‘new_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.
The basic syntax of SQL SELECT statement is given below:
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 Name,City,Course FROM STUDENT;