ITPub博客

首页 > IT职业 > IT生活 > 学习笔记 视图

学习笔记 视图

原创 IT生活 作者:wmlm 时间:2007-05-25 14:09:52 0 删除 编辑

创建强制视图可更新视图视图相关的数据字典

[@more@]


--- 视图中的列数限制1000
The maximum number of columns that can be defined in a view is 1000, just
as for a table.

--- 创建有错误的视图(force view)
SQL> create force view test_view as
2 select c1,c2 from test_table;

Warning: View created with compilation errors.

SQL> desc test_view
ERROR:
ORA-24372: invalid object for describe


SQL> drop view test_view;

View dropped.

SQL> desc test_view
ERROR:
ORA-04043: object test_view does not exist

--- 带约束的视图,并定义约束的名字
SQL> create or replace view dept_above_250
2 as select department_id did,department_name
3 from departments
4 where department_id >250
5 with check option constraint check_dept_250;

View created.

SQL> select constraint_name,table_name from user_constraints where constraint_type='V';

CONSTRAINT_NAME
------------------------------------------------------------
TABLE_NAME
------------------------------------------------------------
CHECK_DEPT_250
DEPT_ABOVE_250

--- 相关的数据字典视图
user_views 视图定义及视图名称
user_tab_columns 视图中的列名
user_updatable_columns 视图中的各列是否可更新
user_constraints 视图上CHECK约束名称


-- 可更新的视图的要点是哪个表是主键表,如果不在基表上定义主键,即便是在视图中不重复,也不是主键表,也不能做更新。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/271063/viewspace-916222/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-08

  • 博文量
    398
  • 访问量
    3716794