当前位置:网站首页>(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.
边栏推荐
- 编译和反编译
- JS interview questions
- 字符型常量和字符串常量的区别?
- 如何将一个域名解析到多个IP地址?
- 访问者模式(visitor)模式
- Arcgis10.2 configuring postgresql9.2 standard tutorial
- How many bytes does Boolean occupy?
- It's over. I went to work for three months and became bald
- 6-18 vulnerability exploitation - backdoor connection
- [leetcode] 502.ipo (difficult)
猜你喜欢

Playwright tutorial (I) suitable for Xiaobai

Fill the whole square with the float property
![[C syntax] void*](/img/34/b29b7bbf8eae9f1730352cac1301a4.png)
[C syntax] void*

6-17 vulnerability exploitation - deserialization remote command execution vulnerability

Virtual memory and disk

Whether the five distribution methods will produce internal fragments and external fragments

3dslicer importing medical image data

4day

『Skywalking』. Net core fast access distributed link tracking platform

win10搭建flutter环境踩坑日记
随机推荐
Xiaobai programmer's fifth day
Don't vote, software testing posts are saturated
Can I buy financial products with a revenue of more than 6% after opening an account
数学规划分类 Math Programming Classfication
IFLYTEK smart office book air e-book reader makes my work life healthier
If it is modified according to the name of the framework module
微信发卡小程序源码-自动发卡小程序源码-带流量主功能
synchronized与volatile
[go basics 02] the first procedure
On the difference between break and continue statements
VIM usage record
编译和反编译
Victoriametrics single node of kubernetes
完啦,上班三个月,变秃了
Redis memory elimination mechanism?
xss-收集常用的代码
SQL中in的用法 DQL 查询
科大讯飞智能办公本Air电纸书阅读器,让我的工作生活更加健康
什么是类加载?类加载的过程?
What is the difference between character constants and string constants?