Ho provato a creare un database con Encoding:UTF8 con una tabella e inserire i due caratteri codificati UTF-8 che il comando COPY sta cercando di inserire e funziona quando si utilizza INSERT.
CREATE DATABASE test
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'English_United States.1252'
LC_CTYPE = 'English_United States.1252'
CONNECTION LIMIT = -1;
CREATE TABLE x
(
first_two_letters character(3)
)
WITH (
OIDS=FALSE
);
ALTER TABLE x
OWNER TO postgres;
INSERT INTO x(
first_two_letters)
VALUES ('سر');
Secondo http://rishida.net/tools/conversion/ per la COPIA non riuscita i punti di codice Unicode sono:
che sono due caratteri , il che significa che dovresti essere in grado di memorizzarli in una colonna definita come carattere(3), che memorizza stringhe fino a 3 caratteri (non byte) di lunghezza.
e se proviamo ad INSERT, ci riesce:
INSERT INTO x(
first_two_letters)
VALUES (U&'\0633\0631');
Dalla documentazione di pgdump puoi INSERT invece di COPY usando l'opzione --inserts
Prova a usarlo invece per il passaggio 1:
pg_dump -U postgres -t OldSchema."TableToCopy" --inserts OldDatabase > Table.sql
Ho anche provato a COPIA da una tabella a un file e utilizzare COPIA per importare e per me funziona.
Sei sicuro che la codifica del database del tuo client e server sia UTF8?
Innanzitutto, esporta la tabella denominata "x" dallo schema "public" sul database "test" in un file SQL di testo normale:
pg_dump -U postgres -t public."x" test > x.sql
che crea il file x.sql che contiene:
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: x; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE x (
first_two_letters character(3)
);
ALTER TABLE public.x OWNER TO postgres;
--
-- Data for Name: x; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY x (first_two_letters) FROM stdin;
سر
\.
--
-- PostgreSQL database dump complete
--
In secondo luogo, importa con:psql -U postgres -d test -f x.sql