当前位置:网站首页>MySQL-DML
MySQL-DML
2022-06-21 11:47:00 【Jue Niu thunder plough hot blade】
/* DML It refers to the data operation language , The full English name is Data Manipulation Language, Used to update the data records of tables in the database . keyword : 1. Insert insert 2. Delete delete 3. to update update */
# Insert the way 1
insert into student(sid, name, gender, age, birthday, address, score)
values (1008, ' Little plum ', 'male', 18, '2004-12-9', ' New York ', 74),
(1009, ' Fruit sister ', 'female', 22, '2000-12-9', ' Washington ', 89);
# Insert data into the specified column
insert into student(sid)
values (1022);
insert into student(sid, name)
values (1024, ' pomegranate ');
# Insert the way 2
# Insert all columns
insert into student
values (1078, ' Kobe ', 'male', 37, '1975-12-9', ' Los Angeles ', 85),
(1099, ' harden ', 'male', 22, '2000-12-9', ' Houston ', 78);
# modify ( to update )
# 1. Change the address of all students to Philadelphia
update student
set address=' Philadelphia ';
# 2. take sid by 1008 The address of the student of is changed to Kashgar
update student
set address=' Kashgar '
where sid = 1008;
# 2. take sid Greater than 1008 The student's address is changed to Russia
update student
set address=' Russia '
where sid > 1008;
# 3. take sid by 1009 The address of the students is changed to Heilongjiang , The grade is revised to 99
update student
set address=' heilongjiang ',
score=99
where sid = 1009;
# Delete data
# 1. Delete sid by 1008 Student data for
delete
from student
where sid = 1008;
# 2. Clear table data
delete
from student;
# truncate table student;
# table Omission
truncate student;
# Be careful :delete and truncate The principle is different ,delete Only delete content ,
# and truncate Be similar to drop table, It can be understood as deleting the whole table , Then create the table ;
# practice
/* 1. Create an employee table emp, The fields are as follows : id( staff id), name( Employee name ), gender( Gender of employees ), salary( Employee pay ), */
create table if not exists emp
(
id int comment ' staff id',
name varchar(20) comment ' Employee name ',
gender varchar(10) comment ' Gender of employees ',
salary double comment ' Employee pay '
);
/* 2. insert data 1,' Zhang San ',' male ',2000 2,' Li Si ',' male ',3000 3,' Wang Xiaowu ',' Woman ',2000 */
insert into emp
values (1, ' Zhang San ', ' male ', 2000),
(2, ' Li Si ', ' male ', 3000),
(3, ' Wang Xiaowu ', ' Woman ', 2000);
# Modify table data
# 1. Change the salary of all employees to 5000
update emp
set salary=5000;
# 2. Name is ‘ Zhang San ’ The salary of the employee is revised to 3000
update emp
set salary=3000
where name = ' Zhang San ';
# 3. take id by 3 The salary of the employee is revised to 6000,gender It is amended as follows ‘ male ’
update emp
set salary=6000,
gender=' male '
where id = 3;
# 4. take id by 3 The employee's salary is increased on the original basis 2000
update emp
set salary=salary + 2000
where id = 3;
边栏推荐
- Deep water area involvement
- Illustrated with pictures and texts -- wechat applet to obtain the user's geographic location information and call Tencent map API to obtain the user's specific location
- 【综合笔试题】难度 2.5/5 :「树状数组」与「双树状数组优化」
- High performance parallel programming and optimization | lesson 01 homework
- 游戏机之AR机械臂
- XML entity injection vulnerability
- DevSecOps:初入江湖
- DevSecOps:应当做好的十件事
- [Harbin Institute of technology] information sharing for the first and second examinations of postgraduate entrance examination
- 事务Transaction
猜你喜欢

2022危险化学品经营单位安全管理人员特种作业证考试题库及在线模拟考试

Break down tasks

站在数字化风口,工装企业如何“飞起来”

XML entity injection vulnerability

boost一定要入门呀

A Kuan food: the battle for "the first share of convenience food" continues

2022年安全员-A证考试模拟100题及在线模拟考试

New experience of cultural tourism! 3dcat helps Guangzhou intangible cultural heritage "yuancosmos" block make a cool appearance
Golang implements redis (9): use geohash to search people nearby

对文件夹下所有的文件一键改名
随机推荐
深水区涉入
[Harbin Institute of technology] information sharing for the first and second examinations of postgraduate entrance examination
2022安全员-B证复训题库及模拟考试
南京大学 静态软件分析(static program analyzes)-- Intermediate Representation 学习笔记
Ar manipulator of game console
Matrial3d parameter analysis
当GDPR来敲门
完美安全代码审计的5个最佳实践
WPF 使用 MAUI 的自绘制逻辑
服务器被入侵了怎么办
阿宽食品:“方便食品第一股”争夺战继续
When gdpr knocks
【哈尔滨工业大学】考研初试复试资料分享
是德示波器软件,Keysight示波器上位机软件NS-Scope
机器学习2-线性回归
The k-th small__
Flink tuning (I) resource tuning and back pressure analysis
Illustrated with pictures and texts -- wechat applet to obtain the user's geographic location information and call Tencent map API to obtain the user's specific location
第k小__
【云原生 | Devops篇】Jenkins安装与实战(二)