Oracle View Creation with a Database generated ID from a Sequence Object

随声附和 提交于 2020-01-24 23:56:27

问题


Can i create an oracle "View" with a DB generated Primary Key?

I want to create a view with its ID being a DB generated ID from a Sequence object.


回答1:


You can't do exactly that, but you can do something like this:

select rownum, field1, field2
  from...

the rownum is an aoutogenerated field that holds exactly that, but it's assigned BEFORE ordering records, so if you have an ORDER BY clause, then you'll have to do this:

Select rownum, *
  from (select ....
         order by ....)


来源:https://stackoverflow.com/questions/9778323/oracle-view-creation-with-a-database-generated-id-from-a-sequence-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!