简体   繁体   English

如何将表从转储恢复到数据库?

[英]How to restore table from dump to database?

I create a table dump using pg_dump: 我使用pg_dump创建一个表转储:

pg_dump -h server1 -U postgres -t np_points gisurfo > D:\np_point.sql

After I go in psql and says: 我进入psql之后说:

-f D:\np_point.sql

But get list of standart PostgreSQL tables. 但获得标准的PostgreSQL表列表。

Next I try to exequte np_point.sql in pgAdmin and get error: 接下来我尝试在pgAdmin中执行np_point.sql并获取错误:

ERROR:  Syntax error (near: "1")
LINE 78: 1 Сухово 75244822005 75644000 Челябинская обл. Нязепетровски...

Its snippet of this sql where I get error: 这个sql的片段,我得到错误:

COPY np_point (gid, full_name, okato, oktmo, obl_name, region_nam, the_geom) FROM stdin;
1   Сухово  75244822005 75644000    Челябинская обл.    Нязепетровский район    0101000020E6100000312A7936BD9F4D402A3C580DE9FF4B40

How can I restore table from sql file? 如何从sql文件恢复表?

UPDATE UPDATE

PostgreSQL 8.4 PostgreSQL 8.4

And first part of sql file. 和sql文件的第一部分。

PostgreSQL database dump

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: np_point; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
 --

CREATE TABLE np_point (
gid integer NOT NULL,
full_name character varying(254),
okato character varying(254),
oktmo character varying(254),
obl_name character varying(254),
region_nam character varying(254),
the_geom geometry,
CONSTRAINT enforce_dims_the_geom CHECK ((st_ndims(the_geom) = 2)),
CONSTRAINT enforce_geotype_the_geom CHECK (((geometrytype(the_geom) = 'POINT'::text) OR (the_geom IS NULL))),
CONSTRAINT enforce_srid_the_geom CHECK ((st_srid(the_geom) = 4326))
);

Did you install posgis in destinations db? 你在目的地db中安装了posgis吗? If not , install postgis first。 如果没有,请先安装postgis。

If you install postgis and still have the problem, try to dump a table without geometry filed and restore it in another db ,and see if the problem still appears. 如果您安装postgis仍然有问题,请尝试转储没有几何体的表并将其还原到另一个数据库中,并查看问题是否仍然出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM