SQL - SELECT Database, USE Statement


Advertisements

When you have multiple databases in your SQL Schema, then before starting your operation, you would need to select a database where all the operations would be performed.

The SQL USE statement is used to select any existing database in the SQL schema.

Syntax

The basic syntax of the USE statement is as shown below −

USE DatabaseName;

Always the database name should be unique within the RDBMS.

Example

You can check the available databases as shown below −

SQL> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| AMROOD             |
| TUTORIALSPOINT     |
| mysql              |
| orig               |
| test               |
+--------------------+
6 rows in set (0.00 sec)

Now, if you want to work with the AMROOD database, then you can execute the following SQL command and start working with the AMROOD database.

SQL> USE AMROOD;

Useful Video Courses


Video

Oracle SQL Online Training

42 Lectures 5 hours

Anadi Sharma

Video

Oracle PL/SQL Online Training

14 Lectures 2 hours

Anadi Sharma

Video

T-SQL Online Training

44 Lectures 4.5 hours

Anadi Sharma

Video

SQL Masterclass: SQL for Data Analytics

94 Lectures 7 hours

Abhishek And Pukhraj

Video

Learn Database Design with MySQL

31 Lectures 6 hours

Eduonix Learning Solutions

Advertisements