当前位置:网站首页>(1) DDL, DML, DQL, DCL and common data types
(1) DDL, DML, DQL, DCL and common data types
2022-07-25 22:24:00 【Who is Huang Huang】
One .MySql
1.MySQL Is a relational database management system
2. Relational database management system , Relational databases store data in different tables , Instead of putting it in a warehouse , This increases the speed , Increased flexibility
3. Small volume 、 Fast 、 The cost is low , Open source
Two .mysql Common data types in databases
2.1 Character type

2.2 value type

2.3 Time type

3、 ... and .DDL、DML、DQL、DCL What are the differences
3.1 DDL( Data definition language ): The relationship between database and database tables
3.1.1 Creating databases and tables
1. grammar :
create table Table name (
Name data type ( length ),
Name data type ( length ),
Name data type ( length ),
Name data type ( length )
......... );
2.
Example : Create a student table sid sname sex sage sbirthday date
create table student(
sid int(11), sname varchar(20),
sex char(2), sage int(4),
sbirthday date
);
3. Be careful :
A. When creating a table You need to add an English semicolon after the brackets Columns are separated by commas
There is no need to write a comma for the last column name
B. The length of the data type of the column You don't specify However, it is generally recommended to specify its length
3.1.2 Modify the name of the table
1. grammar : alter table Original table name rename to The new name of the table
3.1.3 Delete table
1. grammar : drop table Table name
3.2 DML( Data manipulation language ): Add data 、 Delete 、 Modify the operating . The commonly used statement keywords are INSERT、UPDATE、DELETE etc.
3.2.1 Add data
1. grammar : insert into Table name values( data 1, data 2, data 3);
INSERT INTO student VALUES(1,“ Hehaipeng ”,“123456”,‘2018-11-20’);
.
.2. grammar : insert into Table name ( Name , Name , Name )values( data , data , data );
INSERT INTO student(sid,spwd,sbrithday)VALUES(2,“123”,‘2019-11-23’)
.
Insert multiple data
insert into Table name values( data 1, data 2, data 3),( data 1, data 2, data 3)
insert into Table name ( Name , Name , Name )values( data , data , data ),( data , data , data );
Example :
INSERT INTO student(sid,spwd,sbrithday)VALUES(3,“122”,‘2019-10-23’), (4,“345”,‘2019-10-23’)
INSERT INTO student VALUES(5,“ Wu Qilong ”,“123456”,‘2018-11-20’),(6,“ Li Ying Hwan ”,“123456”,‘2018-11-20’)
Be careful :
A. The value of the inserted data must be consistent with the data type in the database list
B. The length of the inserted data value should be less than the length defined in the list
C. Strings can be decorated with single quotation marks and double quotation marks The time type can only be decorated with single quotation marks
3.2.2 Modifying data
1. grammar :update Table name set Name = value , Name = value where Conditions
2. UPDATE student SET sname =“ Brother Mao ” ,spwd=“123” WHERE sid =1;
.
3. When performing modification It needs to be modified according to the conditions
3.2.3 Delete data
grammar :delete from Table name where Conditions
DELETE FROM student WHERE sid=1;
3.3DQL( Data query language ): It is mainly used to query data . Common keywords are SELECT、FROM、WHERE etc.
3.4DCL( Data control language ): It is mainly used to set / Change database user permissions . Common keywords are GRANT、REVOKE etc.
边栏推荐
猜你喜欢

Xiaobai programmer day 8

Ffmpeg plays audio and video, time_ Base solves the problem of audio synchronization and SDL renders the picture

H5幸运刮刮乐抽奖 免公众号+直运营

Win10 set up a flutter environment to step on the pit diary

2day

Imitation Tiktok homepage interface

3day

什么是分区分桶?

Use of hyperlinks

对需求的内容进行jieba分词并按词频排序输出excel文档
随机推荐
Redis foundation 2 (notes)
SQL中in的用法 DQL 查询
Xiaobai programmer the next day
Output Yang Hui triangle with two-dimensional array
About vscode usage+ Solutions to the problem of tab failure
arcgis开发常用源码
Victoriametrics single node of kubernetes
分割金条的代价
Smart S7-200 PLC channel free mapping function block (do_map)
D3.js 学习
Which is reliable between qiniu business school and WeiMiao business school? Is it safe to open an account recommended by the teacher?
TS:typora代码片段缩进显示异常(已解决)-2022.7.24
编译和反编译
【Leetcode】502.IPO(困难)
6-18 vulnerability exploitation - backdoor connection
How to implement an app application to limit users' time use?
Data quality: the core of data governance
3day
3dslicer importing medical image data
对需求的内容进行jieba分词并按词频排序输出excel文档