adding primary key to sql view

Hoa*_*oax 11 sql oracle view primary-key

Reading that

how to do hibernate mapping for table or view without a primary key

I am wondering how to add a primary key to my view as it is basically just a stored query...?

PS: oracle 10g

thx

APC*_*APC 30

我们可以向视图添加禁用的主键约束.也就是说,如果对视图运行插入或更新,则不会触发约束.数据库期望通过对基础表的约束来维护完整性.因此,约束仅用于文档目的.

SQL> create view emp_view as select * from emp
  2  /


View created.

SQL> alter view emp_view add constraint vemp_pk primary key (empno) disable
  2  /

View altered.

SQL> 
Run Code Online (Sandbox Code Playgroud)

警告:我从未尝试过使用Hibernate,所以我不知道它是否适用于你的场景.但是,我确实知道使用Hibernate专门针对一层视图的网站,所以我认为它确实如此.请试用语法并报告回来.