运行 postgresql 脚本时奇怪的从左到右的箭头
Strange left-to-right arrows while running postgresql scripts
我想要 运行 大约 5000 行 postgresql 脚本。由于专业原因,我无法分享脚本的全部内容。
但我有点像这样:
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
...
ALTER TABLE ONLY public.client DROP CONSTRAINT client_pkey;
...
ALTER TABLE public.client ALTER COLUMN id DROP DEFAULT;
...
DROP SEQUENCE public.client_id_seq;
DROP TABLE public.client;
...
--
-- Name: client; Type: TABLE; Schema: public; Owner: myDB; Tablespace:
--
CREATE TABLE client (
id integer NOT NULL,
libelle character varying(255)
);
ALTER TABLE client OWNER TO myDB;
--
-- Name: client_id_seq; Type: SEQUENCE; Schema: public; Owner: myDB
--
CREATE SEQUENCE client_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE client_id_seq OWNER TO myDB;
--
-- Name: client_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: myDB
--
--
-- Data for Name: client; Type: TABLE DATA; Schema: public; Owner: myDB
--
COPY client (id, libelle) FROM stdin;
0
1 XX
247 YY
248 ZZ
\.
copy
语句有很多插入。但是每次我 运行 数据库时,我都会得到这样的东西,里面有很多从左到右的箭头:
而且我不知道如何继续。当我检查我的数据库时,整个脚本并不完全 运行。仅创建表。
请问,有什么问题吗?
PS: 我使用 Linux Debian
当您COPY FROM STDIN
看到消息时:
t=# copy s151 from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
这里的关键是
End with a backslash and a period on a line by itself
所以你的多个 >>
只是意味着一个新行已经从标准输入添加到 COPY。看到那些绝对没问题。在将 \.
放在
之前,您会在每一行看到这些
现在关于这个问题。您的脚本有错误(我 copy/pasted 其中的一部分):
t=# \! cat so.sql
CREATE TABLE client (
id integer NOT NULL,
libelle character varying(255)
);
COPY client (id, libelle) FROM stdin;
0
1 XX
247 YY
248 ZZ
\.
t=# \i so.sql
CREATE TABLE
psql:so.sql:10: ERROR: missing data for column "libelle"
CONTEXT: COPY client, line 1: "0"
添加缺失的列后(并将分隔符更改为 space 以避免从网页复制时出现制表问题):
t=# \! cat so.sql
COPY client (id, libelle) FROM stdin delimiter ' ';
0 ZZ
1 XX
247 YY
248 ZZ
\.
t=# \i so.sql
COPY 4
有效
我想要 运行 大约 5000 行 postgresql 脚本。由于专业原因,我无法分享脚本的全部内容。 但我有点像这样:
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
...
ALTER TABLE ONLY public.client DROP CONSTRAINT client_pkey;
...
ALTER TABLE public.client ALTER COLUMN id DROP DEFAULT;
...
DROP SEQUENCE public.client_id_seq;
DROP TABLE public.client;
...
--
-- Name: client; Type: TABLE; Schema: public; Owner: myDB; Tablespace:
--
CREATE TABLE client (
id integer NOT NULL,
libelle character varying(255)
);
ALTER TABLE client OWNER TO myDB;
--
-- Name: client_id_seq; Type: SEQUENCE; Schema: public; Owner: myDB
--
CREATE SEQUENCE client_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE client_id_seq OWNER TO myDB;
--
-- Name: client_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: myDB
--
--
-- Data for Name: client; Type: TABLE DATA; Schema: public; Owner: myDB
--
COPY client (id, libelle) FROM stdin;
0
1 XX
247 YY
248 ZZ
\.
copy
语句有很多插入。但是每次我 运行 数据库时,我都会得到这样的东西,里面有很多从左到右的箭头:
而且我不知道如何继续。当我检查我的数据库时,整个脚本并不完全 运行。仅创建表。 请问,有什么问题吗?
PS: 我使用 Linux Debian
当您COPY FROM STDIN
看到消息时:
t=# copy s151 from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
这里的关键是
End with a backslash and a period on a line by itself
所以你的多个 >>
只是意味着一个新行已经从标准输入添加到 COPY。看到那些绝对没问题。在将 \.
放在
现在关于这个问题。您的脚本有错误(我 copy/pasted 其中的一部分):
t=# \! cat so.sql
CREATE TABLE client (
id integer NOT NULL,
libelle character varying(255)
);
COPY client (id, libelle) FROM stdin;
0
1 XX
247 YY
248 ZZ
\.
t=# \i so.sql
CREATE TABLE
psql:so.sql:10: ERROR: missing data for column "libelle"
CONTEXT: COPY client, line 1: "0"
添加缺失的列后(并将分隔符更改为 space 以避免从网页复制时出现制表问题):
t=# \! cat so.sql
COPY client (id, libelle) FROM stdin delimiter ' ';
0 ZZ
1 XX
247 YY
248 ZZ
\.
t=# \i so.sql
COPY 4
有效