创建
- 语法:
- insert into 表名(列名1,列名2,列名3,…)
- select ‘值1’,‘值2’,‘值3’,‘值4’ union
- select ‘值1’,‘值1’,‘值2’,‘值3’
---代码:
insert into student(name,sex,age,clazz_id,stu_num)
select '赵胜','男',18,3,2401 union
select '张三','男',19,4,2402
增加
- 语法:insert into 表名(列名1,列名2,列名3,…)
- values (‘值1’,‘值2’,…)
---代码:
insert into course(id,name)
values (4,'赵云')
修改
- 语法: update 表名 set 新列名1=‘值1’ ,新列名2=‘值2’ where 旧列名1=‘值1’ ,…
代码:
update course set name='颜红' where name='马云'
删除
- 语法1:delete from 表名 where 列名=‘值’
- 语法2:truncate table 表名
---代码1:
delete from course where id=1
---代码2:
truncate table course
拷贝数据到另外一张新(不存在)表中
- 语法:select * into 旧表名 from 新表名
代码:
select * into clazz from course