Re: Add CREATE SCHEMA ... LIKE support - Mailing list pgsql-hackers

From Jim Jones
Subject Re: Add CREATE SCHEMA ... LIKE support
Date
Msg-id ae6443da-8757-4633-a3e6-4343b86638e4@uni-muenster.de
Whole thread Raw
In response to Add CREATE SCHEMA ... LIKE support  ("Matheus Alcantara" <matheusssilv97@gmail.com>)
Responses Re: Add CREATE SCHEMA ... LIKE support
List pgsql-hackers
Hi Matheus

On 06/02/2026 15:22, Matheus Alcantara wrote:
> I'd like to propose the introduction of the LIKE syntax on CREATE SCHEMA
> command with the following syntax:
>   CREATE SCHEMA <name> LIKE <source_schema> [like_options...]
> 
> Where like_options is:
>   { INCLUDING | EXCLUDING } { TABLE | INDEX | ... | ALL }
> 
> The idea of LIKE syntax is to create a new schema with all objects that
> exist on source schema like tables, indexes, sequences, functions,
> views, etc.


I generally like the idea.

One quick note:

I'm just wondering if using a similar syntax as IMPORT FOREIGN SCHEMA
would be better than creating a new one


IMPORT FOREIGN SCHEMA remote_schema
    [ { LIMIT TO | EXCEPT } ( table_name [, ...] ) ]
    FROM SERVER server_name
    INTO local_schema
    [ OPTIONS ( option 'value' [, ... ] ) ]


So EXCEPT instead of EXCLUDING and LIMIT TO instead of INCLUDING. Of
course, assuming the proposed syntax isn't already defined in the SQL
standard.

Best, Jim



pgsql-hackers by date:

Previous
From: "Matheus Alcantara"
Date:
Subject: Add CREATE SCHEMA ... LIKE support
Next
From: Chengpeng Yan
Date:
Subject: Re: Unfortunate pushing down of expressions below sort