简单的答案是你的语法不正确。您必须指定DISABLE。

NOVALIDATE禁用主键验证,在视图中这是默认值,因此自动包含;但是如果你使用它会更清楚,因为在一个可爱的双重否定中,disable novalidate禁用了禁用主键的功能。

rely是可选的;它指定在创建视图时是否考虑主键。 rely的反义词是norely。

创建视图约束有很多限制,因为它依赖于下表,它并不像@RC已经注意到的那样值得。但如果您只需要文档,那么请转到:

SQL> create table tmp_test ( a number(10), b varchar2(120) );

Table created.

SQL>

SQL> insert into tmp_test

2 select level, 'b'

3 from dual

4 connect by level <= 20

5 ;

20 rows created.

SQL> commit ;

Commit complete.

SQL>

SQL> alter table tmp_test

2 add constraint tmp_test_pk

3 primary key (a)

4 using index;

Table altered.

SQL>

SQL> create or replace view v_tmp_test (a, b

2 , constraint v_tmp_test_pk primary key (a) rely disable novalidate) as

3 select a, b

4 from tmp_test

5 ;

View created.

SQL>来自documentation:

View Constraints

Oracle does not enforce view constraints. However, operations on views

are subject to the integrity constraints defined on the underlying

base tables. This means that you can enforce constraints on views

through constraints on base tables.

Notes on View Constraints View constraints are a subset of table

constraints and are subject to the following restrictions:

You can specify only unique, primary key, and foreign key constraints

on views. However, you can define the view using the WITH CHECK OPTION

clause, which is equivalent to specifying a check constraint for the

view.

View constraints are supported only in DISABLE NOVALIDATE mode. You

cannot specify any other mode. You must specify the keyword DISABLE

when you declare the view constraint. You need not specify NOVALIDATE

explicitly, as it is the default.

The RELY and NORELY parameters are optional. View constraints, because

they are unenforced, are usually specified with the RELY parameter to

make them more useful. The RELY or NORELY keyword must precede the

DISABLE keyword. Please refer to "RELY Clause" for more information.

Because view constraints are not enforced directly, you cannot specify

INITIALLY DEFERRED or DEFERRABLE.

You cannot specify the using_index_clause, the exceptions_clause

clause, or the ON DELETE clause of the references_clause.

You cannot define view constraints on attributes of an object column.

oracle视图view看不出来主键,oracle - 使用主键创建视图相关推荐

  1. 数据库-视图(View)详解

    一.简介 视图(View)可以看作定义在SQL Server上的虚拟表.视图正如其名字的含义一样,是另一种查看数据的入口.常规视图本身并不存储实际的数据,而仅仅存储一个Select语句和所涉及表的me ...

  2. Android中自定义视图View

    标签: 前言 好长时间没写blog了,心里感觉有点空荡荡的,今天有时间就来写一个关于自定义视图的的blog吧.关于这篇blog,网上已经有很多案例了,其实没什么难度的.但是我们在开发的过程中有时候会用 ...

  3. Android中自定义视图View之---前奏篇

    前言 好长时间没写blog了,心里感觉有点空荡荡的,今天有时间就来写一个关于自定义视图的的blog吧.关于这篇blog,网上已经有很多案例了,其实没什么难度的.但是我们在开发的过程中有时候会用到一些自 ...

  4. mysqldump导出数据库视图_mysql中如何用mysqldump批量如何导出视图view啊?

    你的位置: 问答吧 -> MySQL -> 问题详情 mysql中如何用mysqldump批量如何导出视图view啊? mysql中如何用mysqldump批量如何导出视图view啊? 我 ...

  5. SQL创建视图(CREATE VIEW)

    视图是基于 SELECT 语句的结果集的可视化的表. 什么是视图? 在 SQL 中,一个视图是基于某个 SELECT 语句的结果集的可视化的表. 视图包含行和列,就像一个真实的表.视图中的域就是来自一 ...

  6. Oracle创建视图和同义词

    今天创建视图遇到一点问题,记录一下. 问题1:创建视图提示没有权限:ORA-01031: insufficient privileges 解决方案:登录sys用户,给需要创建视图的用户授予创建视图权限 ...

  7. 视图view基本概念

    视图(view):是根据用户需求定义的数据结构,是从一个或多个表导出的虚拟的表,其内容由查询定义.具有普通表的结构,但是不实现数据存储.视图本身并不包含任何数据,它只包含映射到基表的一个查询语句,当基 ...

  8. Oracle创建视图的一个问题

    问题: 在用户user1中创建视图,查询内容包含user2下的表数据, 创建视图的时候提示"权限不足".执行如下语句: --为USER1授权 GRANT CREATE ANY TA ...

  9. MySQL 进阶 视图 -- 视图介绍、视图CRUD语法、检查选项(CASCADED、LOCAL)、视图的更新、视图作用、视图案例

    文章目录 1. 视图 1.1 视图介绍 1.2 语法 1.2.1 创建视图 1.2.2 查询视图 1.2.3 修改视图 1.2.4 删除视图 1.2.5 插入数据说明 1.3 检查选项 1.3.1 C ...

最新文章

  1. 禁止/启用angularjs相关缓存的方法
  2. 什么是‘YTowOnt9‘?
  3. 四.MongoDB 概念解析
  4. python pandas读取csv_Python3 pandas怎么读取csv文件的第一行的
  5. 安装CCS5时仿真驱动出现问题的解决方法
  6. 我把上课的机器学习课件发给了国内300多位高校老师
  7. boost::callable_traits的is_lvalue_reference_member的测试程序
  8. Curl http_code 状态码
  9. 移动页面自适应手机屏幕宽度HTML5开发
  10. 软考(2)——看图心想编译原理
  11. 查看工作组计算机没有服务器,计算机相关:网上邻居问题:当前工作组的服务器列表无法使用...
  12. Spring - Configuration Metadata
  13. TeaVM的samples/benchmark范例运行办法
  14. gluster安装完全指南
  15. 如何去掉firefox启动就是360主页 小白实操记录
  16. 征集国内操作系统项目列表
  17. 游戏策划:为什么我的儿子不沉迷游戏?
  18. QT下获取汉字拼音首字母
  19. 函数曲线长度的计算方法
  20. SQLserver基础--语句、存储过程(七)

热门文章

  1. ExtJS入门(08)窗口,按钮,输入框,
  2. php的toast,使用toast组件实现提示用户忘记输入用户名或密码功能
  3. web项目通过ajax提交数据太大报错
  4. Jquery 禁用元素的所有属性
  5. 苹果公司透露Siri新发音引擎的内部原理
  6. Android RecyclerView和ScrollView嵌套使用
  7. 看人家如何拿到腾讯阿里的offer
  8. Spark入门实战系列--2.Spark编译与部署(下)--Spark编译安装
  9. 2.4-yum工具详解
  10. oKit项目管理软件试用及感受