Skip to main content

database

Description

Returns the name of the current database. If no database is selected, an empty value is returned.

Syntax

database()

Parameters

This function does not require parameters.

Return value

Returns the name of the current database as a string.

Examples

-- Select a destination database.
use db_test

-- Query the name of the current database.
select database();
+------------+
| DATABASE() |
+------------+
| db_test |
+------------+

See also

USE: Switches to a destination database.