Update documentation to show how to have PostgreSQL generate columns list

This commit is contained in:
dim 2008-02-12 17:03:26 +00:00
parent a2195ec2e7
commit d02bf0a661

View File

@ -440,6 +440,25 @@ In case you have a lot a columns per table, you will want to use
multiple lines for this parameter value. Python ConfigParser module multiple lines for this parameter value. Python ConfigParser module
knows how to read multi-line parameters, you don't have to escape knows how to read multi-line parameters, you don't have to escape
anything. anything.
+
An easy way to get the list of attributes (columns) of your tables
(say +a+, +b+ and +c+) is by the following query:
+
BEGIN;
CREATE AGGREGATE array_acc(anyelement) (
SFUNC = array_append,
STYPE = anyarray,
INITCOND = '{}'
);
SELECT relname, array_acc(attname)
FROM pg_attribute a join pg_class c on a.attrelid = c.oid
WHERE relname in ('a', 'b', 'c')
and attname not in ('tableoid','cmax','xmax','cmin','xmin','ctid')
GROUP BY relname;
ROLLBACK;
+
user_defined_columns:: user_defined_columns::
+ +