0

Trying to save a text file from desktop

copy my_notes(notes) from  '/root/desktop/test_note.txt' 

It shows this error..

ERROR: extra data after last expected column

CONTEXT: COPY my_notes, line 3: " cher"

I'm a newbie in postgresql

Community
  • 1
  • 1

2 Answers2

2

COPY expects tab-separated data, with newlines separating rows.

It isn't suitable for just loading a text file into a field. To do that, I suggest using a simple script, say python and psycopg2.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
0

To read a plain text from a file, there is also pg_read_file() - reserved for superusers, though, because of potential security implications. Details in this related answer:
Read data from a text file inside a trigger

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228