当前位置:网站首页>Built in functions other functions
Built in functions other functions
2022-07-27 20:12:00 【Hua Weiyun】
11.12 MySQL Other functions of
MySQL There are some functions in that cannot be specifically classified , But these functions are MySQL It can not be ignored in the process of development, operation and maintenance , This section briefly introduces MySQL Functions that cannot be specifically classified in .
11.12.1 FORMAT(value,n) function
FORMAT(value,n) Function returns a pair of numbers value Formatted result data , among n It means to keep it after the decimal point after rounding n position . If n Is less than or equal to 0, Then only the integer part .
mysql> SELECT FORMAT(123.123, 2), FORMAT(123.523, 0), FORMAT(123.123, -2); +--------------------+--------------------+---------------------+| FORMAT(123.123, 2) | FORMAT(123.523, 0) | FORMAT(123.123, -2) |+--------------------+--------------------+---------------------+| 123.12 | 124 | 123 |+--------------------+--------------------+---------------------+1 row in set (0.00 sec)11.12.2 CONV(value,from,to) function
CONV(value,from,to) Function will value The value of is converted between different hexadecimals ,value It's an integer , If any of the parameters is NULL, The result returns NULL. An example is as follows :
mysql> SELECT CONV(16, 10, 2), CONV(8888,10,16), CONV(NULL, 10, 2);+-----------------+------------------+-------------------+| CONV(16, 10, 2) | CONV(8888,10,16) | CONV(NULL, 10, 2) |+-----------------+------------------+-------------------+| 10000 | 22B8 | NULL |+-----------------+------------------+-------------------+1 row in set (0.00 sec)11.12.3 INET_ATON(value) function
INET_ATON(value) Functions will be separated by dots IP The address is converted into a number , among ,value Is represented by dots IP Address . An example is as follows :
mysql> SELECT INET_ATON('192.168.1.100');+----------------------------+| INET_ATON('192.168.1.100') |+----------------------------+| 3232235876 |+----------------------------+1 row in set (0.00 sec)With “192.168.1.100” For example , The calculation method is 192 multiply 256 Of 3 Power , add 168 multiply 256 Of 2 Power , add 1 multiply 256, Plus 100.
11.12.4 INET_NTOA(value) function
INET_NTOA(value) Function will be in numerical form IP The address is converted to dot separated IP Address . An example is as follows :
mysql> SELECT INET_NTOA(3232235876);+-----------------------+| INET_NTOA(3232235876) |+-----------------------+| 192.168.1.100 |+-----------------------+1 row in set (0.00 sec)You can see ,INET_ATON(value) Function and INET_NTOA(value) Functions are inverse functions to each other .
11.12.5 BENCHMARK(n,expr) function
BENCHMARK(n,expr) Function will express expr repeat n Time , Mainly used for testing MySQL Handle expr The time taken by the expression . An example is as follows :
mysql> SELECT BENCHMARK(1, MD5('mysql'));+----------------------------+| BENCHMARK(1, MD5('mysql')) |+----------------------------+| 0 |+----------------------------+1 row in set (0.00 sec)You can see , The string mysql perform 1 Time MD5 Encryption takes little time .
mysql> SELECT BENCHMARK(1000000, MD5('mysql')); +----------------------------------+| BENCHMARK(1000000, MD5('mysql')) |+----------------------------------+| 0 |+----------------------------------+1 row in set (0.20 sec)You can see , The string mysql perform 1000000 Time MD5 Encryption takes time 0.20s.
11.12.6 CAST(value AS type) function
CAST(value AS type) Function will value Convert to type Type value , among type The values of are shown in the table 11-6 Shown .
surface 11-6 CAST(value AS type) Function type Desirable value

An example is as follows :
mysql> SELECT CAST('123' AS SIGNED);+-----------------------+| CAST('123' AS SIGNED) |+-----------------------+| 123 |+-----------------------+1 row in set (0.00 sec)CONVERT(value,type) Functions and CAST(value AS type) The same function , I won't repeat .
11.12.7 CONVERT(value USING char_code) function
take value The character encoding used is modified to char_code, An example is as follows :
mysql> SELECT CHARSET('mysql'), CHARSET(CONVERT('mysql' USING 'utf8'));+------------------+----------------------------------------+| CHARSET('mysql') | CHARSET(CONVERT('mysql' USING 'utf8')) |+------------------+----------------------------------------+| utf8mb4 | utf8 |+------------------+----------------------------------------+1 row in set, 1 warning (0.00 sec)You can see ,MySQL The default character encoding for strings is utf8mb4, have access to CONVERT(value USING char_code) Function to change it to UTF-8.
边栏推荐
- codeforces每日5题(均1500)-第二十四天
- LG Group announced that it would donate 3million yuan in cash, 1.2 million masks and 10000 sets of protective clothing to Hubei
- 康佳半导体首款存储主控芯片量产出货,首批10万颗
- How to run kevinchappell / FormBuilder
- Dcm11- write the function and configuration of the data service ($2e) according to the identifier [based on DaVinci configurator classic]
- [redis] redis penetration, avalanche and breakdown
- Software configuration | tigervnc download, installation and configuration
- ECU software and hardware architecture
- Chapter 2 Introduction
- antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key
猜你喜欢

PMP practice once a day | don't get lost in the exam -7.27 (including agility + multiple choices)

cesium基本控件介绍

Global function

Introduction to basic cesium controls
![[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB](/img/ab/026111b25836758ec7ffec8d60f49d.png)
[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB

Common errors reported by pytorch

信道容量、信道带宽基本概念的理解

电容串联与并联以及电容串联与平衡电阻

ms721负载测试

剑指 Offer 25. 合并两个排序的链表
随机推荐
Container summary
函数优先顺序
PMP practice once a day | don't get lost in the exam -7.27 (including agility + multiple choices)
总线Bus是什么意思
Underlying principle of mvcc
LeetCode练习2——两数之和
Unified Modeling Language (UML) specification
Product Manager: check where there is an error prompt of "system exception" on the offline
Codeworks 5 questions per day (average 1500) - day 24
In 2019, the global semiconductor revenue fell by 12% year-on-year, and China's market share ranked first
使用cpolar建立一个商业网站(5)
Capacitance in series and in parallel and capacitance in series and balance resistance
信道容量、信道带宽基本概念的理解
LED高精度体重秤方案规格书
C # network application programming, experiment 1: WPF exercise
‘vite‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件
Libpcap library and pcap_ Sendpacket interface function understanding
Cfssl of pki/tls tool -- the road to dream
[redis] several deployment methods of redis
Western digital mobile hard disk can't be read (the idiom of peace of mind)