Javatpoint Logo
Javatpoint Logo

SQL SELECT Database

Suppose database users and administrators want to perform some operations on tables, views, and indexes on the specific existing database in SQL. Firstly, they have to select the database on which they want to run the database queries.

Any database user and administrator can easily select the particular database from the current database server using the USE statement in SQL.

Syntax of USE statement in SQL

In this syntax, we have to define the name of the database after the USE keyword and the name of the database must be unique.

Syntax of USE statement in MySQL

Syntax of USE statement in Oracle

There is no need to select the database in Oracle.

Examples of USE statement in SQL

In this article, we have taken the following three examples which will help you how to run and perform USE statement in SQL:

Example 1: Suppose, you want to work with the Hospital database. For this firstly, you have to check that if the Hospital database exists on the current database server or not by using the following query:

If the Hospital database is shown in the output, then you have to execute the following query to select the Hospital database:

Example 2: Suppose, you want to work with another College database in SQL. For this firstly, you have to check that the College database exists on the current database server or not by using the following query:

If the College database is shown in the result, then you have to execute the following query to select the College database:

Example 3: Suppose you want to work with another School database in SQL. For this firstly, you have to check that the School database exists on the current database server or not by using the following query:

If the School database is shown in the result, then you have to execute the following query to select the School database:


Next TopicSql TABLE





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA