Oracle,视图,序列,索引
2016-05-11 22:21
260 查看
视图:对应于一条select语句。它本身不包含任何数据。它只包含映射到基表的一个查询语句。
分类:简单视图(不包含任何函数,表达式,分组函数),复杂视图(简单视图相反),连接视图(多个表连接)语法:create view viewName AS Select语句
作用:简化复杂查询,限制数据访问。
对视图操作会影响到基表中的数据。
为了实现视图的安全性:一般再最后加上[with check option]的约束。表示:视图所做的修改必须在 视图所见的范围内。
【read only】约束只读视图。
复杂视图不允许DML操作。
删除视图:drop view viewName
序列:
sequence是一种用来生成唯一数字值的数据库对象。一个序列可以为多个表提供主键值。创建序列:create sequence sequence_name
[start with i] [increment by j]
[maxvalue m | nomaxvalue]
[minvalue n | nominvalue]
[cycle | nocycle][cache p | nocache]
例如:create sequence emp_seq start with 100 increment by 10;
序列中有两个伪列:nextVal currval
删除序列:drop sequence squence_name;
索引:提高查询效率。
create [unique]index index_name on table(colum[,colum...]);例如:create index test_index on test(id);
修改索引:alter index index_name rebuild(重建索引)
drop index index_name
约束:
包括Not Null,Unique,Primary Key,Foreign Key,Check(检查约束)例如:Alter table emp add constraint emp_name unique(name);
Alter table emp add constraint emp_id primary key(id)
外键约束:先建表,在建表后建立外键约束条件。
例如:alter table employees add constraint employees_fk foreign key(deptno) references dept(deptno)
检查约束:
例如:alter table employees add constraint employees_check Check(salary>2000);
相关文章推荐
- Oracle EBS OM Transaction
- ORACLE报错
- Oracle dblink详解
- Oracle用户,权限,角色以及登录管理 scoot 授权
- ORACLE用SYS登录报ORA-28009:connection as SYS should be as SYSDBA OR SYSOPER解决方法
- 读书笔记:Oracle数据库之【分区】
- oracle数据迁移到db2数据库
- oracle表回滚到一个指定时间的操作语句
- Oracle LOB
- oracle数据库内存调优
- oracle 数据库搭建库详解
- Oracle-游标
- oracle的nvl和sql server的isnull
- oracle 密码文件文件
- oracle之 sql性能优化
- Oracle表误删恢复数据
- 欢迎使用CSDN-markdown编辑器
- Oracle12c中功能及性能新特点之with子句的增强
- Oracle 12c 数据库中scott用户不存在的解决方法
- 【OGG】GoldenGate For Oracle实施文档 --超详细总结版