如何将表从转储还原到数据库? [英] How to restore table from dump to database?

查看:117
本文介绍了如何将表从转储还原到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用pg_dump创建表转储:

I create a table dump using pg_dump:

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

我进入psql后说:

-f D:\np_point.sql

但是获取标准PostgreSQL表列表。

But get list of standart PostgreSQL tables.

接下来,我尝试在pgAdmin中使用np_point.sql并得到错误:

Next I try to exequte np_point.sql in pgAdmin and get error:

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

此sql的代码段,我会收到错误:

Its snippet of this sql where I get error:

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

如何从sql文件还原表?

How can I restore table from sql file?

更新

PostgreSQL 8.4

PostgreSQL 8.4

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))
);


推荐答案

您是否在目标数据库中安装了posgis?如果不是,请先安装postgis。

Did you install posgis in destinations db? 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.

这篇关于如何将表从转储还原到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆