I'm trying to select all from db.table if db.table exists. I've tried if, exists, etc. and none works. What's the best way to do this? I'm using cockroachdb and psycopg2. Didn't find an existing answer (most are quite old) that I could use. For example, this one didn't work me: SQl select all if table exists
I tried the following per Tim's suggestion, which doesn't seem to work. However, the db.table exists.
select exists (select 1 from information_schema.tables where table_name = 'table') ;
exists
+--------+
false
(1 row)
Time: 6.848579ms
select exists (select 1 from information_schema.tables where table_name = 'db.table') ;
exists
+--------+
false
(1 row)
Time: 5.958707ms
psycopg2is Postgres, I'll try to keep that in mind for next time!table. When you doSELECT * FROM information_schema.tables, do you see your table anywhere?