mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-10 16:26:58 +02:00
Update documentation to show how to have PostgreSQL generate columns list
This commit is contained in:
parent
a2195ec2e7
commit
d02bf0a661
@ -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::
|
||||||
+
|
+
|
||||||
|
Loading…
Reference in New Issue
Block a user