Search code examples
oracle-databasesequencesynonym

Sequence can have synonym?


I created first sequence=>

SQL> create sequence sq_001;

Then synonym for sequence=>

SQL> create synonym syn_001 for sq_001;

Then I query the user_synonyms =>

SQL> select*from user_synonyms where synonym_name = 'SYN_001';

SYNONYM_NAME    TABLE_OWNER     TABLE_NAME      DB_LINK         ORIGIN_CON_ID
--------------- --------------- --------------- --------------- -------------
SYN_001         RAMIN           SQ_001                                      3

This is confused me, written table_name but this is sequence(SQ_001) and worked =>

TABLE_NAME
---------------
SQ_001

Solution

  • Yes, a sequence can have a synonym as you have demonstrated. The view USER_SYNONYMS is confusing in having a column called TABLE_NAME that can contain other things - it should really be OBJECT_NAME. Presumably when USER_SYNONYMS was first created only tables could have synonyms.