From: | jo <jose(dot)soares(at)sferacarta(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | dump order by |
Date: | 2012-12-22 17:29:51 |
Message-ID: | 50D5EE0F.3070407@sferacarta.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I would like to know if it is possible to dump a table ordered by its
primary key.
Take a look at the this test table...
\d test
Table "public.test"
Column | Type | Modifiers
-----------+---------+---------------------------------------------------
id | integer | not null
name | text |
id_father | integer |
Indexes:
"test_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"test_id_father_fkey" FOREIGN KEY (id_father) REFERENCES test(id)
select * from test;
id | nome | id_father
----+-----------------+-----------
6 | Homer Simpson | 5
5 | Abraham Simpson |
10 | Maggie Simpson | 6
1 | Ned Flanders |
2 | Maude Flanders |
9 | Bart Simpson | 6
3 | Rod Flanders | 1
4 | Todd Flanders | 1
7 | Marge Simpson |
8 | Lisa Simpson | 6
(10 rows)
I would like to dump the table with this order:
COPY test (id, nome, id_father) FROM stdin;
1 Ned Flanders \N
2 Maude Flanders \N
3 Rod Flanders 1
4 Todd Flanders 1
5 Abraham Simpson \N
6 Homer Simpson 5
7 Marge Simpson \N
8 Lisa Simpson 6
9 Bart Simpson 6
10 Maggie Simpson 6
\.
instead it is dumped like this:
COPY test (id, note, id_father) FROM stdin;
6 Homer Simpson 5
5 Abraham Simpson \N
10 Maggie Simpson 6
1 Ned Flanders \N
2 Maude Flanders \N
9 Bart Simpson 6
3 Rod Flanders 1
4 Todd Flanders 1
7 Marge Simpson \N
8 Lisa Simpson 6
\.
and I can't upload the table because the foreing keys.
j
From | Date | Subject | |
---|---|---|---|
Next Message | salah jubeh | 2012-12-22 17:45:48 | Re: dump order by |
Previous Message | Philipp Kraus | 2012-12-22 15:32:20 | rule / trigger definition |