ID EN
Information Functions

DATABASE()

MySQL 8.4

Returns the default (current) database name as a string in the utf8mb3 character set. If there is no default database, DATABASE() returns NULL. Within a stored routine, the default database is the database that the routine is associated with, which is not necessarily the same as the database that is the default in the calling context.

Syntax

MYSQL
SELECT DATABASE();
'test'

Examples

Example

If there is no default database, DATABASE() returns NULL.

MYSQL
SELECT DATABASE();
'test'