Name

DATABASE( )

Synopsis

DATABASE( )

This function returns the name of the database currently in use for the session. There are no arguments. If no database has been set to default yet, it returns NULL; prior to Version 4.1.1 of MySQL, it returns an empty string.

SELECT DATABASE( );
+------------+
| DATABASE( ) |
+------------+
| bookstore  |
+------------+

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.