【笔记】2.表格中的操作DML

阅读 33

2022-01-30

-- 数据插入
#格式1
insert into student_info(sid,name,gender,age,birth,address,score)
	VALUES(1,'张三', '男', 18, '2001-12-23', 'beijing', 85.5),
	(2,'张四', '男', 18, '2001-12-24', 'beijing', 85.6);
insert into student_info(sid,name)
	VALUES(1,'张三'),
	(2,'张四');

#格式2
insert into student_info
	VALUES(1,'张三', '男', 18, '2001-12-23', 'beijing', 85.5),
	(2,'张八', '男', 18, '2001-12-24', 'beijing', 82.6);
	
-- 数据修改
#将所有学生的地址改为重庆
update student_info set address = '重庆';
#修改指定的内容
update student_info set address = 'beijing' where sid = 1;
update student_info set address = 'shanghai', score=99 where sid = 2;

-- 数据删除
delete from student_info where score = 82.6;
-- delete from student_info; #删除表中内容
-- truncate table student_info; #删除表,然后重建一个表

精彩评论(0)

0 0 举报