using the "copy from" command to load tables from a txt flat file - Mailing list pgsql-general

From Knepper, Michelle
Subject using the "copy from" command to load tables from a txt flat file
Date
Msg-id 57E2A340D65EB240B071FEED12F4777B0794DA@merlin.intellidot.net
Whole thread Raw
Responses Re: using the "copy from" command to load tables from a
List pgsql-general
Hi out there,

I'm a first-time user of the "Copy ... From..." command, and I'm trying
to load a table from a text flat file.

http://www.postgresql.org/docs/7.4/static/sql-copy.html

I don't know if I'm using the command correctly.
Question:  I run this command as a superuser, and the "copy from"
command is run like a SQL command on the command line, correct?
I get the following error.  Any suggestions would be greatly
appreciated.

[mknepper@barney datafiles]$ psql -U postgres medispan
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

medispan=# COPY mmw_ade_com FROM
'/home/mknepper/medispan/datafiles/mmwadecom.txt' WITH DELIMITER '|';
ERROR:  COPY command, running in backend with effective uid 500, could
not open file '/home/mknepper/medispan/datafiles/mmwadecom.txt' for
reading.  Errno = Permission denied (13).
medispan=#



Table schema:

CREATE TABLE mmw_ade_com
(
    gpi                         VARCHAR(14) NOT NULL,
    mcid                        INTEGER NOT NULL,
    restrictionid               INTEGER NOT NULL,
    sequencenumber              SMALLINT NOT NULL,
    textid                      INTEGER,
    PRIMARY KEY (gpi, mcid, restrictionid, sequencenumber)
);



example of data, from the TXT flat file, called mmwadecom.txt:

01100040100310|5|0|10|14608
01100040100310|8|0|10|17377
01100040100310|8|0|20|18061
01100040100310|8|0|30|14608
01100040100310|22|0|10|18025
01100040100310|30|0|10|14608
01100040100310|36|0|10|14608
01100040100310|115|0|10|13937
01100040100310|115|0|20|18041



pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: value too long error
Next
From: "Karl O. Pinc"
Date:
Subject: Re: referring to computed values from the select list in the where and order clauses