【问题标题】:How to restore table from dump to database?如何将表从转储恢复到数据库?
【发布时间】:2013-03-13 06:52:23
【问题描述】:

我使用 pg_dump 创建了一个表转储:

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

在我进入 psql 并说:

-f D:\np_point.sql

但是获取标准 PostgreSQL 表的列表。

接下来我尝试在 pgAdmin 中执行 np_point.sql 并得到错误:

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

我得到错误的这个sql的sn-p:

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

如何从 sql 文件中恢复表?

更新

PostgreSQL 8.4

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

【问题讨论】:

  • 哪些版本的 postgres?您要从中转储和导入的数据库的属性是什么?您要从中转储和导入的数据库的架构是什么样的?
  • @wich:我更新了问题。请看一下。是你想看的吗?
  • 你在destinations db中安装了posgis吗?
  • @francs:是的,当然。

标签: sql postgresql


【解决方案1】:

您是否在目的地数据库中安装了 posgis?如果没有,先安装postgis。

如果你安装了 postgis 仍然有问题,尝试转储一个没有几何文件的表 并在另一个数据库中恢复它,看看问题是否仍然出现。

【讨论】:

  • pg_dump -h server1 -E UTF8 -U postgres -t "schemaname.np_points" gisurfo > D:\np_point.sql
猜你喜欢
  • 1970-01-01
  • 2020-04-07
  • 1970-01-01
  • 2019-06-12
  • 2022-01-04
  • 1970-01-01
  • 2012-08-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多