[SQL] drop table where tableName like 'backup_2007%' ?

2008-03-31 Thread Emi Lu
Good morning, Is there a command to drop tables whose name begins a specific string? For example, all backup tables begins with backup_2007: Drop table where tableName like 'backup_2007%'? Thanks a lot! -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] drop table where tableName like 'backup_2007%' ?

2008-03-31 Thread Tom Lane
Emi Lu [EMAIL PROTECTED] writes: Is there a command to drop tables whose name begins a specific string? No. The standard answer to this type of problem is to write a little plpgsql function that scans the appropriate catalog and issues commands constructed with EXECUTE. for r in select

Re: [SQL] drop table where tableName like 'backup_2007%' ?

2008-03-31 Thread Richard Huxton
Tom Lane wrote: Note that the above is overly simplistic --- it doesn't pay attention to schemas, for example. These are what I use. BEGIN; CREATE SCHEMA util; CREATE OR REPLACE FUNCTION util.exec_all(objtype name, schname name, objname name, cmd TEXT) RETURNS text AS $$ DECLARE