本篇內(nèi)容主要講解“MySQL5.6中常用的函數(shù)用法介紹”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“MySQL5.6中常用的函數(shù)用法介紹”吧!
成都創(chuàng)新互聯(lián)公司專業(yè)IDC數(shù)據(jù)服務(wù)器托管提供商,專業(yè)提供成都服務(wù)器托管,服務(wù)器租用,四川電信科技城機(jī)房,四川電信科技城機(jī)房,成都多線服務(wù)器托管等服務(wù)器托管服務(wù)。
常用的函數(shù)有:
1. 字符串函數(shù);主要用于處理字符串。
2. 數(shù)值函數(shù);主要用于處理數(shù)字。
3. 日期和時(shí)間函數(shù);主要用于處理日期和事件。
4. 系統(tǒng)信息函數(shù);獲取系統(tǒng)信息。
1. 使用字符串函數(shù):
1.1 合并字符串函數(shù)concat() 和 concat_ws():
concat(s1, s2,...sn)
//該函數(shù)會(huì)將傳入的參數(shù)連接起來(lái)返回合并的字符串類型的數(shù)據(jù)。如果其中一個(gè)參數(shù)為null,則返回值為null.
例子:
mysql> select concat('my','s','ql');
+-----------------------+
| concat('my','s','ql') |
+-----------------------+
| mysql |
+-----------------------+
1 row in set (0.00 sec)
mysql> select concat('my','s','ql',null);
+----------------------------+
| concat('my','s','ql',null) |:
+----------------------------+
| NULL |
+----------------------------+
1 row in set (0.00 sec)
mysql> select concat(curdate(), 12.2);
+-------------------------+
| concat(curdate(), 12.2) |
+-------------------------+
| 2017-03-1712.2 |
+-------------------------+
1 row in set (0.00 sec)
concat_ws()的定義:
concat_ws(sep,s1,s2,...sn)
//該函數(shù)與concat()相比,多了一個(gè)表示分隔符的seq參數(shù),不僅將傳入的其他參數(shù)連接起來(lái),而且還會(huì)通過(guò)分隔符將各個(gè)字符串分割開來(lái)。
//分隔符可以是一個(gè)字符串,也可以是其他參數(shù)。如果分割符為null,則返回結(jié)果為null。函數(shù)會(huì)忽略任何分割符后的參數(shù)null.
例子:
mysql> select concat_ws('-','010','87658907');
+---------------------------------+
| concat_ws('-','010','87658907') |
+---------------------------------+
| 010-87658907 |
+---------------------------------+
1 row in set (0.02 sec)
mysql> select concat_ws(null,'010','87658907');
+----------------------------------+
| concat_ws(null,'010','87658907') |
+----------------------------------+
| NULL |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select concat_ws('-','010',null,'87658907');
+--------------------------------------+
| concat_ws('-','010',null,'87658907') |
+--------------------------------------+
| 010-87658907 |
+--------------------------------------+
1 row in set (0.00 sec)
1.2 比較字符串大小函數(shù)strcmp():
strcmp()定義為:
strcmp(str1,str2);
//如果參數(shù)str1大于str2,返回1;如果str1小于str2,則返回-1;如果str1等于str2,則返回0;
例子:
mysql> select strcmp('abc','abd'),strcmp('abc','abc'),strcmp('abc','abb');
+---------------------+---------------------+---------------------+
| strcmp('abc','abd') | strcmp('abc','abc') | strcmp('abc','abb') |
+---------------------+---------------------+---------------------+
| -1 | 0 | 1 |
+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
1.3 獲取字符串長(zhǎng)度函數(shù)length()和字符數(shù)函數(shù)char_length():
length()的定義如下:
length(str)
char_length(str)的定義如下:
char_length(str)
例子:
mysql> select length('mysql'),length('中國(guó)'),char_length('mysql'),char_length('中國(guó)');
+-----------------+------------------+----------------------+-----------------------+
| length('mysql') | length('漢字') | char_length('mysql') | char_length('中國(guó)') |
+-----------------+------------------+----------------------+-----------------------+
| 5 | 6 | 5 | 2 |
+-----------------+------------------+----------------------+-----------------------+
1 row in set (0.00 sec)
//字符串‘MySQL'共有5個(gè)字符,但是占6個(gè)字節(jié)空間。這是因?yàn)槊總€(gè)字符串都是以\0結(jié)束。兩個(gè)函數(shù)都是獲取字符串的字符數(shù)而不是所占空間大小。utf8(一個(gè)中文三個(gè)字節(jié)),所以兩個(gè)漢字占6個(gè)字節(jié)。
1.4 字母的大小寫轉(zhuǎn)換upper()和lower():
字母大寫轉(zhuǎn)換函數(shù):upper(s); ucase(s);
字母小寫轉(zhuǎn)換函數(shù):lower(s); lcase(s);
例子:
mysql> select upper('mysql'),ucase('mYsql'),lower('MYSQL'),lcase('MYsql');
+----------------+----------------+----------------+----------------+
| upper('mysql') | ucase('mYsql') | lower('MYSQL') | lcase('MYsql') |
+----------------+----------------+----------------+----------------+
| MYSQL | MYSQL | mysql | mysql |
+----------------+----------------+----------------+----------------+
1 row in set (0.00 sec)
1.5 查找字符串:
mysql中提供了豐富的函數(shù)去查找字符串的位置。分別有find_in_set()函數(shù)、field()函數(shù)、locate()函數(shù)、position()函數(shù)和instr()函數(shù)。同時(shí)還提供了查找指定位置的字符串的函數(shù)elt()。
1.5.1 返回字符串位置的find_in_set()函數(shù):
函數(shù)定義為:
find_in_set(str1,str2)
//會(huì)返回在字符串str2中與str1相匹配的字符串的位置,參數(shù)str2字符串中將包含若干個(gè)用逗號(hào)隔開的字符串。
例子:
mysql> select find_in_set('mysql','oracle,db2,mysql');
+-----------------------------------------+
| find_in_set('mysql','oracle,db2,mysql') |
+-----------------------------------------+
| 3 |
+-----------------------------------------+
1 row in set (0.00 sec)
1.5.2 返回指定字符串位置的field()函數(shù):
函數(shù)定義為:
filed(str,str1,str2...)
//返回第一個(gè)與字符串str匹配的字符串的位置。
例子:
mysql> select field('mysql','oracle','db2','redis','mysql');
+-----------------------------------------------+
| field('mysql','oracle','db2','redis','mysql') |
+-----------------------------------------------+
| 4 |
+-----------------------------------------------+
1 row in set (0.00 sec)
1.5.3 返回子字符串相匹配的開始位置:
mysql中有三個(gè)函數(shù)可以獲取子字符串相匹配的開始位置,分別是locate()、position()、instr()函數(shù)。
locate(str1,str) //返回參數(shù)str中字符串str1的開始位置
position(str1 in str) 和 instr(str,str1)
例子:
mysql> select locate('sql','mysql'),position('sql' in 'mysql'),instr('mysql','sql');
+-----------------------+----------------------------+----------------------+
| locate('sql','mysql') | position('sql' in 'mysql') | instr('mysql','sql') |
+-----------------------+----------------------------+----------------------+
| 3 | 3 | 3 |
+-----------------------+----------------------------+----------------------+
1 row in set (0.00 sec)
1.5.4 返回指定位置的字符串的elt()函數(shù):
函數(shù)語(yǔ)法為:
elt(n,str1,str2...);
例子:
mysql> select elt(2,'db2','mysql','oracle');
+-------------------------------+
| elt(2,'db2','mysql','oracle') |
+-------------------------------+
| mysql |
+-------------------------------+
1 row in set (0.00 sec)
1.5.5 選擇字符串的make_set()函數(shù):
函數(shù)定義為:
make_set(num,str1,str2...strn)
例子:
mysql> select bin(5),make_set(5,'mysql','db2','oracle','redus');
+--------+--------------------------------------------+
| bin(5) | make_set(5,'mysql','db2','oracle','redus') |
+--------+--------------------------------------------+
| 101 | mysql,oracle |
+--------+--------------------------------------------+
1 row in set (0.00 sec)
//make_set()首先會(huì)將數(shù)值num轉(zhuǎn)換成二進(jìn)制數(shù),然后按照二進(jìn)制從參數(shù)str1,str2,...,strn中選取相應(yīng)的字符串。再通過(guò)二進(jìn)制從右到左的順序讀取該值,如果值為1選擇該字符串,否則將不選擇該字符串。
1.6 從現(xiàn)有字符串中截取子字符串:
截取子字符串的函數(shù)有:left(),right(),substring(),mid();
1.6.1 從左邊或右邊截取子字符串:
函數(shù)定義為:
left(str,num)
//返回字符串str中包含前num個(gè)字母(從左邊數(shù))的字符串。
right(str,num)
//返回字符串str中包含后num個(gè)字母(從右邊數(shù))的字符串。
例子:
mysql> select left('mysql',2),right('mysql',3);
+-----------------+------------------+
| left('mysql',2) | right('mysql',3) |
+-----------------+------------------+
| my | sql |
+-----------------+------------------+
1 row in set (0.01 sec)
1.6.2 截取指定位置和長(zhǎng)度的字符串:
可以通過(guò)substring()和mid()函數(shù)截取指定位置和長(zhǎng)度的字符串。
函數(shù)語(yǔ)法為:
substring(str,num,len) //返回字符串str中的第num個(gè)位置開始長(zhǎng)度為len的子字符串。
mid(str,num,len)
例子:
mysql> select substring('duansf',1,4),mid('duansf',5,6);
+-------------------------+-------------------+
| substring('duansf',1,4) | mid('duansf',5,6) |
+-------------------------+-------------------+
| duan | sf |
+-------------------------+-------------------+
1 row in set (0.00 sec)
1.7 去除字符串的首尾空格:
去除字符串首尾空格的函數(shù)有:ltrim()、rtrim()、trim()
1.7.1 去除字符串開始處的空格:
函數(shù)定義如下:
ltrim(str) //返回去掉開始處空格的字符串
例子:
mysql> select length(concat('-',' mysql ','-')),length(concat('-',ltrim(' mysql '),'-'));
+-----------------------------------+------------------------------------------+
| length(concat('-',' mysql ','-')) | length(concat('-',ltrim(' mysql '),'-')) |
+-----------------------------------+------------------------------------------+
| 9 | 8 |
+-----------------------------------+------------------------------------------+
1 row in set (0.00 sec)
1.7.2 去除字符串結(jié)束處的空格:
rtrim(str) //返回去掉結(jié)束處空格的字符串。
例子:
mysql> select length(concat('-',' mysql ','-')) ,length(concat('-',rtrim(' mysql '),'-'));
+-----------------------------------+------------------------------------------+
| length(concat('-',' mysql ','-')) | length(concat('-',rtrim(' mysql '),'-')) |
+-----------------------------------+------------------------------------------+
| 9 | 8 |
+-----------------------------------+------------------------------------------+
1 row in set (0.00 sec)
1.7.3 去除字符串首尾空格:
trim(str) //返回去掉首尾空格的字符串
例子:
mysql> select concat(' mysql ') origi,length(concat(' mysql ')) orilen, concat(trim(' mysql ')) after, length(concat(trim(' mysql '))) afterlen;
+---------+--------+-------+----------+
| origi | orilen | after | afterlen |
+---------+--------+-------+----------+
| mysql | 7 | mysql | 5 |
+---------+--------+-------+----------+
1 row in set (0.00 sec)
1.8 替換字符串:
實(shí)現(xiàn)替換字符串的功能,分別為insert()和replace()
1.8.1 使用insert()函數(shù):
函數(shù)定義為:
insert(str,pos,len,newstr)
//insert()函數(shù)會(huì)將字符串str中的pos位置開始長(zhǎng)度為len的字符串用字符串newstr來(lái)替換。
//如果參數(shù)pos的值超過(guò)字符串長(zhǎng)度,則返回值為原始字符串str。
//如果len的長(zhǎng)度大于原來(lái)str中所剩字符串的長(zhǎng)度,則從位置pos開始進(jìn)行全部替換。若任何一個(gè)參數(shù)為null,則返回值為null.
例子:
mysql> select insert('這是mysql數(shù)據(jù)庫(kù)系統(tǒng)',3,5,'oracle') bieming;
+-----------------------------+
| bieming |
+-----------------------------+
| 這是oracle數(shù)據(jù)庫(kù)系統(tǒng) |
+-----------------------------+
1 row in set (0.00 sec)
1.8.1 使用replace()函數(shù):
函數(shù)的定義為:
replace(str,substr,newstr) //將字符串str中的子字符串substr用字符串newstr來(lái)替換。
例子:
mysql> select replace('這是db2數(shù)據(jù)庫(kù)','db2','mysql') bieming;
+----------------------+
| bieming |
+----------------------+
| 這是mysql數(shù)據(jù)庫(kù) |
+----------------------+
1 row in set (0.00 sec)
2. 使用數(shù)值函數(shù):
2.1 獲取隨機(jī)數(shù):
通過(guò)rand()和rand(x)函數(shù)來(lái)獲取隨機(jī)數(shù)。這兩個(gè)函數(shù)都會(huì)返回0-1之間的隨機(jī)數(shù),其中rand()函數(shù)返回的數(shù)是完全隨機(jī)的,而rand(x)函數(shù)返回的隨機(jī)數(shù)值是完全相同的。
例子:
mysql> select rand(),rand(),rand(2),rand(2);
+--------------------+--------------------+--------------------+--------------------+
| rand() | rand() | rand(2) | rand(2) |
+--------------------+--------------------+--------------------+--------------------+
| 0.6218820266629402 | 0.4098255535679176 | 0.6555866465490187 | 0.6555866465490187 |
+--------------------+--------------------+--------------------+--------------------+
1 row in set (0.00 sec)
2.2 獲取整數(shù)的函數(shù):
在具體應(yīng)用中,如果想要獲取整數(shù),可以通過(guò)ceil()和floor()函數(shù)來(lái)實(shí)現(xiàn)。
ceil()函數(shù)的定義為:
ceil(x) //函數(shù)返回大于或等于數(shù)值x的最小整數(shù)。
floor() //函數(shù)返回小于或等于數(shù)值x的最大整數(shù)。
例子:
mysql> select ceil(4.3),ceil(-2.4),floor(4.3),floor(-2.4);
+-----------+------------+------------+-------------+
| ceil(4.3) | ceil(-2.4) | floor(4.3) | floor(-2.4) |
+-----------+------------+------------+-------------+
| 5 | -2 | 4 | -3 |
+-----------+------------+------------+-------------+
1 row in set (0.00 sec)
2.3 截取數(shù)值函數(shù):
可以通過(guò)truncate()對(duì)數(shù)值的小數(shù)位進(jìn)行截?。?br/>函數(shù)定義為:
truncate(x,y) //返回?cái)?shù)值x,保留小數(shù)點(diǎn)后y位
例子:
mysql> select truncate(903.342434,2),truncate(903.342,-1);
+------------------------+----------------------+
| truncate(903.342434,2) | truncate(903.342,-1) |
+------------------------+----------------------+
| 903.34 | 900 |
+------------------------+----------------------+
1 row in set (0.00 sec)
2.4 四舍五入函數(shù):
對(duì)數(shù)值進(jìn)行四舍五入可以通過(guò)round()函數(shù)實(shí)現(xiàn):
round(x)
//函數(shù)返回值x經(jīng)過(guò)四舍五入操作后的數(shù)值。
round(x,y)
//返回?cái)?shù)值x保留到小數(shù)點(diǎn)后y位的值。在具體截取數(shù)據(jù)時(shí)需要進(jìn)行四舍五入的操作。
例子:
mysql> select round(902.53567),round(-902.53567),round(902.53567,2),round(902.53567,-1);
+------------------+-------------------+--------------------+---------------------+
| round(902.53567) | round(-902.53567) | round(902.53567,2) | round(902.53567,-1) |
+------------------+-------------------+--------------------+---------------------+
| 903 | -903 | 902.54 | 900 |
+------------------+-------------------+--------------------+---------------------+
1 row in set (0.02 sec)
3. 使用日期和時(shí)間函數(shù):
3.1 獲取當(dāng)前日期和時(shí)間的函數(shù):
3.1.1 獲取當(dāng)前日期和時(shí)間(日期 + 時(shí)間):
MySQL中可以通過(guò)四個(gè)函數(shù)獲取當(dāng)前日期和時(shí)間,分別是now(),current_timestamp(),localtime(),sysdate(),這四個(gè)函數(shù)不僅可以獲取當(dāng)前日期和時(shí)間,而且顯示的格式也一樣。推薦使用now()
例子:
mysql> select now(),current_timestamp(),localtime(),sysdate();
+---------------------+---------------------+---------------------+---------------------+
| now() | current_timestamp() | localtime() | sysdate() |
+---------------------+---------------------+---------------------+---------------------+
| 2017-03-17 15:52:24 | 2017-03-17 15:52:24 | 2017-03-17 15:52:24 | 2017-03-17 15:52:24 |
+---------------------+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
3.1.2 獲取當(dāng)前日期:
獲取當(dāng)前日期的函數(shù)curdate()和current_date()函數(shù)。
例子:
mysql> select curdate(),current_date();
+------------+----------------+
| curdate() | current_date() |
+------------+----------------+
| 2017-03-17 | 2017-03-17 |
+------------+----------------+
1 row in set (0.00 sec)
3.1.3 獲取當(dāng)前時(shí)間:
獲取當(dāng)前時(shí)間的函數(shù),curtime()或者current_time();推薦使用curtime();
例子:
mysql> select curtime(),current_time();
+-----------+----------------+
| curtime() | current_time() |
+-----------+----------------+
| 15:53:32 | 15:53:32 |
+-----------+----------------+
1 row in set (0.00 sec)
3.2 獲取日期和時(shí)間各部分值:
在MySQL中,可以通過(guò)各種函數(shù)來(lái)獲取當(dāng)前日期和時(shí)間的各部分值,其中year()函數(shù)返回日期中的年份,quarter()函數(shù)返回日期屬于第幾個(gè)季度,month()函數(shù)返回日期屬于第幾個(gè)月,week()函數(shù)返回日期屬于第幾個(gè)星期,dayofmonth()函數(shù)返回日期屬于當(dāng)前月的第幾天,hour()函數(shù)返回時(shí)間的小時(shí),minute()函數(shù)返回時(shí)間的分鐘,second()函數(shù)返回時(shí)間的秒。
例子:
mysql> select now(),year(now()),quarter(now()),month(now()),week(now()),dayofmonth(now()),hour(now()),minute(now()),second(now());
+---------------------+-------------+----------------+--------------+-------------+-------------------+-------------+---------------+---------------+
| now() | year(now()) | quarter(now()) | month(now()) | week(now()) | dayofmonth(now()) | hour(now()) | minute(now()) | second(now()) |
+---------------------+-------------+----------------+--------------+-------------+-------------------+-------------+---------------+---------------+
| 2017-03-17 15:54:07 | 2017 | 1 | 3 | 11 | 17 | 15 | 54 | 7 |
+---------------------+-------------+----------------+--------------+-------------+-------------------+-------------+---------------+---------------+
1 row in set (0.00 sec)
3.2.1 關(guān)于月的函數(shù):
例子:
mysql> select now(),month(now()),monthname(now());
+---------------------+--------------+------------------+
| now() | month(now()) | monthname(now()) |
+---------------------+--------------+------------------+
| 2017-03-17 15:54:43 | 3 | March |
+---------------------+--------------+------------------+
1 row in set (0.03 sec)
3.2.2 關(guān)于星期的函數(shù):
例子:
mysql> select now(),week(now()),weekofyear(now()),dayname(now()),dayofweek(now()),weekday(now());
+---------------------+-------------+-------------------+----------------+------------------+----------------+
| now() | week(now()) | weekofyear(now()) | dayname(now()) | dayofweek(now()) | weekday(now()) |
+---------------------+-------------+-------------------+----------------+------------------+----------------+
| 2017-03-17 15:55:32 | 11 | 11 | Friday | 6 | 4 |
+---------------------+-------------+-------------------+----------------+------------------+----------------+
1 row in set (0.00 sec)
3.2.3 關(guān)于天的函數(shù):
例子:
mysql> select now(),dayofyear(now()),dayofmonth(now());
+---------------------+------------------+-------------------+
| now() | dayofyear(now()) | dayofmonth(now()) |
+---------------------+------------------+-------------------+
| 2017-03-17 15:56:12 | 76 | 17 |
+---------------------+------------------+-------------------+
1 row in set (0.00 sec)
3.2.4 獲取指定值的extract():
函數(shù)定義為:
extract(type from date)
//上述函數(shù)會(huì)從日期和時(shí)間參數(shù)date中獲取指定類型參數(shù)type的值。type的取值可以是:year,month,day,hour,minute和second
例子:
mysql> select now(),extract(year from now()) year,extract(month from now()) month,extract(day from now()) day,extract(hour from now()) hour,extract(minute from now()) minute,extract(second from now()) second;
+---------------------+------+-------+------+------+--------+--------+
| now() | year | month | day | hour | minute | second |
+---------------------+------+-------+------+------+--------+--------+
| 2017-03-17 15:57:26 | 2017 | 3 | 17 | 15 | 57 | 26 |
+---------------------+------+-------+------+------+--------+--------+
1 row in set (0.00 sec)
3.3 計(jì)算日期和時(shí)間的函數(shù):
3.3.1 與默認(rèn)日期和時(shí)間操作:
兩個(gè)函數(shù)來(lái)實(shí)現(xiàn)與默認(rèn)日期和時(shí)間的操作,分別為to_days()和from_days()
to_days(date):該函數(shù)計(jì)算日期參數(shù)date與默認(rèn)日期和時(shí)間(0000年1月1日)之間的想個(gè)天數(shù)。
from_days(number):該函數(shù)計(jì)算從默認(rèn)日期和時(shí)間(0000年1月1日)開始經(jīng)歷number天后的日期和時(shí)間。
例子:
mysql> select now(),to_days(now()),from_days(to_days(now()));
+---------------------+----------------+---------------------------+
| now() | to_days(now()) | from_days(to_days(now())) |
+---------------------+----------------+---------------------------+
| 2017-03-17 15:58:44 | 736770 | 2017-03-17 |
+---------------------+----------------+---------------------------+
1 row in set (0.00 sec)
3.3.2 與指定日期和時(shí)間操作:
adddate(date,n)函數(shù):該函數(shù)計(jì)算日期參數(shù)date加上n天后的日期。
subdate(date,n)函數(shù):該函數(shù)計(jì)算日期參數(shù)date減去n天后的日期。
adddate(d,interval expr type):返回日期參數(shù)d加上一段時(shí)間后的日期,表達(dá)式參數(shù)expr決定了時(shí)間的長(zhǎng)度,參數(shù)type決定了所操作的對(duì)象。
subdate(d,interval expr type):返回日期參數(shù)d減去一段時(shí)間后的日期,表達(dá)式expr決定了時(shí)間的長(zhǎng)度。參數(shù)type決定了所操作的對(duì)象。
addtime(time,n):計(jì)算時(shí)間參數(shù)time加上n秒后的時(shí)間。
subtime(time,n):計(jì)算時(shí)間參數(shù)time減去n秒后的時(shí)間。
例子一:
mysql> select curdate(),adddate(curdate(),5),subdate(curdate(),5);
+------------+----------------------+----------------------+
| curdate() | adddate(curdate(),5) | subdate(curdate(),5) |
+------------+----------------------+----------------------+
| 2017-03-17 | 2017-03-22 | 2017-03-12 |
+------------+----------------------+----------------------+
1 row in set (0.00 sec)
例子二:
mysql> select curdate(),adddate(curdate(),interval '2,3' year_month),subdate(curdate(),interval '2,3' year_month);
+------------+----------------------------------------------+----------------------------------------------+
| curdate() | adddate(curdate(),interval '2,3' year_month) | subdate(curdate(),interval '2,3' year_month) |
+------------+----------------------------------------------+----------------------------------------------+
| 2017-03-17 | 2019-06-17 | 2014-12-17 |
+------------+----------------------------------------------+----------------------------------------------+
1 row in set (0.00 sec)
例子三:
mysql> select curtime(),addtime(curtime(),5),subtime(curtime(),5);
+-----------+----------------------+----------------------+
| curtime() | addtime(curtime(),5) | subtime(curtime(),5) |
+-----------+----------------------+----------------------+
| 16:03:49 | 16:03:54 | 16:03:44 |
+-----------+----------------------+----------------------+
1 row in set (0.03 sec)
4. 使用系統(tǒng)信息函數(shù):
select version(),database(),user();
例子:
mysql> select version(),database(),user();
+------------+------------+----------------+
| version() | database() | user() |
+------------+------------+----------------+
| 5.6.27-log | mysql | mdba@localhost |
+------------+------------+----------------+
1 row in set (0.00 sec)
到此,相信大家對(duì)“MySQL5.6中常用的函數(shù)用法介紹”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!