How to check if a sequence exists in my schema?
Asked Answered
B

3

6

Is there a way to retrieve all the sequences defined in an existing oracle-sql db schema?

Ideally I would like to use something like this:

SELECT * FROM all_sequences WHERE owner = 'me';

which apparently doesn't work.

Bellbottoms answered 3/1, 2014 at 16:14 Comment(1)
What are you looking for exactly and what does your table look like?Antigen
G
9

Try this:

SELECT object_name
  FROM all_objects
 WHERE object_type = 'SEQUENCE' AND owner = '<schema name>'
Granville answered 3/1, 2014 at 16:22 Comment(0)
W
7

Yes:

select * from user_sequences;

Your SQL was almost correct too:

select * from all_sequences where sequence_owner = user;
Wendy answered 3/1, 2014 at 16:23 Comment(1)
Thanks Tony, this works as well, but I chose the other answer as it is more generic.Bellbottoms
D
3

Below query can be triggered in Oracle Developer to check whether sequence present in DB or not :

SELECT count(*) count FROM user_sequences WHERE sequence_name = 'SEQ_NAME';

If 'SEQ_NAME' present in your DB then count will return 1 else 0 .

Dichromate answered 12/7, 2018 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.