Adds support for column reordering in pg_dump Tested in postgresql 8.3.5 To compile: - patch/replace pg_dump.c - place reorder.c in the same directory To run: use the -r/--reorder-columns Format of the file that specifies the new ordering: One full qualified column-name per line, format "schema.tablename.colname" (accepts comments beginning with # , discards blanks, ignores blank lines, rejects non-ascii chars) Only required are the columns to be reordered, the omitted columns will be placed after the specified ones. Example: see atrjobs.lst Hint: The following query produces all the original columns of the db in the desired format (uncoment to get the type as a comment) SELECT namesp.nspname || '.' || t.relname || '.' || atr.attname -- || ' # ' || atr_type.typname -- optional FROM pg_attribute atr, pg_class t, pg_type atr_type, pg_namespace namesp WHERE atr.attnum>0 and atr.attisdropped = 'f' and atr.attrelid = t.oid and atr.atttypid = atr_type.oid and t.relnamespace = namesp.oid and t.relkind = 'r' and namesp.nspname not like 'pg_%' and namesp.nspname != 'information_schema' ORDER BY namesp.nspname,t.relname,atr.attnum Hernan J. Gonzalez nov 2008 hgonzalez@gmail.com