2016-11-22 7 views
0

.sqlデータベースダンプをインポートしようとしています。私はコマンドラインとPosticoのGUIで試しましたが、インポート時に何千ものエラーのようなエラーが発生します。postgresのSQLダンプインポートで多くの構文とアクセス許可のエラーが発生しました

SQLダンプは、postgres 9.4.5を実行している同僚からのものであり、SQLが有効に見えます。

私のPostgresのバージョン:アップル社に基づき のi686-りんごdarwin11-LLVM-GCC-4.2でコンパイルx86_64版 - リンゴ - ダーウィン、(GCC)4.2.1(上

のPostgreSQL 9.6.1 。 ビルド5658)(LLVM 2336.11.00を構築)、64ビットのIは、以下の輸入しようとした

psql -U postgres dbname < ~/Desktop/dbname_local_db_20161122.sql

は次にログインし、それをしよう:

psql -U postgres dbname

dbname=# \i ~/Desktop/dbname_local_db_20161122.sql

エラー:(これ以外の方法よりあります)

Password for user postgres: 
SET 
SET 
SET 
SET 
SET 
SET 
CREATE EXTENSION 
COMMENT 
ERROR: schema "public" does not exist 
ERROR: extension "citext" does not exist 
ERROR: schema "public" does not exist 
ERROR: extension "pg_trgm" does not exist 
SET 
ERROR: function "add_session_metric" already exists with same argument types 
ERROR: role "myrole" does not exist 
ERROR: function "session_metrics_partition_creation" already exists with same argument types 
ERROR: role "myrole" does not exist 
ERROR: function "session_metrics_partition_function" already exists with same argument types 
ERROR: role "myrole" does not exist 
SET 
SET 
ERROR: permission denied to create "pg_catalog.messages" 
DETAIL: System catalog modifications are currently disallowed. 
ERROR: relation "messages" does not exist 
ERROR: permission denied to create "pg_catalog.Message_id_seq" 
DETAIL: System catalog modifications are currently disallowed. 
ERROR: relation "Message_id_seq" does not exist 
ERROR: relation "Message_id_seq" does not exist 
ERROR: permission denied to create "pg_catalog.sessions_users" 

invalid command \N 
invalid command \N 
invalid command \N 
invalid command \N 
invalid command \N 
invalid command \. 
ERROR: syntax error at or near "2" 
LINE 1: 2 hello 3 1 2015-11-12 09:25:14.646-07 2015-11-12 09:25:14.64... 
ERROR: syntax error at or near "1" 
LINE 1: 1 
     ^
ERROR: relation "external_session_info_sessions" does not exist 
invalid command \. 
ERROR: syntax error at or near "2528" 
LINE 1: 2528 1 
     ^
invalid command \. 
ERROR: relation "feedback_id_seq" does not exist 
LINE 1: SELECT pg_catalog.setval('feedback_id_seq', 1, false); 

私が言ったように、SQLファイルルックス有効です。 9.4.5から9.6.1への互換性の問題を確認しましたが、表示されません。

私はPERMISSION DENIEDを見んが、私は、スーパーユーザー権限を持つユーザーpostgresなどのコマンドを実行しています:

enter image description here

答えて

0

まず、推奨される方法は、に高い(ターゲット)データベースのバージョンからpg_dumpを使用することですそのバージョンのpg_dumpは、互換性のない変更があったことを認識しており、正しく復元されるダンプを作成できるため、ダンプを作成します。

同じ名前のオブジェクトがすでに存在するデータベースにダンプを復元すると、一部のエラーは正常です。多くの場合、CREATE DATABASEステートメントを含めるには、ダンプが実際にpg_dump -Cで作成されているはずのサインです。

しかし、あなたのSQLスクリプトはひどく混乱しているようですが、それは9.4.5データベースの変更されていないダンプであるとは思えません。

pg_dumpは、pg_catalogにオブジェクトをダンプしません。このスキーマには、ダンプに含まれていないシステムオブジェクト(CREATE DATABASEによって作成されています)が含まれているだけで、スーパーユーザーでもそのスキーマ内にオブジェクトが作成されることはありません(allow_system_table_modson、 t be)。

関連する問題