Обсуждение: ERROR: invalid input syntax for integer:
Readers, A database table was created with the command: CREATE TABLE tablename (column1 bigint,date date,time time,column2 text) a csv file was imported, of structure: 123456,2000-01-01,01:10,"sometext" Using the command: \copy tablename from file.csv Causes the command terminal error: input syntax for integer: "123456,2000-01-01,01:10,"sometext"" CONTEXT: COPY tablename, line 1, column column2: "123456 What is my mistake please?
e-letter <inpost@gmail.com> writes: > A database table was created with the command: > CREATE TABLE tablename (column1 bigint,date date,time time,column2 text) > a csv file was imported, of structure: > 123456,2000-01-01,01:10,"sometext" > Using the command: > \copy tablename from file.csv > Causes the command terminal error: > input syntax for integer: "123456,2000-01-01,01:10,"sometext"" > CONTEXT: COPY tablename, line 1, column column2: "123456 I don't believe that \copy will default to assuming that the file is in csv format. You probably need to add "format csv" or something similar to that command. regards, tom lane
On Wed, Sep 21, 2011 at 4:04 PM, e-letter <inpost@gmail.com> wrote:
Within psql, the following works for me:
\COPY tablename FROM file.csv CSV HEADER
Using the command:
\copy tablename from file.csv
Causes the command terminal error:
input syntax for integer: "123456,2000-01-01,01:10,"sometext""
CONTEXT: COPY tablename, line 1, column column2: "123456
What is my mistake please?
Within psql, the following works for me:
\COPY tablename FROM file.csv CSV HEADER
On 22/09/2011, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > I don't believe that \copy will default to assuming that the file is in > csv format. You probably need to add "format csv" or something similar > to that command. Thanks; for the benefit of others, import was successful when the above \copy command was appended with: csv When the csv file had no header columns.