Oracle数据库对表基本的操作--增删查改

--向student表中加入入学时间属性,其数据类型为日期型
alter table student add scome date;

--删除student表中的入学时间属性
alter table student drop column scome;

--删除基本表
drop table <表名>;

--修改列
alter table student modify(列名 数据类型);

--修改表名
rename <表名> to <新表名>;

--修改列名
alter table <表名> rename column <列名> to <新列名>;

--建立索引是加快查询的有效手段,加快查找速度
--为学生表student按姓名建立唯一索引
create unique index index_sname on student(sname);

--删除索引
drop index <索引名>;
drop index index_sname;

--单表查询
select <查询字段>
from <表名>
where <条件>;

--数据更新插入
insert into <表名> values(表中所有字段信息);
insert into <表名>(列名1,列名2...) values (列名内容);

--更新修改数据
update <表名>
set <列名>=<表达式>
where <条件>;

--删除数据
delete from <表名>
where <条件>;


--视图:是从一个或者几个基本表导出的表,是一个虚表,可以限制用户对数据库的访问

--例如:
create view vw_student
as
select sno,sname,sage
from student
where sdept='CS';
--授权
--授权用户
grant select
on student
to user1;
--允许授权用户把权限授予给其他用户
with grant option;

--权限回收
revoke update
on student
from user1;

猜你喜欢

转载自www.cnblogs.com/ylkh/p/9071833.html