one problem
Hello all
how to get back one database (text format) to postgresql ?
field1 field2 field3 ...
field1 field2 field3 ...
.
.
.
thanks
-----Message d'origine-----
De : Jonathan davis <haj@idianet.net>
� : 'pgsql-general@postgreslq.org' <pgsql-general@postgreSQL.org>
Date : mardi 6 juillet 1999 12:45
Objet : [GENERAL] one problem
Hello all
how to get back one database (text format) to postgresql ?
field1 field2 field3 ...
field1 field2 field3 ...
.
.
.thanks
the COPY command does that BUT BUT BUT BUT !!!
how to specify the fields for example I just insert field2 into the
database
example:
create table country (code char(2), country char(20));
and i want to insert just the field country not the field code
how to proceed ?
Import Notes
Resolved by subject fallback
Hello all
how to get back one database (text format) to postgresql ?
field1 field2 field3 ...
field1 field2 field3 ...
.
.
.thanks
the COPY command does that BUT BUT BUT BUT !!!
how to specify the fields for example I just insert field2 into the
databaseexample:
create table country (code char(2), country char(20));
and i want to insert just the field country not the field code
how to proceed ?
Salut Jonathan,
Hum... don't think you could do that with a COPY in one step
you could COPY all of that data into a temp table and then INSERT the
fields you want into the final table and delete the old ones so:
(in psql)
CREATE TABLE temp_copy (field1 text, field2 text, field3 text); --
obviously, use the right types
COPY temp_copy FROM <text_format_database>;
INSERT INTO country (country) SELECT field2 FROM temp_copy; -- or whatever
field or fields you want,
-- you could also use SELECT INTO command to create TABLE country on the
fly and alter it with ALTER TABLE if necessary.
DROP TABLE temp_copy;
HTH,
Stuart.
+-------------------------+--------------------------------------+
| Stuart Rison | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street |
| Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. |
| Fax. (0171) 878 4040 | stuart@ludwig.ucl.ac.uk |
+-------------------------+--------------------------------------+
On Tue, 6 Jul 1999, Jonathan davis wrote:
-----Message d'origine-----
De : Jonathan davis <haj@idianet.net>
� : 'pgsql-general@postgreslq.org' <pgsql-general@postgreSQL.org>
Date : mardi 6 juillet 1999 12:45
Objet : [GENERAL] one problemHello all
how to get back one database (text format) to postgresql ?
field1 field2 field3 ...
field1 field2 field3 ...
.
.
.thanks
the COPY command does that BUT BUT BUT BUT !!!
how to specify the fields for example I just insert field2 into the
databaseexample:
create table country (code char(2), country char(20));
and i want to insert just the field country not the field code
how to proceed ?
Some bash or perl magic to preprocess that file could help. I hear the
cut(1) command does wonders.
--
Peter Eisentraut
PathWay Computing, Inc.