当前位置:网站首页>MySQL function
MySQL function
2022-07-26 09:55:00 【My talented girlfriend】
Number function
- abs() Absolute value function
- ceil ceiling The smallest integer greater than or equal to the value
- floor The largest integer less than or equal to the value
- least Return the smallest value in the parameter
- greatest Return the maximum value of the list
- radians Angle in radians
- degrees The angle of arc
- sin / asin Sine function / Antisinusoidal function The parameter is radian
- cos / acos cosine / Arccosine
- tan / atan tangent / Anyway
- atan2(m,n) Returns the arctangent of two parameters
- cot Cotangent
- pow / power chengfang
- exp e Of x Power
- sqrt The square root of the parameter
- ln / log e At the bottom of the x The logarithmic
- log10 10 Logarithm of the parameter with the base
- log2 2 Logarithm of the parameter with the base
- rand Random return 0 To 1 Random number between
- rand(x) The parameters are consistent, and the random numbers returned are the same
- round Rounded integer
- round(x,y) y Indicates the number of decimal places reserved
- truncate(x,y) y Indicates that the reserved digits are relative to the decimal digits
- sign Symbolic function , A positive number returns 1, otherwise 0
- div except
- mod Returns the remainder
String function
- ascii Returns the first of the parameters ascii Code value
- char_length Return the number of characters of the parameter
- length Returns the length of the parameter
- concat Return a character with parameters , One of them is NULL, return NULL
- concat_ws Returns the combined character divided by the first parameter , If the first parameter is NULL, Then return to null, Other parameters are null It ignores
- insert(oldstr,x,y,replacestr) character oldstr From the x Location y Characters with a length of characters are replaced by replacestr
- lower / upper Case conversion
- left(str,x) / right(str,x) Returns a specific number of left and right characters
- lpad(str,n,pstr) / rpad(str,n,pstr) The string str Fill left and right until the length reaches n
- ltrim / rtrim / trim Remove the left and right spaces of characters
- trim(substr from str) Remove str Left and right substr
- repeat(str,x) repeat str character x Time
- replace(s,a,b) use b Replace in s Medium a
- strcmp(s1,s2) Compare s1 and s2 Of ascii Code value size of , return -1、0 and 1
- substr(s,x,y) / substring(s,x,y) / mid(s,x,y) Want to be with crop characters s from x The position begins y Characters
- space Return the space character of the parameter space
- locate(substr, str) / position(substr, str) / instr(substr, str) Return string substr stay str The location of
- elt(m,s1,s2…) return m Value corresponds to the position of the following character
- field(s,s1,s2…) Returns that the first parameter appears in the following character list
- find_in_set(s1,s2) return s1 In the character s2 Where in
- reverse return s String with opposite characters
- nullif(s1,s2) If s1 and s2 equal , Then return to null, Otherwise return to s1
Date and time functions
utc It refers to the world coordinated time
- curdate The current date , The format is YYYY-MM-DD
- curtime Current event , The format is HH:MM:SS
- now Current time and date , The format is YYYY-MM-DD HH:MM:SS
- unix_timestamp Convert parameter date to unix Time stamp
- from_unixtime The parameter unix Timestamp to date
- utc_date return utc date
- utc_time return utc Time
- year month Return the year of the date of the parameter 、 month
- monthname Return the English name of the month on which the parameter is located
- day Return the date of the parameter
- dayofweek Returns the number of days in the week corresponding to the number of days in the parameter
- weekday Return the index value of the number of days in the week corresponding to the number of days in the parameter ,0 It corresponds to mid Monday
- week The current date corresponds to the week of the year
- weekofyear The current date corresponds to the week of the year
- dayofyear Corresponding to the number of days in a year
- dayofmonth Corresponding to the number of days in the month
- quarter Current season
- hour minute second The hour corresponding to the parameter 、 Minutes and seconds
- extract(type from date) Return a specific part from the date
- time_to_sec take time Into seconds
- sec_to_time Convert seconds into time
- date_add(date interval expr type) / date_sub(date interval expr type) Date addition and subtraction
- addtime / subtime Add and subtract dates , The second parameter is seconds
- datediff The number of days to calculate the difference between dates
- from_days() from 0000 year 1 month 1 The day after the day parameter
- last_day The last day of the current month
- makedate / maketime Combine time and date
- period_add(time.n) Time plus n after
- to_days() distance 0000 year 1 month 1 Day to parameter day
- date_format(date, format) / time_format(date, format) In the specified format format date
- get_format(date_type, format_type) Return date string format
- str_to_date(str, format) return str according to format Date or time of format conversion
Process handler
- if(v1,v2,v3) If v1 by true, return v2, Otherwise return to v3
- ifnull(v1,v2) If v1 Not for null, return v1, Otherwise return to v2
- case when codition then
- case v1 when v2 then
Encryption and decryption functions
- password encryption
- md5 Yes value Conduct md5 encryption
- encode / decode Use the corresponding values for encryption and decryption
Aggregate functions
- count Count
- max Maximum
- min Minimum
- sum Sum up
- avg Ball average
obtain mysql Information functions
- version Version number
- datebase The database where the current command is located
- user The current user
- last_insert_id The latest value of self increment
- charset(value) mysql Character set
- collation(value) String sorting
Locking and unlocking function
- get_lock(v1,timeout) obtain v1 Lock of , continued timeout
- release_lock Unlock
- is_ferr_lock Judge whether the differential lock can be used
- is_used_lock Determine whether the differential lock is in use
JSON function
- json_contains Inquire about json Whether to include a specific value
- json_search stay json Field specified key In looking for value
- json_pretty Display in an elegant format json
- json_depth Inquire about json The depth of the
- json_length json Length of data
- json_keys return json Data top key Composed of json data
- json_insert stay json Insert data
- json_remove remove json It is specified in key Value
- json_replace to update json It is specified in key Value
- json_set towards json Insert data
- json_type For return json Type of data
- json_valid Judge value Is it effective json data
Window function
- row_number Order
- rank Sort side by side , Through repeated serial numbers
- dense_rank Sort side by side
- percent_rank Grade percentage
- cume_dist Cumulative distribution value
- lag(expr, n) Returns the top of the current line n Yes expr Value
- lead(expr, n) After returning the current line n Yes expr Value
- first_value(expr) /last_value Return to the first or last expr Value
- nth_value(expr,n) Back to page n individual expr Value
- ntile Divide the partitioned ordered data into n A barrel , Record the bucket number
Other functions
format(value,n) rounding ,n For decimal places
conv(value, from, to) Binary conversion
inet_aton take ip Convert to number
inet_ntoa Convert numbers to ip Address
benchmark test mysql Time spent processing parameters
cast take value Turn into type type
convert take value The character encoding used is converted to char_code
边栏推荐
- 【信息系统项目管理师】初见高项系列精华汇总
- Encapsulation of tabbarcontroller
- Write a script that can run in Bash / shell and PowerShell
- 服务发现原理分析与源码解读
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- js 表格自动循环滚动,鼠标移入暂停
- Interview shock 68: why does TCP need three handshakes?
- Draw arrows with openlayer
- Customize permission validation in blazor
- 开发转测试:从0开始的6年自动化之路...
猜你喜欢

新增市场竞争激烈,中国移动被迫推出限制性超低价5G套餐

Production of a-modal drag function in antui

The problem of accessing certsrv after configuring ADCs

Solve NPM -v sudden failure and no response

Search module use case writing

Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration

Development to testing: a six-year road to automation starting from 0

Gauss elimination

Fiddler download and installation

R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)
随机推荐
Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
云原生(三十六) | Kubernetes篇之Harbor入门和安装
面试突击68:为什么 TCP 需要 3 次握手?
Mo team learning summary (II)
2022年中科磐云——服务器内部信息获取 解析flag
(1) Hand eye calibration of face scanner and manipulator (eye on hand)
E. Two Small Strings
Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
Node memory overflow and V8 garbage collection mechanism
莫队学习笔记(一)
Interview shock 68: why does TCP need three handshakes?
面试突击68:为什么 TCP 需要 3 次握手?
在Blazor 中自定义权限验证
Keeping alive to realize MySQL automatic failover
E. Two Small Strings
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
Basic knowledge of website design
PHP executes shell script
Network flow learning notes
新公链Aptos何以拉满市场期待值?