1.数据的插入
格式:
insert into 表 (列名1,列名2,列名3...) values (值1,值2,值3...); // 向表中插入指定列的值
insert into 表 values (值1,值2,值3...); // 向表中插入所有列的值
范例:
insert into student(sid,sname,gender,sage,birth,address,score)
values(1001,'张三','男',18,'1996-2-10','北京',83.5);
insert into student values(1002,'李四','男',19,'1995-12-11','北京',75);
2.数据的修改
格式:
update 表名 set 字段名=值,字段名=值...;
update 表名 set 字段名=值,字段名=值... where 条件;
范例:
-- 将所有学生的地址修改为上海
update student set address = '上海';
-- 将sid为1002的学生的成绩修改为90
update student set score = 90 where sid = 1002;
3.数据删除
格式:
delete from 表名 [where 条件];
truncate table 表名 或者 truncate 表名;
范例:
-- 1.删除sid为1002的学生数据
delete from student where sid = 1002;
-- 2.删除表所有数据
delete from student;
-- 3.清空表数据
truncate table student;
truncate student;