pg_dump -f myDatabase.tar -F t -h myServer -U myUser -W -i myDatabase
createdb -h myServer -U myUser -T template0 myDatabaseCopy
pg_restore -d myDatabaseCopy -h myServer -U myUser myDatabase.tar
Then I get this error, and the import fails with an error for the whole table.
psql: /home/me/myDatabase.tar: 660266: ERROR: value too long for a character of type (100) CONTEXT: COPY myTable, line 591, column myColumn: "Former member of the State Department" Project for the Future of Iraq "and now in the Atlantic compartment ... "
These hats are annoying curly single and double quotes. It seems to me that they first fit into the column, but somewhere in the export / import process they expand, and then no longer fit into the column with the changing symbol (100).
I actually move the database on the server, for which I have little rights, so the sql solution will be great. Is there a way to do something like
UPDATE myTable SET myColumn = removeNonAscii(myColumn) WHERE hasNonAscii(myColumn)
EDIT: Habe got this. I changed
createdb -h myServer -U myUser -T template0 myDatabaseCopy
to
createdb -h myServer -U myUser -T template0 -E UTF8 myDatabaseCopy
and it did the trick.
source
share