psql: SELECT * ... except one column
To get the list of columns in default order, without the bad column:
SELECT string_agg(quote_ident(attname), ', ' ORDER BY attnum)
FROM pg_attribute
WHERE attrelid = 'myschema.mytable'::regclass
AND NOT attisdropped -- no dropped (dead) columns
AND attnum > 0 -- no system columns
AND attname <> 'bad_column' -- case sensitive!
Or just WHERE attrelid = 'mytable'::regclass
if you trust the search path to resolve to the right schema.
quote_ident()
adds double-quotes where necessary.
I asked the same question in 2007 on pgsql-general. It was Postgres 8.2 back then. Sweet memories ...
Related:
- How to check if a table exists in a given schema