SQL SELECT Database

The SQL SELECT DATABASE statement is used to select a database for use. Once selected, you can perform various operations such as creating tables, querying data, or modifying the structure of the selected database.

Syntax: SELECT DATABASE();

This command is commonly used to confirm which database is currently in use or to display the name of the database selected in the current session.

Code Example


SELECT DATABASE();
            

Output

SchoolDB

The SELECT DATABASE() statement returns the name of the currently selected database. This can be helpful in verifying the active database in your session.

Important Notes:
- You must have an active connection to the database server to execute this statement.
- The USE command is typically used to select a specific database for use in queries, making it the more common approach in SQL.