当前位置:网站首页>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
边栏推荐
- 【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛
- antd TreeSelect获取父节点的值
- 面试突击68:为什么 TCP 需要 3 次握手?
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- Applet record
- Learning notes: what are the common array APIs that change the original array or do not change the original array?
- Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
- 2019 ICPC Asia Yinchuan regional (water problem solution)
- WARNING: [pool www] server reached pm. max_ children setting (5), consider raising it
- R language ggpubr package ggsummarystats function visualizes the grouping box diagram (custom grouping color) and adds the statistical values corresponding to the grouping under the x-axis label (samp
猜你喜欢
Mysql5.7.25 master-slave replication (one-way)
Registration module use case writing
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
The diagram of user login verification process is well written!
B站这个视频我是跪着看完的
面试突击68:为什么 TCP 需要 3 次握手?
regular expression
Login module use case writing
Fuzzy PID control of motor speed
Fiddler download and installation
随机推荐
protobuf的基本用法
Wu Enda linear regression of machine learning
Modern medicine in the era of "Internet +"
服务发现原理分析与源码解读
在.NET 6.0中配置WebHostBuilder
MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
Development to testing: a six-year road to automation starting from 0
Phpexcel export Emoji symbol error
QT handy notes (VI) -- update interface, screenshot, file dialog box
The use of MySQL in nodejs
Wechat applet learning notes 2
SSG框架Gatsby访问数据库,并显示到页面上
Draw arrows with openlayer
Study notes of the first week of sophomore year
JS判断数据类型 Object.prototype.toString.call和typeof
分布式网络通信框架:本地服务怎么发布成RPC服务
JS continuous assignment operation
Sublime install plug-ins
Application of Gauss elimination