View Single Post

   
  #5 (permalink)  
Old 04-09-2008, 11:04 PM
Florian Pflug
 
Posts: n/a
Default Re: Generating TRUNCATE orders

Erik Jones wrote:
> On Oct 3, 2007, at 12:19 PM, Scott Marlowe wrote:
>
> SELECT 'TRUNCATE ' || schemaname || '.' || tablename ';'
> FROM pg_tables
> WHERE schemname='my_schema'
> ORDER BY tablename;


To be safe, you'd probably want to write
SELECT 'TRUNCATE' || quote_ident(schemaname) || '.' || quote_ident(tablename) ||
';' ...

Otherwise, table or schema names containing funny characters, upper case, or
spaces will cause trouble..

greetings, Florian Pflug


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply With Quote