Re: pg_dump and public schema

From: Paul Foerster <paul(dot)foerster(at)gmail(dot)com>
To: Олег Самойлов <splarv(at)ya(dot)ru>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_dump and public schema
Date: 2020-03-04 13:52:49
Message-ID: CABNMRRxVNY_VCZBVoO5JQvesEmzXQceuoqS7x=z6atLbUVt8Jg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I think "create database" always creates the "public" schema. So, all
is well. All you have to do is drop it after running the dump.sql
script.

Cheers,
Paul

On Wed, Mar 4, 2020 at 2:43 PM Олег Самойлов <splarv(at)ya(dot)ru> wrote:
>
> Hi all. PostgresQL 12.1. Strange behaviour with pg_dump and absent public schema.
>
> I droped public schema and I work under "username" schema.
>
> => \dn
> List of schemas
> Name | Owner
> -------+-------
> olleg | olleg
> (1 row)
>
> Dump now
>
> pg_dump -U postgres -C olleg >dump.sql
>
> --
> -- PostgreSQL database dump
> --
>
> -- Dumped from database version 12.1
> -- Dumped by pg_dump version 12.1
>
> 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;
>
> --
> -- Name: olleg; Type: DATABASE; Schema: -; Owner: olleg
> --
>
> CREATE DATABASE olleg WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'ru_RU.UTF-8' LC_CTYPE = 'ru_RU.UTF-8';
>
>
> ALTER DATABASE olleg OWNER TO olleg;
>
> \connect olleg
>
> 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;
>
> --
> -- Name: olleg; Type: SCHEMA; Schema: -; Owner: olleg
> --
>
> CREATE SCHEMA olleg;
>
>
> ALTER SCHEMA olleg OWNER TO olleg;
>
> --
> -- PostgreSQL database dump complete
> --
>
> recreate DB from the dump:
>
> psql postgres postgres -f dump.sql
>
> And now I see public schema, which must be absent.
>
> psql olleg olleg
>
> => \dn
> List of schemas
> Name | Owner
> --------+----------
> olleg | olleg
> public | postgres
> (2 rows)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hernan Jesus Gonzalez Carmona 2020-03-04 13:58:14 Re: Exportacion por lotes
Previous Message Олег Самойлов 2020-03-04 13:42:58 pg_dump and public schema