Hi,
On Wed, Jan 11, 2023 at 09:07:08AM +0000, ROCHER Julien wrote:
>
> I don’t expect the --exclude-schema flag (-N) to restore chosen schema with
> pgrestore<https://docs.postgresql.fr/11/app-pgrestore.html> tool, but it
> actually tries to create the schema then its table. I deliberately keep the
> same db name in the below example because this is actually what I’m trying to
> do (restore a dump from a similar db but excluding some already existing
> schemas on it), but I guess you don’t need to deal with this detail. Did I
> misunderstand this command ?
You didn't, but made an error in how SQL object names work:
> ➜ ~ psql -U julien -W -p 5432 -d postgres -c "create schema schemaA; create schema schemaB;"
this creates schemaa and schemab, not schemaA and schemaB. If you want objects
to be case sensitive at the SQL level, you need to double quote identifiers,
like "schemaB".
> ➜ ~ pg_restore -p 5432 -W -d postgres --verbose -N schemaB dump.sql
this on the other hand is a command line utility, and will use the given case
(and properly quote identifers at the SQL leve), so it means "schemaB" which
isn't found and thus not filtered.