我想使用postgresql v9.5数据库,并使用sql转储 pg_dump
来移动表格:
pg_dump --host=localhost --username=postgres --port=5432 --dbname=my_db -t ,my_table > /D:\my_table.sql
表格中有一个UUID标识符CREATE TABLE public.my_table
(
uuid uuid NOT NULL DEFAULT gen_random_uuid(),
created timestamp with time zone DEFAULT now(),
content text,
)
导入.sql文件
对于没有UUID列的表,可以使用以下方法:
cd C:\Program Files (x86)\PostgreSQL\9.5\bin
psql --dbname=my_db --host=localhost --username=postgres -w --port=5432 -f D:\my_table.sql
针对具有UUID列的特定表格,我在第一个UUID位置上遇到以下错误:
psql:D:\my_table.sql:1327: ERROR: syntax error at or near "c9ccacd8"
LINE 1: c9ccacd8-7e37-40a2-8eca-e589dbe42a59 2016-06-04 09:48:00.676...
sql文件
下面是my_table.sql文件中引用的行:
ALTER TABLE my_table OWNER TO postgres;
COPY my_table (uuid, created, content) FROM stdin;
c9ccacd8-7e37-40a2-8eca-e589dbe42a59 2016-06-04 09:48:00.676592+00 \N
40ce5512-f566-495f-b709-0b2ec45e09c6 2016-06-04 09:48:57.148606+00 \N
\.