Checkif sequence exists

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Checkif sequence exists

Post by swraman »

I need to check if a sequence exists, I know that to check if a table exists you can rin a querry line

SELECT count(*)>0 FROM pg_tables WHERE schemaname='public' AND tablename='sections'

and it will return true if the table exists and false if it doesnt. But how do you check this for a sequence? I couldnt fint much online about this.

Thanks

Raman
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Checkif sequence exists

Post by VladSun »

[sql]SELECT     * FROM     information_schema.sequences[/sql]

Why do you need that?
There are 10 types of people in this world, those who understand binary and those who don't
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: Checkif sequence exists

Post by swraman »

when I run the install file that creates all the tables and sequences I need to check if the sequence exists before telling it to create it.
Post Reply