MySQL 函式,不常用的

2021-10-04 22:07:46 字數 1672 閱讀 9680

select abs(-9

)-- 返回絕對值

select ceiling(

2.2)

-- 向上取整

select floor(

2.2)

-- 向上取整

select rand(

)-- 返回0-1隨機數

select sign(x)

-- 返回乙個數的正負,正返回1,負返回-1

select char_length(

'反恐精英之生死決奪'

)-- 返回乙個字串的長度

select concat(

'反恐精英'

,'拿著'

,'m4a4'

)-- 拼接字串

select

insert

('彩虹六號圍攻',1

,1,'反恐精英'

)-- 從哪個索引,後數幾個字元,並替換成新字元

select lower(

'csgo'

)-- 轉成小寫

select upper(

'csgo'

)-- 轉成大寫

select instr(

'csgo'

,'g'

)-- 返回第一次出現的子串位置(不是從0開始的,從1)

select

replace

('反恐精英'

,'恐'

,'kong'

)-- 替換字串,將第乙個引數的字串中第二個引數替換成第三個

select substr(

'刺客信條',1

,2)-- 從第幾個開始,擷取幾個字元

select reverse(

'看門狗2'

)-- 反轉字串

-- 時間日期函式

select

current_date()

-- 返回當前日期

select

current_date

-- 返回當前日期

select

current_time()

-- 返回當前時間

select

current_time

-- 返回當前時間

select

now(

)-- 返回當前年月日時分秒

select localtime(

)-- 返回本地時間

select sysdate(

)-- 返回系統時間

select

year

(now()

)-- 年

select

month

(now()

)-- 月

select

day(

now())

-- 日

select

hour

(now()

)-- 時

select

minute

(now()

)-- 分

select

second

(now()

)-- 秒

select

user()

-- 返回使用者

select version(

)-- 返回版本

hive不常用函式

計算天數差函式 在計算留存時,常會用到天數差函式datediff select datediff 2017 08 03 2017 08 02 結果為1 根據日期計算星期幾 有時會遇到根據日期計算星期幾的情況,實現的方法是和某乙個的固定的週日的日期做天數差,再對7取餘 select pmod date...

mysql命令不常用的引數

mysql e 這個引數是告訴mysql 我只要執行 e 後面的某個命令,而不是要通過mysql連線到mysql server上面,此引數在寫一些基本的mysql檢查和監控的指令碼中非常有用 mysql h,htlm 這個引數 select出來的結果都會按照html格式輸出,在某些場後下,比如希望用...

oracle 中不常用的單行函式

1 bfilename 該函式用於初始化bfile定位符 2 coalesce 用於獲得列表引數中第乙個不為null 的表示式 3 decode返回於特定匹配的表示式的結果 select empno 編號,empname as 姓名 sal,4 depth 用於返回xml方案中under path ...