开发者

How to find out if a column is an auto increment field in oracle?

开发者 https://www.devze.com 2023-02-12 05:15 出处:网络
How to find out if a开发者_开发技巧 column is an auto increment field in oracle?You can\'t. Oracle doesn\'t have auto-increment fields.

How to find out if a开发者_开发技巧 column is an auto increment field in oracle?


You can't. Oracle doesn't have auto-increment fields.

Oracle supports sequences, which are separate database objects for generating numbers. These seuqences can be used in the insert statement or in a before insert trigger to generate a primary key value for the new record.

The fields themselves are just normal field and there is no relation between the sequence and the field.

So the only hope is to parse a trigger and see if you can find evidence of it being filled there using a sequence. That would be a tough job, though, and I doubt if you can make this reliable enough. After all, the trigger could fire a function which returns the value, so you have to go all the way if you want to be sure.


As of Oracle 12.1 identity columns (with self generated sequences) can be identified by looking at the "DATA_DEFAULT" column of view DBA_TAB_COLUMS (or USER_TAB_COLUMNS or ALL_TAB_COLUMNS). They will look like "#OWNER"."ISEQ$$_nnnnn".nextval

0

精彩评论

暂无评论...
验证码 换一张
取 消