Skip to main content

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     |
+------------+