Discussion:
query on multiple tables in schema
(too old to reply)
Angus Berry
2004-09-28 21:19:20 UTC
Permalink
Hi, I wonder if anyone can help.

I'd like to execute a SQL query that performs an action on all the
(unrelated) tables that I select. The following query doesn't work, but
the subselect (which works) shows what I'm trying to do. All tables have
an identical column called id_num.

delete from
(select tablename from pg_tables where schemaname = 'public')
where id_num = null

I'd appreciate any advice.


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Bruno Wolff III
2004-10-01 18:30:59 UTC
Permalink
On Tue, Sep 28, 2004 at 17:19:20 -0400,
Post by Angus Berry
Hi, I wonder if anyone can help.
I'd like to execute a SQL query that performs an action on all the
(unrelated) tables that I select. The following query doesn't work, but
the subselect (which works) shows what I'm trying to do. All tables have
an identical column called id_num.
delete from
(select tablename from pg_tables where schemaname = 'public')
where id_num = null
id_num = null will always return NULL which is not TRUE so that no rows
will be selected for deletion. Try using IS NULL instead.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Loading...