当前位置:网站首页>What functions does MySQL have? Don't look everywhere. Just look at this.
What functions does MySQL have? Don't look everywhere. Just look at this.
2022-07-28 11:23:00 【51CTO】

Format function FPRMAT(x,n)
format(x,n) The digital x format , And keep the decimal point after... In the way of rounding n position , The result is returned as a string .
If n by 0, Then the return result function does not contain decimal part .
Numbers in different base numbers are converted to each other
conv(n, from_base, to_base) This function can convert between different base numbers . For example, will 16 Conversion of decimal digits to 2 Base number , Or 2 Conversion of decimal digits to 10 It's all right .
The return value is a number n String representation of , from from_base The base number is converted to to_base Base number . If any of the parameters is null Words , So the return value is null.
IP Address and number conversion function
inet_auto(expr) Give a dot address representation of the network address as a string , Returns an integer representing the value of the address . The address can be 4 perhaps 8bit Address .
conversely , We can also use inet_ntoa Function converts a numeric network address to a string network point address , To look down :
therefore , From above ,inet_ntoa and inet_aton They're inverse functions to each other .
Lock function and unlock function
get_lock(str, timeout) Try to use a string str Get a lock for a given name , The timeout is timeout second . If you succeed in getting the lock , Then return to 1, If the operation times out , Then return to 0; Once an error occurs , Then return to null.
release_lock(str) Untie the quilt get_lock() Acquired 、 Use string str Lock named lock . If the lock is unlocked , Then return to 1, If the thread has not created a lock , Then return to 0( The lock is not unlocked at this time ); If the named lock does not exist , Then return to null. If this lock has never been get_lock() Call to get , Or the lock has been untied in advance , Then the lock does not exist .
is_free_lock(str) Check that the name is str Whether the lock can be used , If this lock can be used , Then return to 1( No one uses this lock ); If this lock is being used , Then return to 0; If something goes wrong , Then return to null( Like incorrect parameters ).
if_used_lock(str) Check that the name is str Is your lock being used , If this is locked , Returns the connection identifier of the client using the lock , Otherwise , Just go back to null.
get_lock('yunweijia', 15): The return result is 1, Description successfully got a name of ‘yunweijia’ Lock of , Duration is 15 second ;
is_used_lock('yunweijia'): The return result is the current connection id, The name is yunweijia The lock of is being used ;
is_free_lock('yunweijia'): The return is 0, The description name is yunweijia The lock of is being used ;
release_lock('yunweijia'): The return value is 1, It indicates that the unlocking is successful .
Reset the function that performs the specified operation
benchmark(count, expr) Function repetition count Number of execution expressions expr.
He can calculate with a computer mysql Speed of processing expressions . The result value is generally 0(0 It just means that the processing process is fast , Not without time ). Another function is that it can be used in mysql The execution time of the client internal report statement .
for instance :
First we use sha Function to encrypt a password , as follows :
You can see from above , This article sql The execution time is 0.00 sec, Then we use benchmark function , Repeat this command 50000 Time , Look at the running time ;
As you can see from the above results , It actually runs 0.03 second .
Functions that change the character set
convert(...using...): with using Of convert() Function is used to convert data between different character sets .
See from above , The default character set is utf8mb3, adopt convert The string yunweijia The default character set of is changed to latin1.
Functions that change data types
cast(x, as type) and convert(x, type) Function converts a value of one type to a value of another type , Convertible type There are the following :
- binary
- char(n)
- date
- time
- datetime
- decimal
- signed
- unsigned
You can see from above ,select cast(1000 as char(3)) Set integer data 1000, Convert to a string type with two display widths , The result is 100;
convert('2022-07-18 09:09:00', time) take datetime The value of type is converted to time Type values , The result is 09:09:00.
thus , In this paper, the end .
For more information, go to VX official account “ Operation and maintenance home ” , Get the latest article .
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
------ “ Operation and maintenance home ” ------
Linwu County operation and maintenance engineer training , Wenzhou operation and maintenance engineer , Accessible oa Implementation O & M engineer , Interview with call center operation and maintenance engineer
tencent idc shipment Interview with maintenance engineer , O & M Engineer samba, What is the industry of operation and maintenance engineers ,
Origin of operation and maintenance engineer , Operation and maintenance engineers are easy to find , Operation and maintenance Engineer access , Self study of operation and maintenance engineers is feasible
边栏推荐
- 【C语言】的%*d、%.*s等详解:「建议收藏」
- 零代码 | 轻松实现数据仓库建模,搭建BI看板
- Machine learning strong foundation plan 0-5: why is the essence of learning generalization ability?
- 2021-03-24
- DHCP experiment demonstration (Huawei switch device configuration)
- 盘点:144个免费学习网站,全网最全资源合集
- 什么是WordPress
- 什么是WordPress
- Build a quick development ide: visualsvn + sublime + Visual Studio 2013 + quickeasyftpserver
- Three ways for Cortex-M kernel to manage global interrupts
猜你喜欢

Why should coding and modulation be carried out before transmission

CRM+零代码:轻松实现企业信息化

小水滴2.0网站导航网模板

本地化、低时延、绿色低碳:阿里云正式启用福州数据中心
![[JS advanced] JS functions, overloads, anonymous functions, scopes and scope chains_ 03](/img/50/754f7915ee4b2e04fdd21ae68130c6.png)
[JS advanced] JS functions, overloads, anonymous functions, scopes and scope chains_ 03

做数据分析,你还不懂RFM分析方法(模型)?

What is WordPress

Learn to use MySQL explain to execute the plan, and SQL performance tuning is no longer difficult

I use the applet container to improve the efficiency of mobile R & D by 5 times!

DHCP experiment demonstration (Huawei switch device configuration)
随机推荐
Picture slide effect
【cesium】entity属性和时许绑定:SampledProperty方法简单使用
Related concepts of several databases
表格数据处理软件,除了Excel还有什么?
什么是WordPress
用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案
Remote shutdown of computer with mobile phone
Fhwy workday schedule
The solution of PHP sending mobile MAS SMS garbled code
Preliminary understanding of float
学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难
Make a virtual human with zego avatar | virtual anchor live broadcast solution
18张图,直观理解神经网络、流形和拓扑
What is WordPress
Nodejs: detect and install the NPM module. If it is already installed, skip
JWT 登录认证 + Token 自动续期方案,写得太好了!
GIS数据漫谈(五)— 地理坐标系统
Reading these six books makes learning MySQL easier
Array related knowledge points
机器学习强基计划0-5:为什么学习的本质是泛化能力?