注意:插入数据时要满足表或者列的约束条件,否则插入失败,不成功!
// 挑选字段插入
insert into student(sno, sname) values('001','zs')
// 插入所有属性
insert into student values('001','zs','male')
// 一次插入多条
insert into student values('001','zs','male')
values('002','ls','famale')
// 插入子查询结果
insert into student2
select sno, sname
from student
// 注意+where条件,否则全部被修改
update student
set sex = 'female'
where sno = '001'
//带子查询的修改
update student
set sex = 'male'
where sno in
(select sno
from sc
where sdept = 'cs')
// 注意加where条件,否则删除全部
delete from student where sno = '001'
// 带子查询的
delete from sc
where sno in(
select sno
from student
where sdept = 'cs'
)
创建视图
DBMS执行CREATE VIEW语句时只是把视图定义存入数据字典,并不执行其中的SELECT语句。在对视图查询时,按视图的定义从基本表中将数据查出。
不指定属性列的坏处