it should go like this...
if select count(*) from pg_class where relname = 'mytable' is NULL THEN CREATE table table
Main Topics
Browse All TopicsHi Experts,
Is there a way to check if a table exists in a given database before I try to create it in ODBC for Postgres?
Thanks,
Mike
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
if not check this link
http://www.experts-exchang
SELECT count(*) from information_schema.tables WHERE table_name = 'my_table';
That will give you the count of matching tables. You can also optionally confirm the table_schema if you have tables of the same name in different schemas.
The good thing about using information_schema is that it's part of the SQL standard. Here's a link to the documentation on the information_schema:
http://www.postgresql.org/
There are several other useful views in that schema.
More info about SQLTables:
http://msdn2.microsoft.com
Cheers,
za-k/
Thanks for the problem. I learned quite a lot about ODBC these days.
At first I thought there is no way to access the schema and I thought:
This is outrageous! How come you cannot access that??!!
You can do that with DAODB but not with ODBC??!
Then I searched some more and found the SQLTables function.
Cheers,
za-k/
Business Accounts
Answer for Membership
by: scorpiiaPosted on 2008-01-25 at 03:38:13ID: 20741627
if Object_id(tablename) is not NULL