当前位置:网站首页>MySQL built-in functions
MySQL built-in functions
2022-07-28 22:21:00 【GSX_ MI】
Catalog
3. Mathematical functions ( Less use )
1. Date function
(1) Function USES
- Get date :
- Obtain hours, minutes and seconds :

- Get timestamp :

- Add a date to the date :

- Subtract the time from the date :

- Calculate the number of days between two dates :

(2) Case study 1: Create a table , Record birthday
(3) Case study 2: Create a message table , And insert data
① Show all message messages , The release date only shows the date , Don't show the time
② Please check in 2 Posts posted within minutes
2. String function
(1) Use cases
① obtain msg Tabular name Character set of column
② Ask to show exam_result Information in the table , Display format :“XXX My language is XXX branch , mathematics XXX branch , English XXX branch ”
③ Find the number of bytes occupied by students' names in the student table
- Be careful :length Function returns the length of the string , In bytes . If it is a multi byte character, calculate the number of bytes ; If it is a single byte character, it is counted as a byte . such as : Letter , The array counts as a byte , Chinese means multiple bytes ( Related to character set encoding )
④ take EMP There are... In all the names in the table M Of is replaced by ' Rice noodles '
⑤ Intercept EMP In the table ename The second to third characters of the field
⑥ Display the names of all employees in lowercase
(2) Other tests
- instr
- left
- strcmp( Case insensitive )
- ltrim,rtrim,trim
3. Mathematical functions ( Less use )
① The absolute value
② Rounding up ( Round to positive infinity in the number axis )
③ Rounding down ( Round to negative infinity in the number axis )
④ Keep two decimal places ( Round the decimal )
⑤ Generate random numbers ,rand() What comes out randomly is <0 Number of numbers
4. Other functions
①user() Query current user
②md5(str) To a string md5 Abstract , After the summary, we get a 32 A string
- Generally in mysql in , Save the user password without clear text ,
- Benefits of using summaries :
- 1.mysql There is no clear text password , Even inside the company DBA( Database administrator ), You can't view the password
- 2. The password is fixed !( The database table for storing passwords is easy to design )
- When I first registered my account , The database encrypts the password into a fixed length string and saves it in the database , After logging in again, you only need to encrypt the password entered by the user again and compare it with the string stored in the database to determine whether the password is correct
③database() Displays the database currently in use
④password() function ,MySQL The database uses this function to encrypt users
⑤ifnull(val1, val2) If val1 by null, return val2, Otherwise return to val1 Value
边栏推荐
- MOV格式是不是静态图像文件格式
- Typeof principle
- 乌官员:乌克兰一半农产品经多瑙河港口出口
- HCIP(12)
- Ukrainian officials: half of Ukrainian agricultural products are exported through the Danube port
- If you want to grow rapidly, you must first experience a major blow!
- What is a prime factor? In number theory, a prime factor (prime factor or prime factor) refers to a prime number that can divide a given positive integer
- 2021 mathematical modeling group B exercise
- 迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名
- array_ diff_ The method of not comparing array values when Assoc element is an array
猜你喜欢
SQL injection less34 (post wide byte injection + Boolean blind injection)
mysql create语句能不能用来建立表结构并追加新的记录
HCIP(8)
How to establish a decentralized community in Web3
腾讯云数据库负责人林晓斌借一亿元炒股?知情人士:金额不实
Chapter 7: drawing rotating cubes
DHCP and PPPoE protocols and packet capture analysis
If you want to grow rapidly, you must first experience a major blow!
2021 mathematical modeling group B exercise
成立不到一年!MIT衍生量子计算公司完成900万美元融资
随机推荐
Clearing of applet component timer
记录Flutter解决A RenderFlex overflowed by 7.3 pixels on the bottom溢出问题
Why is 0.1 + 0.2 not equal to 0.3? How to solve this problem?
小程序 组件 定时器的清除
tutorial/detailed_ workflow. Ipynb quantitative finance qlib Library
MOV格式是不是静态图像文件格式
Win11怎么打开软件通知
[machine learning] naive Bayesian classification of text -- Classification of people's names and countries
IFLYTEK written examination
In Kingbase, the user is specified to search the schema by default, or the user cannot use the function under the public schema
[NLP] generate word cloud
HCIP(13)
Future trend of defi in bear market
HCIP(11)
数据可视化新闻,不一样的新闻报道形式
Mysql内置函数
Alibaba cloud CDN practice
迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名
第 7 篇:绘制旋转立方体
Small program canvas generates posters