当前位置:网站首页>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

边栏推荐
- SQL injection less42 (post stack injection)
- 数据可视化新闻,不一样的新闻报道形式
- IFLYTEK written examination
- tutorial/detailed_workflow.ipynb 量化金融Qlib库
- Tensorflow serving high performance machine learning model service system
- Form validation and cascading drop-down lists (multiple implementations)
- 第 8 篇:创建摄像机类
- 示波器发展史中的变化
- Aimbetter insight into your database, DPM and APM solutions
- 90. Subset II
猜你喜欢
随机推荐
39. Combined sum
Tensorflow serving high performance machine learning model service system
Esp8266 Arduino programming example - timer and interrupt
小程序 canvas 生成海报
Ordinary practice of JS DOM programming
腾讯云数据库负责人借了一亿元炒股?知情人士:金额不实
C语言编程规范学习笔记和总结
Lotus 1.16.0 extend sector expiration time
Ecmasript 5/6 notes
什么是时间复杂度
Ruiji takeout - background login function development
hcip实验(12)
[NLP] generate word cloud
罗克韦尔AB PLC RSLogix数字量IO模块基本介绍
display 各值的区别
Why is 0.1 + 0.2 not equal to 0.3? How to solve this problem?
SQL injection less38 (Stack Injection)
【云原生之kubernetes】在kubernetes集群下的映射外部服务—Eendpoint
【机器学习】朴素贝叶斯对文本分类--对人名国别分类
hcip实验(14)










