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_iden
On Oct 3, 2007, at 12:19 PM, Scott Marlowe wrote:
On 10/3/07, Laurent ROCHE <[EMAIL PROTECTED]> wrote:
Would this work:
SELECT
'TRUNCATE TABLE ' ||
'my_schema.' ||
c.relname ||', '
FROM pg_namespace nc, pg_class c
WHERE c.relnamespace = nc.oid
AND c.relkind IN ('r' )
AND nc.nspname = 'my_sc
On 10/3/07, Laurent ROCHE <[EMAIL PROTECTED]> wrote:
Would this work:
SELECT
'TRUNCATE TABLE ' ||
'my_schema.' ||
c.relname ||', '
FROM pg_namespace nc, pg_class c
WHERE c.relnamespace = nc.oid
AND c.relkind IN ('r' )
AND nc.nspname = 'my_schema'
ORDER BY relname
---(e
Laurent ROCHE wrote:
So I wrote:
SELECT 'TRUNCATE TABLE '
UNION
...
ORDER BY relname
And this fails with the following message:
ERROR: column "relname" does not exist
But I don't understand why this does not work: the 2 SELECTs produce a single
char column so from what I understand th
Hi,
I wanted to write a SELECT that generates a TRUNCATE TABLE for all the tables
in a given schema.
So I wrote:
SELECT 'TRUNCATE TABLE '
UNION
SELECT 'my_schema.' || c.relname ||', '
FROM pg_namespace nc, pg_class c
WHERE c.relnamespace = nc.oid
AND c.relkind IN ('r' )
AND nc.nspname = '