当前位置:网站首页>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
边栏推荐
- 服务发现原理分析与源码解读
- JS continuous assignment operation
- js 表格自动循环滚动,鼠标移入暂停
- Wechat H5 payment on WAP, for non wechat browsers
- Gauss elimination
- Write a script that can run in Bash / shell and PowerShell
- 挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破
- In Net 6.0
- MFC handy notes
- 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
猜你喜欢
【荧光字效果】
Spolicy request case
Draw arrows with openlayer
Principle analysis and source code interpretation of service discovery
The diagram of user login verification process is well written!
服务发现原理分析与源码解读
Keeping alive to realize MySQL automatic failover
Installation and use of cocoapods
开发转测试:从0开始的6年自动化之路...
Applet record
随机推荐
Development to testing: a six-year road to automation starting from 0
在同一conda环境下先装Pytroch后装TensorFlow
El table implements adding / deleting rows, and a parameter changes accordingly
时间序列异常检测
解释一下自动装箱和自动拆箱?
Principle analysis and source code interpretation of service discovery
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
[fluorescent character effect]
网易云UI模仿-->侧边栏
Applet record
JS table auto cycle scrolling, mouse move in pause
Sqoop [put it into practice 02] sqoop latest version full database import + data filtering + field type support description and example code (query parameter and field type forced conversion)
PHP executes shell script
The diagram of user login verification process is well written!
反射机制的原理是什么?
Gauss elimination solves the inverse of matrix (Gauss)
protobuf的基本用法
Write a script that can run in Bash / shell and PowerShell
Search module use case writing
In Net 6.0