0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pgadmin4 でエラーになり、psql で取り込める sql ファイル

Last updated at Posted at 2023-05-07

Query Tool で、sql ファイルを開き実行するとエラーになります。

image.png

エラーメッセージ

ERROR:  syntax error at or near "t3463"
LINE 47: t3463 東広島 92513 2001-06-12
         ^ 

SQL state: 42601
Character: 1070

SQL ファイル

may0704.sql
--
-- PostgreSQL database dump
--

-- Dumped from database version 15.2 (Ubuntu 15.2-1)
-- Dumped by pg_dump version 15.2 (Ubuntu 15.2-1)

-- Started on 2023-05-07 11:21:18 JST

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- TOC entry 214 (class 1259 OID 20742)
-- Name: cities; Type: TABLE; Schema: public; Owner: scott
--

CREATE TABLE public.cities (
    id character varying(10) NOT NULL,
    name text,
    population integer,
    date_mod date
);


ALTER TABLE public.cities OWNER TO scott;

--
-- TOC entry 3339 (class 0 OID 20742)
-- Dependencies: 214
-- Data for Name: cities; Type: TABLE DATA; Schema: public; Owner: scott
--

COPY public.cities (id, name, population, date_mod) FROM stdin;
t3463	東広島	92513	2001-06-12
t3464		93167	2001-09-29
t3465	尾道	95419	2001-03-18
t3466	竹原	82314	2001-02-21
t3467	三次	76152	2001-08-16
t3468	大竹	37541	2001-07-07
t3469	府中	46518	2001-10-09
\.


-- Completed on 2023-05-07 11:21:18 JST

--
-- PostgreSQL database dump complete
--

psql で実行した結果

$ psql -U scott city < may0704.sql 
SET
SET
SET
SET
SET
 set_config 
------------
 
(1 row)

SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
COPY 7

sql ファイルの作成方法

pgadmin4 のバックアップで作成しました。
Format を plain にしました。

image.png

ファイルは次の場所に出来ました。
ユーザーが test@test.com の場合です。

/var/lib/pgadmin/storage/test_test.com
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?