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

边栏推荐
- Byte side: can TCP and UDP use the same port?
- 90. Subset II
- 静态路由和缺省路由实验
- tutorial/detailed_ workflow. Ipynb quantitative finance qlib Library
- 数据可视化新闻,不一样的新闻报道形式
- 阿里云CDN实践
- Why is 0.1 + 0.2 not equal to 0.3? How to solve this problem?
- Esp8266 Arduino programming example - timer and interrupt
- Record the fluent to solve the problem of a renderflex overflowed by 7.3 pixels on the bottom
- 04.toRef 默认值
猜你喜欢

C语言编程规范学习笔记和总结

HCIP(14)

SQL injection less34 (post wide byte injection + Boolean blind injection)

Sword finger offer II 052. flatten binary search tree (simple binary search tree DFS)

拥抱开源指南

AimBetter洞察您的数据库,DPM 和 APM 解决方案

Ruiji takeout - background login function development

mysql create语句能不能用来建立表结构并追加新的记录

Win11怎么打开软件通知

hcip实验(14)
随机推荐
The difference between get and post
MOV格式是不是静态图像文件格式
HCIP(14)
【CVPR 2021】Cylinder3D:用于LiDAR点云分割的圆柱体非对称3D卷积网络
SQL injection less38 (Stack Injection)
Learning notes and summary of C language programming specification
内网渗透学习(三)域横向移动——计划任务
局域网添加DNS服务器进行域名解析
[cloud native kubernetes] mapping external service under kubernetes cluster eendpoint
Aimbetter insight into your database, DPM and APM solutions
[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints
ECMASript 5/6 笔记
SQL injection less34 (post wide byte injection + Boolean blind injection)
TensorFlow Serving 高性能的机器学习模型服务系统
display 各值的区别
科大讯飞笔试
Typeof principle
Learn kotlin - extension function
LCR测试仪最为主要的功能和用途都是什么
HCIP(12)
