Page 1 of 1

Checkif sequence exists

Posted: Tue Jan 20, 2009 7:50 pm
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

Re: Checkif sequence exists

Posted: Wed Jan 21, 2009 7:33 am
by VladSun
[sql]SELECT     * FROM     information_schema.sequences[/sql]

Why do you need that?

Re: Checkif sequence exists

Posted: Wed Jan 21, 2009 9:35 am
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.