DATABASE() - Name of Current Database

Q

How to obtain the name of the current database using the DATABASE() function?

✍: FYIcenter.com

A

DATABASE() is a MySQL built-in function that returns the name of the current database. For example:

USE mysql;
Database changed

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

Reference information of the DATABASE() function:

DATABASE(): name
  Returns the name of the current database.

Arguments, return value and availability:
  name: Return value. The name of the current database.
  Available since MySQL 4.0.

 

FOUND_ROWS() - Row Count from Last SELECT Statement

CURRENT_USER() - Authentication Name of Current User

MySQL Functions on System Information

⇑⇑ MySQL Function References

2023-12-18, 796🔥, 0💬