MySQL Tutorial MySQL Advanced MySQL Database Account Management MySQL References

MySQL DATABASE() Function



The MySQL DATABASE() function returns the name of the current (default) database. This function uses the UTF8 character set. It returns NULL, if there is no default database.

Syntax

DATABASE()

Parameters

No parameter is required.

Return Value

Returns the name of the current (default) database.

Example:

The example below shows the usage of DATABASE() function.

mysql> SELECT DATABASE();

The above query will return name of the current (default) database. If the current (default) database is SQLExample, the above query will return the string 'SQLExample'.

mysql> SELECT DATABASE();
Result: 'SQLExample'

❮ MySQL Functions