pg12中pg_dump/pg_dumpall新增选项介绍
source link: https://blog.51cto.com/u_13646489/5354096
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
pg12中pg_dump/pg_dumpall新增选项介绍
原创瀚高数据库
本文主要用于介绍与pg10.5相比,pg_dump/pg_dumpall命令的新增选项介绍。
一、pg_dump
1、新增选项
pg_dump命令主要增加了以下选项
--on-conflict-do-nothing | 此选项自动将ON CONFLICT DO NOTHING子句分配给输出INSERT语句。 必须在使用--inserts选项或--column-inserts选项指定。 | |
--extra-float-digits | 如果为此参数指定了整数值,则在使用pg_dump命令获取数据之前执行“ SET extra_float_digits =指定值”语句。 转储文件不包含SET语句。 可以指定的值的范围是-15至3。如果指定了非数字值,则将其视为0。 | |
--rows-per-insert | This option is used with the --inserts option. Multiple tuples can be inserted in a single INSERT statement. The range of values is 1 to 2,147,483,647. |
① --on-conflict-do-nothing
--
-- PostgreSQL database dump
-- -- Dumped from database version 12.4
-- Dumped by pg_dump version 12.4 ...... --
-- Name: test; Type: TABLE; Schema: public; Owner: postgres
-- CREATE TABLE public.test (
id integer NOT NULL,
name text
);
ALTER TABLE public.test OWNER TO postgres; --
-- Data for Name: test; Type: TABLE DATA; Schema: public; Owner: postgres
-- INSERT INTO public.test VALUES (1, 'Li Ming') ON CONFLICT DO NOTHING;
INSERT INTO public.test VALUES (2, 'Han Meimei') ON CONFLICT DO NOTHING;
INSERT INTO public.test VALUES (3, 'Zhang Qiang') ON CONFLICT DO NOTHING;
--
-- Name: test test_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- ALTER TABLE ONLY public.test
ADD CONSTRAINT test_pkey PRIMARY KEY (id);
--
-- PostgreSQL database dump complete
--
② --rows-per-insert
--
-- PostgreSQL database dump
-- -- Dumped from database version 12.4
-- Dumped by pg_dump version 12.4 ...... -- Name: test2; Type: TABLE; Schema: public; Owner: postgres
-- CREATE TABLE public.test2 (
id integer NOT NULL,
demark character varying(20)
);
ALTER TABLE public.test2 OWNER TO postgres; --
-- Data for Name: test2; Type: TABLE DATA; Schema: public; Owner: postgres
-- INSERT INTO public.test2 VALUES
(1, 'postgres'),
(2, 'postgres');
INSERT INTO public.test2 VALUES
(3, 'postgres'),
(4, 'postgres');
INSERT INTO public.test2 VALUES
(5, 'postgres'),
(6, 'postgres');
......
二、pg_dumpall
1、新增选项
pg_dumpall命令主要增加了以下选项
--extra-float-digits | 如果为此参数指定了整数值,则在使用pg_dump命令获取数据之前执行“ SET extra_float_digits =指定值”语句。 转储文件不包含SET语句。 可以指定的值的范围是-15至3。如果指定了非数字值,则将其视为0。 | |
--exclude-database | 在PostgreSQL 12中,添加了--exclude-database选项。 此选项指定要从备份中排除的数据库。 指定多个数据库时,请使用与psql命令相同的模式。 也可以多次指定相同的选项。 | |
--oids | 这个选项已经被移除. | |
注释已添加到输出文件中,用于用户设置(ALTER USER SET语句)和数据库设置。 |
① --exclude-database
[postgres@host1 ~]$ pg_dumpall --exclude-database='test1' -f alldump.sql
##排除多个名字相近数据库
[postgres@host1 ~]$ pg_dumpall --exclude-database='test[12]' -f alldump.sql
##排除多个名字完全不同数据库
[postgres@host1 ~]$ pg_dumpall --exclude-database='a' --exclude-database='b' -f alldump.sql
②增加的注释,以下内容部分会出现在pg_dumpall导出的文本文件中.
-- User Config {User_name}
-- Databases
-- Database {Database_name} dump
- 打赏
- 赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK