您的位置:首页 > 数据库 > MySQL

mysql系统信息函数之database,user,connection_id用法

2018-03-08 11:37 453 查看

语法

DATABASE()

Returns the default (current) database name as a string in the utf8 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.

以utf8字符集中的字符串形式返回默认(当前)数据库名称。 如果没有默认数据库,则DATABASE()返回NULL。 在存储例程中,默认数据库是例程所关联的数据库,它不一定与调用上下文中默认的数据库相同。

USER()

Returns the current MySQL user name and host name as a string in the utf8 character set.

以utf8字符集中的字符串形式返回当前的MySQL用户名和主机名。

CONNECTION_ID()

Returns the connection ID (thread ID) for the connection. Every connection has an ID that is unique among the set of currently connected clients.

The value returned by CONNECTION_ID() is the same type of value as displayed in the ID column of the INFORMATION_SCHEMA.PROCESSLIST table, the Id column of SHOW PROCESSLIST output, and the PROCESSLIST_ID column of the Performance Schema threads table.

返回连接的连接标识(线程标识)。 每个连接都有一组在当前连接的客户端中唯一的ID。

CONNECTION_ID()返回的值与INFORMATION_SCHEMA.PROCESSLIST表的ID列,SHOW PROCESSLIST输出的Id列和Performance Schema线程表的PROCESSLIST_ID列中显示的值类型相同。

实例

SELECT database();        # test
SELECT user();            # root@localhost
SELECT connection_id();   # 10
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: