1.VERSION()
用法:返回MySQL服务器的版本
举例:
mysql> select VERSION(); +-----------+ | VERSION() | +-----------+ | 5.6.10 | +-----------+ 1 row in set (0.00 sec)
2.USER(),SYSTEM_USER()
用法:返回当前登录用户名
举例:
mysql> select USER(); +----------------+ | USER() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec) mysql> select SYSTEM_USER(); +----------------+ | SYSTEM_USER() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec)
3.DATABASE()
用法:返回当前数据库名
举例:
mysql> select DATABASE(); +------------+ | DATABASE() | +------------+ | test | +------------+ 1 row in set (0.00 sec)
4.FOUND_ROWS()
用法:将最后一个SELECT查询(没有以LIMIT语句进行限制)返回的记录行数返回
举例:
mysql> select FOUND_ROWS(); +--------------+ | FOUND_ROWS() | +--------------+ | 1 | +--------------+ 1 row in set (0.00 sec)
5.LAST_INSERT_ID()
用法:返回由系统自动产生的最后一个AUTOINCREMENT ID的值(多条记录同时插入时返回的是第一条的记录的插入的ID)
举例:
mysql> select LAST_INSERT_ID(); +------------------+ | LAST_INSERT_ID() | +------------------+ | 0 | +------------------+ 1 row in set (0.02 sec)
6.CONNECTION_ID()
用法:返回当前客户的连接ID
举例:
mysql> select CONNECTION_ID(); +-----------------+ | CONNECTION_ID() | +-----------------+ | 1 | +-----------------+ 1 row in set (0.00 sec)
7.CHARSET(str)
用法;返回字符串str的字符集
举例:
mysql> select CHARSET(‘MYSQL‘); +------------------+ | CHARSET(‘MYSQL‘) | +------------------+ | utf8 | +------------------+ 1 row in set (0.04 sec)
时间: 2024-09-30 10:22:41