LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   postgres COPY function needed help (https://www.linuxquestions.org/questions/linux-newbie-8/postgres-copy-function-needed-help-252306/)

vickr1z 11-08-2004 01:54 AM

postgres COPY function needed help
 
im having this error on my script:
psqlolmap.sql:18: invalid command \.
psqlolmap.sql:36: invalid command \.

polmap.sql
Code:

\c polmap
BEGIN;

SET search_path = public, pg_catalog;

--
-- Data for TOC entry 315 (OID 761231)
-- Name: provinces; Type: TABLE DATA; Schema: public; Owner: dbadmin
--

COPY provinces (province_name, province_code, db_user, "timestamp") FROM stdin;
APAYAO        988100000        dbadmin        2004-01-27 06:48:19.458466
MOUNTAIN PROVINCE        984400000        dbadmin        2004-01-27 06:48:19.458466
KALINGA        983200000        dbadmin        2004-01-27 06:48:19.458466
IFUGAO        982700000        dbadmin        2004-01-27 06:48:19.458466
\.

--
-- Data for TOC entry 316 (OID 761238)
-- Name: municipalities; Type: TABLE DATA; Schema: public; Owner: dbadmin
--

COPY municipalities (municipality_name, municipality_code, db_user, "timestamp") FROM stdin;
SAN MIGUEL        993907000        dbadmin        2004-01-27 06:48:19.464152
MALATE        993910000        dbadmin        2004-01-27 06:48:19.464152
CITY OF LAS PIÑAS        997601000        dbadmin        2004-01-27 06:48:19.464152
CITY OF PARAÑAQUE        997604000        dbadmin        2004-01-27 06:48:19.464152
PASAY CITY        997605000        dbadmin        2004-01-27 06:48:19.464152
SAN NICOLAS        993904000        dbadmin        2004-01-27 06:48:19.464152
NAVOTAS        997503000        dbadmin        2004-01-27 06:48:19.464152
TONDO        993901000        dbadmin        2004-01-27 06:48:19.464152
\.

what does the errors mean: do i have to edit my script?? i just got this created from a database dump (pg_dump -h 192.12.0.100 polmapdb > polmap.sql)

how can i fix my script so it would run correctly?? any idea will appreciate very much..

rjlee 11-08-2004 05:36 AM

You didn't say how you are using the script.

The problem is this:
Code:

\.
which is being used to mean “end of file” in the dump script. If you don't use the right utility (I think you want psql) to load the script, it won't know what to do with \. because it's not a part of SQL.

Copying from Postgres to postgres, you might find it easier to use a binary dump file (see the pg_dump manpage); it's faster than using an SQL dump and takes up less space.


All times are GMT -5. The time now is 06:06 AM.