Find if a column in Oracle has a sequence

后端 未结 5 505
孤独总比滥情好
孤独总比滥情好 2021-02-05 02:56

I am attempting to figure out if a column in Oracle is populated from a sequence. My impression of how Oracle handles sequencing is that the sequence and column are separate en

5条回答
  •  灰色年华
    2021-02-05 03:23

    If the sequence is used in a trigger, it is possible to find which tables it populates:

    SQL> select t.table_name, d.referenced_name as sequence_name
      2  from   user_triggers t
      3         join user_dependencies d
      4         on d.name = t.trigger_name
      5  where  d.referenced_type = 'SEQUENCE'
      6  and    d.type = 'TRIGGER'
      7  /
    
    TABLE_NAME                     SEQUENCE_NAME
    ------------------------------ ------------------------------
    EMP                            EMPNO_SEQ
    
    SQL>
    

    You can vary this query to find stored procedures, etc that make use of the sequence.

提交回复
热议问题