hopeless-dream

导航

MySQL内置函数-版本、用户等函数

查看版本信息

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.18    |
+-----------+
1 row in set (0.00 sec)

查看当前数据库

mysql> select database();
+------------+
| database() |
+------------+
| world      |
+------------+
1 row in set (0.00 sec)

查看当前用户

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

查看uuid

UUID一共五部分:

  • 前三部分是根据时间戳生成的
  • 第四部分是保留时间的唯一性
  • 第五部分是根据网卡生成的
mysql> select uuid();
+--------------------------------------+
| uuid()                               |
+--------------------------------------+
| ac8a84eb-aacc-11ea-b4fc-000c295e277d |
+--------------------------------------+
1 row in set (0.00 sec)

 类型转换函数cast()

cast 可以把一个值转化为指定的数据类型。类型有:BINARY , CHAR , DATE , TIME , DATETIME , SIGNED , UNSIGNED 

mysql> SELECT CAST(NOW() AS SIGNED INTEGER ),CURDATE()+0;
+--------------------------------+-------------+
| CAST(NOW() AS SIGNED INTEGER ) | CURDATE()+0 |
+--------------------------------+-------------+
|                 20200610031903 |    20200610 |
+--------------------------------+-------------+
1 row in set (0.00 sec)

 

 

posted on 2020-06-10 11:55  hopeless-dream  阅读(495)  评论(0编辑  收藏  举报