begin; create table foo ( one int, two int, three int, primary key (one, three) ); insert into foo values (4, 5, 6); select * from foo order by 1, 3; select c.relname, a.attname, a.attnum from pg_attribute a join pg_class c on (c.oid = a.attrelid) where c.relname='foo' and attnum >= 0 order by attnum; select indnatts, indkey, indisprimary from pg_index i join pg_class c on (c.oid = i.indrelid) where c.relname='foo'; alter table foo drop column two; select c.relname, a.attname, a.attnum from pg_attribute a join pg_class c on (c.oid = a.attrelid) where c.relname='foo' and attnum >= 0 order by attnum; select indnatts, indkey, indisprimary from pg_index i join pg_class c on (c.oid = i.indrelid) where c.relname='foo'; select * from foo order by 1, 3; rollback;