Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query optimization, and usability that you won’t want to miss.

DATABASE

Returns the name of the currently selected database. If no database is selected, then this function returns NULL.

Syntax

DATABASE()

Return Type

String.

Example

SELECT DATABASE();
****
+------------+
| DATABASE() |
+------------+
| NULL       |
+------------+
USE trades;

SELECT DATABASE();
****
+------------+
| DATABASE() |
+------------+
| trades     |
+------------+