Skip to content
Related Articles

Related Articles

Improve Article

SQL USE Database Statement

  • Last Updated : 06 Sep, 2021
Geek Week

SQL(Structured Query Language) is a standard Database language that is used to create, maintain and retrieve the data from relational databases like MySQL, Oracle, etc. It is flexible and user-friendly. In SQL, to interact with the database, the users have to type queries that have certain syntax, and use command is one of them. The use command is used when there are multiple databases in the SQL and the user or programmer specifically wants to use a particular database. Thus, in simple terms, the use statement selects a specific database and then performs operations on it using the inbuilt commands of SQL.


USE database_name;

Example 1:

The user wants to works on the databases named “GEEKS”. So the user will write:

USE candy;

Example 2:

Before using any database using the use command, it’s necessary to first create it. In order to create a database in SQL, the following command is used. Here, we create a database named “GFG1”:


Now, after the user has created a database named candy, we can use this database to perform the database operations. So, for that, the user has to type the USE command as follows:


After performing desired operations on the database, if we do not want the database, We can drop the database using the DROP command:


Remember, once a database is dropped, it’s removed permanently from the list of available databases, there is no way to retrieve the data of the table or the complete database in any possible way.

After using the drop command, if the user types –


The SQL database will throw an error as the GFG1 database has been removed permanently from the database using the drop command. 

Attention reader! All those who say programming isn’t for kids, just haven’t met the right mentors yet. Join the  Demo Class for First Step to Coding Coursespecifically designed for students of class 8 to 12. 

The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.

My Personal Notes arrow_drop_up
Recommended Articles
Page :