Add CREATE SCHEMA ... LIKE support
Add CREATE SCHEMA ... LIKE support
Hi hackers
I was reading the TODO wiki page and found the "Add CREATE SCHEMA ...
LIKE that copies a schema" item and I thought that it could be a good
idea to have this at core.
It's common for certain applications to have a different schema for each
customer and having a built-in way to copy an entire schema could be
useful for this use case.
I'd like to propose the introduction of the LIKE syntax on CREATE SCHEMA
command with the following syntax:
CREATE SCHEMA LIKE [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'm attaching a PoC patch that implements the LIKE syntax for tables and
indexes. I would like to start a discussion to see if this feature make
sense and if it could be useful to have at core. I have intention to add
support for more objects(sequence, functions, ...) in future patches if
It makes sense.
Thoughts?
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
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 LIKE [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
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 06/02/26 11:35, Jim Jones wrote:
>> I'd like to propose the introduction of the LIKE syntax on CREATE SCHEMA
>> command with the following syntax:
>> CREATE SCHEMA LIKE [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.
>
Yeah, it could be an option but IMHO adding the LIKE on CREATE SCHEMA
sounds more similar to what we already have for CREATE TABLE ... LIKE.
Although I prefer the CREATE SCHEMA LIKE syntax I'm open to discuss
about other syntaxes.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Marcos Pegoraro <marcos@f10.com.br>
Дата:
Em sex., 6 de fev. de 2026 às 11:22, Matheus Alcantara <matheusssilv97@gmail.com> escreveu:
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...
This feature is really cool.
Having a function to clone schemas is what we use for these cases, so it would be very interesting to have a command that replaces that function.
One observation is that you are using CREATE TABLE ... LIKE and this command does not respect some object names, like indexes and constraints.Your example idx_t1_name will clone as t1_name_idx
So the cloned schema will not be exactly the same as the source.
Maybe a rename process to match names from source to target next to CREATE TABLE LIKE would solve those cases.
regards
Marcos
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 06/02/2026 15:42, Matheus Alcantara wrote: > On 06/02/26 11:35, Jim Jones wrote: >> 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. >> > > Yeah, it could be an option but IMHO adding the LIKE on CREATE SCHEMA > sounds more similar to what we already have for CREATE TABLE ... LIKE. > > Although I prefer the CREATE SCHEMA LIKE syntax I'm open to discuss > about other syntaxes. Just to be clear, I also like the CREATE SCHEMA LIKE syntax. I was just suggesting to consider changing EXCLUDING and INCLUDING to EXCEPT and LIMIT TO, respectively. Just to make it more consistent with IMPORT FOREIGN SCHEMA, although I find INCLUDING and EXCLUDING way more intuitive :) Best, Jim
Add CREATE SCHEMA ... LIKE support
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Friday, February 6, 2026, Matheus Alcantara <matheusssilv97@gmail.com> wrote:
I'm attaching a PoC patch that implements the LIKE syntax for tables and
indexes. I would like to start a discussion to see if this feature make
sense and if it could be useful to have at core. I have intention to add
support for more objects(sequence, functions, ...) in future patches if
It makes sense.
I’d suggest you solve the functions cloning first to make sure that won’t end up being a blocker. SET clauses in particular, and “atomic” functions, seem non-trivial to deal with. Views too really, depending on the approach.
More generally maybe start with the documentation to define exactly how it should behave and what limitations it would have (i.e., it isn’t going to re-point schema references in black-box function bodies).
David J.
Re: Add CREATE SCHEMA ... LIKE support
От:
hubert depesz lubaczewski <depesz@depesz.com>
Дата:
On Fri, Feb 06, 2026 at 04:23:45PM +0100, Jim Jones wrote: > > > On 06/02/2026 15:42, Matheus Alcantara wrote: > > On 06/02/26 11:35, Jim Jones wrote: > >> 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. > >> > > > > Yeah, it could be an option but IMHO adding the LIKE on CREATE SCHEMA > > sounds more similar to what we already have for CREATE TABLE ... LIKE. > > > > Although I prefer the CREATE SCHEMA LIKE syntax I'm open to discuss > > about other syntaxes. > > Just to be clear, I also like the CREATE SCHEMA LIKE > syntax. I was just suggesting to consider changing > EXCLUDING and INCLUDING to EXCEPT and LIMIT TO, respectively. Just to > make it more consistent with IMPORT FOREIGN SCHEMA, although I find > INCLUDING and EXCLUDING way more intuitive :) The way I see it EXCLUDING and INCLUDING are for TYPES of objects (like: EXCLUDING indexes), while EXCEPT and LIMIT TO are for specific objects (EXCEPT users). Best regards, depesz
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 06/02/26 12:19, Marcos Pegoraro wrote: >> I'd like to propose the introduction of the LIKE syntax on CREATE SCHEMA >> command with the following syntax: >> CREATE SCHEMA LIKE [like_options... > > > This feature is really cool. > Having a function to clone schemas is what we use for these cases, so it > would be very interesting to have a command that replaces that function. > One observation is that you are using CREATE TABLE ... LIKE and this > command does not respect some object names, like indexes and constraints. > Your example idx_t1_name will clone as t1_name_idx > > So the cloned schema will not be exactly the same as the source. > Maybe a rename process to match names from source to target next to CREATE > TABLE LIKE would solve those cases. > Thanks for the input. I'll think about how to fix this for the next version. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 06/02/26 12:30, David G. Johnston wrote: > On Friday, February 6, 2026, Matheus Alcantara > wrote: > >> >> I'm attaching a PoC patch that implements the LIKE syntax for tables and >> indexes. I would like to start a discussion to see if this feature make >> sense and if it could be useful to have at core. I have intention to add >> support for more objects(sequence, functions, ...) in future patches if >> It makes sense. >> > > I’d suggest you solve the functions cloning first to make sure that won’t > end up being a blocker. SET clauses in particular, and “atomic” functions, > seem non-trivial to deal with. Views too really, depending on the approach. > Thanks for the call. I'll focus on these for the next version. > More generally maybe start with the documentation to define exactly how it > should behave and what limitations it would have (i.e., it isn’t going to > re-point schema references in black-box function bodies). > Good point, I'll also include some initial documentation changes on the next version. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 06/02/26 12:23, Jim Jones wrote: > > > On 06/02/2026 15:42, Matheus Alcantara wrote: >> On 06/02/26 11:35, Jim Jones wrote: >>> 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. >>> >> >> Yeah, it could be an option but IMHO adding the LIKE on CREATE SCHEMA >> sounds more similar to what we already have for CREATE TABLE ... LIKE. >> >> Although I prefer the CREATE SCHEMA LIKE syntax I'm open to discuss >> about other syntaxes. > > Just to be clear, I also like the CREATE SCHEMA LIKE > syntax. I was just suggesting to consider changing > EXCLUDING and INCLUDING to EXCEPT and LIMIT TO, respectively. Just to > make it more consistent with IMPORT FOREIGN SCHEMA, although I find > INCLUDING and EXCLUDING way more intuitive :) > The idea of INCLUDING and EXCLUDING is to specify objects that should be included/excluded, e.g INCLUDING ALL EXCLUDING INDEX EXCLUDING VIEW It seems to me that LIMIT TO and EXCEPT is more related to specify which objects you want to include/exclude e.g "EXCEPT users" (where users is a table) (While I'm writing this email, Hubert Depesz has shared a similar comment about this [1]) [1] https://www.postgresql.org/message-id/aYYKQDln_qjA_CdA%40depesz.com -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 06/02/2026 16:52, Matheus Alcantara wrote: > The idea of INCLUDING and EXCLUDING is to specify objects that should > be included/excluded, e.g INCLUDING ALL EXCLUDING INDEX EXCLUDING VIEW > > It seems to me that LIMIT TO and EXCEPT is more related to specify > which objects you want to include/exclude e.g "EXCEPT users" (where > users is a table) Oh, I see it now. It means including/excluding all tables, not specific ones. In that case I also agree that LIMIT TO and EXCEPT are not the best fit here :) Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
On 06/02/26 12:46, I wrote: >> More generally maybe start with the documentation to define exactly >> how it >> should behave and what limitations it would have (i.e., it isn’t >> going to >> re-point schema references in black-box function bodies). >> > Good point, I'll also include some initial documentation changes on > the next version. > So here is V2 with some documentation changes and also with the index name not being preserved issue that Marcos have mentioned earlier fixed. I'm still working on the function support. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Marcos Pegoraro <marcos@f10.com.br>
Дата:
Em seg., 9 de fev. de 2026 às 14:42, Matheus Alcantara <matheusssilv97@gmail.com> escreveu:
So here is V2 with some documentation changes and also with the index
name not being preserved issue that Marcos have mentioned earlier fixed.
You followed INCLUDING and EXCLUDING as CREATE TABLE LIKE does, but the problem is that on command CREATE TABLE LIKE if you EXCLUDE any of available options, which are: COMMENTS | COMPRESSION | CONSTRAINTS | DEFAULTS | GENERATED | IDENTITY | INDEXES | STATISTICS | STORAGE, the table will be created anyway, because none of them are obligatory
Now you are creating several objects and some of them are dependent, what do you do if a table depends on a TYPE or a DOMAIN but they were not included on the options list ? And more, a different TYPE or DOMAIN with that name exists but on another schema that is in the search_path ?
I think only CREATE TABLE LIKE like you did will not work as expected. Imagine something like this.
set search_path to public;
create domain i32 integer check (value > 0);
create schema a;
create table a.t1(id i32);
--create schema like should get an exception because a table cannot be created without the domains it depends.
create schema b like a excluding domain;
--then a second problem
set search_path to a;
create domain i32 integer check (value > 0);
create schema a;
create table a.t1(id i32);
--create schema like should get an exception because a table cannot be created without the domains it depends.
create schema b like a excluding domain;
--then a second problem
set search_path to a;
--create a second domain but same name. table a continues using public.i32.
create domain i32 integer check (value = 1);
--now we have two different domains, which on will be used ?
--create schema like would get an error because domain was not found on search_path or would create a table using a wrong object ?
create domain i32 integer check (value = 1);
--now we have two different domains, which on will be used ?
--create schema like would get an error because domain was not found on search_path or would create a table using a wrong object ?
create schema b like a including all;
regards
Marcos
Re: Add CREATE SCHEMA ... LIKE support
От:
Marcos Pegoraro <marcos@f10.com.br>
Дата:
Em seg., 9 de fev. de 2026 às 14:42, Matheus Alcantara <matheusssilv97@gmail.com> escreveu:So here is V2 with some documentation changes and also with the index
name not being preserved issue that Marcos have mentioned earlier fixed.
And additionally
Default is EXCLUDING ALL, right ?
create schema b like a;
It's the same as
create schema b;
right ?
regards
Marcos
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 09/02/26 18:44, Marcos Pegoraro wrote: >>> So here is V2 with some documentation changes and also with the index >>> name not being preserved issue that Marcos have mentioned earlier fixed. >> >> And additionally > Default is EXCLUDING ALL, right ? Yes > create schema b like a; > It's the same as > create schema b; > right ? > Yes too. Thanks for checking this patch. I'm preparing a reply for your previous comments. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 09/02/26 17:53, Marcos Pegoraro wrote: >> So here is V2 with some documentation changes and also with the index >> name not being preserved issue that Marcos have mentioned earlier fixed. > > > You followed INCLUDING and EXCLUDING as CREATE TABLE LIKE does, but the > problem is that on command CREATE TABLE LIKE if you EXCLUDE any of > available options, which are: COMMENTS | COMPRESSION | CONSTRAINTS | > DEFAULTS | GENERATED | IDENTITY | INDEXES | STATISTICS | STORAGE, the table > will be created anyway, because none of them are obligatory > Now you are creating several objects and some of them are dependent, what > do you do if a table depends on a TYPE or a DOMAIN but they were not > included on the options list ? I think that the simple way would to just let the error happen when creating the table. Perhaps we could add a HINT to mention that e.g INCLUDING TABLE EXCLUDING TYPE will not work if a table depends of a specific created type. Another way would be to automatic create these dependencies and not have options like TYPE or DOMAIN for example, but I think that this can limitless the LIKE options that we could have. > And more, a different TYPE or DOMAIN with > that name exists but on another schema that is in the search_path ? > I think only CREATE TABLE LIKE like you did will not work as expected. > Imagine something like this. > > set search_path to public; > create domain i32 integer check (value > 0); > create schema a; > create table a.t1(id i32); > --create schema like should get an exception because a table cannot be > created without the domains it depends. > create schema b like a excluding domain; (I think that the command would be something like create schema b like a including all excluding domain) This seems right to me. Exclude a domain if you have a table that depend on it should throw an error. It seems to me that DOMAIN and TYPE is more likely to be used with INCLUDING (e.g CREATE SCHEMA b LIKE a INCLUDING TYPE INCLUDING DOMAIN) or I'm missing something? One idea would be to have something like LIMIT TO and EXPECT to select only some tables to include/exclude. > --then a second problem > set search_path to a; > --create a second domain but same name. table a continues using public.i32. > create domain i32 integer check (value = 1); > --now we have two different domains, which on will be used ? > --create schema like would get an error because domain was not found on > search_path or would create a table using a wrong object ? > create schema b like a including all; > It will still reference public.i32 since it is what a.t1 is referencing. I think that we should only recreate the objects from the source schema, so public.i32 should still be used on table b.t1. If a.t1.id is changed to reference a.i32, so b.i32 should also be created when running create schema b like a including all; -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 09/02/2026 23:39, Matheus Alcantara wrote:
> So here is V2 with some documentation changes and also with the index
> name not being preserved issue that Marcos have mentioned earlier fixed.
Thanks for the patch!
One observation:
In a scenario where a parent table and the partitioned tables live in
different schemas, creating a schema based on the schema that contains
only the partitions arguably generates useless tables.
postgres=# CREATE SCHEMA s1;
CREATE TABLE s1.m (
city_id int NOT NULL,
logdate date NOT NULL
) PARTITION BY RANGE (logdate);
CREATE SCHEMA
CREATE TABLE
Partitions are in s2:
postgres=# CREATE SCHEMA s2;
CREATE TABLE s2.p1 PARTITION OF s1.m
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE s2.p2 PARTITION OF s1.m
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
CREATE SCHEMA
CREATE TABLE
CREATE TABLE
postgres=# CREATE SCHEMA s3 LIKE s2 INCLUDING ALL;
CREATE SCHEMA
postgres=# \d s3.p1
Table "s3.p1"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
postgres=# \d s2.p1
Table "s2.p1"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition of: s1.m FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')
I'm not saying it's wrong, but perhaps you should consider ERROR/WARN if
trying to copy a schema with "orphan" partitions
The same applies for creating schema that contains only the parent table
postgres=# CREATE SCHEMA s4 LIKE s1 INCLUDING ALL;
CREATE SCHEMA
postgres=# \d s4.m
Table "s4.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
postgres=# \d s1.m
Partitioned table "s1.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition key: RANGE (logdate)
Number of partitions: 2 (Use \d+ to list them.)
Even if parent and children live in the same schema, they become
detached in the new copy -- I'd argue that this one is a bug.
postgres=# CREATE SCHEMA s1;
CREATE TABLE s1.m (
city_id int NOT NULL,
logdate date NOT NULL
) PARTITION BY RANGE (logdate);
CREATE SCHEMA
CREATE TABLE
postgres=# CREATE TABLE s1.p1 PARTITION OF s1.m
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE s1.p2 PARTITION OF s1.m
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
CREATE TABLE
CREATE TABLE
postgres=# CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
CREATE SCHEMA
postgres=# \d s1.m
Partitioned table "s1.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition key: RANGE (logdate)
Number of partitions: 2 (Use \d+ to list them.)
postgres=# \d s2.m
Table "s2.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
postgres=# \d s1.p1
Table "s1.p1"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition of: s1.m FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')
postgres=# \d s2.p1
Table "s2.p1"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Comments are also being ignored, but I guess it was already mentioned
upthread:
postgres=# \dt+ s2.t
List of tables
-[ RECORD 1 ]-+----------
Schema | s2
Name | t
Type | table
Owner | jim
Persistence | permanent
Access method | heap
Size | 0 bytes
Description |
postgres=# \dt+ s1.t
List of tables
-[ RECORD 1 ]-+----------
Schema | s1
Name | t
Type | table
Owner | jim
Persistence | permanent
Access method | heap
Size | 0 bytes
Description | foo
Thanks!
Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 10/02/2026 11:09, Jim Jones wrote:
> In a scenario where a parent table and the partitioned tables live in
> different schemas, creating a schema based on the schema that contains
> only the partitions arguably generates useless tables.
> The same applies for creating schema that contains only the parent table
> Even if parent and children live in the same schema, they become
> detached in the new copy -- I'd argue that this one is a bug.
> Comments are also being ignored, but I guess it was already mentioned
> upthread:
I also just noticed that UNLOGGED tables are cloned as normal tables:
postgres=# CREATE SCHEMA s1;
CREATE UNLOGGED TABLE s1.t(c int);
CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
CREATE SCHEMA
CREATE TABLE
CREATE SCHEMA
postgres=# \d s1.t
Unlogged table "s1.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
postgres=# \d s2.t
Table "s2.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
Adding this to collectSchemaTablesLike in schemacmds.c could do the trick:
newRelation->relpersistence = classForm->relpersistence;
Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
От:
Marcos Pegoraro <marcos@f10.com.br>
Дата:
Em ter., 10 de fev. de 2026 às 07:09, Jim Jones <jim.jones@uni-muenster.de> escreveu:
Even if parent and children live in the same schema, they become
detached in the new copy -- I'd argue that this one is a bug.
I think the approach will fail at some point if you keep using CREATE TABLE LIKE, because so many things will be incomplete or at least strange, that you'll have to redo many of them.
Sequence values will be shared with the old table.Constraints/Indexes names will have to be renamed.
Partitioned tables will have to be attached.
Foreign Keys are not created either.
These are the ones we've found so far, but other inconsistencies will certainly appear.
So I don't know if CREATE TABLE LIKE is the best way to do this work.
regards
Marcos
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 10/02/2026 12:52, Marcos Pegoraro wrote: > I think the approach will fail at some point if you keep using CREATE > TABLE LIKE, because so many things will be incomplete or at least > strange, that you'll have to redo many of them. > Sequencevalues will be shared with the old table. > Constraints/Indexes names will have to be renamed. > Partitioned tables will have to be attached. > Foreign Keys are not created either. Quite right. Either we draw a clear line here, or it will be a tough nut to crack. Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
Thank you for all the comments, they were very helpful!
I'll address all previous comments on this email.
> In a scenario where a parent table and the partitioned tables live in
> different schemas, creating a schema based on the schema that contains
> only the partitions arguably generates useless tables.
> ...
> I'm not saying it's wrong, but perhaps you should consider ERROR/WARN if
> trying to copy a schema with "orphan" partitions
>
I've fixed this by adding a WARNING message and skipping the table
partition.
On this new version of the patch I've also added support for FK's and it
has the same behaviour, if a FK reference a table outside from the
source schema the FK will not be created.
I think that any object that reference an object outside of the source
schema should be skipped. It fells more safe to me to avoid sharing the
same object by multiple schemas.
> The same applies for creating schema that contains only the parent table
> ...
> Even if parent and children live in the same schema, they become
> detached in the new copy -- I'd argue that this one is a bug.
>
I've added support for partitioned tables on this new version. Although
this works for the test cases that I've added on create_schema.sql (make
check is also happy) I'm not sure if it's the best way to do it. On
getPartitionBoundSpec() I get PartitionBoundSpec from a given partitiond
oid as a string and then call stringToNode to actually generate a
PartitionBoundSpec. The problem IIUC is that fields like lowerdatums,
upperdatums and listdatums are already transformed so when
transformPartitionBoundValue() call transformExpr() the Node* will
already be transformed (e.g PartitionRangeDatum vs T_A_Const) and it
will fail on switch (nodeTag(Node))
I fixed this by adding a is_transformed field on PartitionBoundSpec and
set it to true on getPartitionBoundSpec(). Hash partition bounds only
have int values (modulus and remainder) and it shows to be required to
still do the transformation for this case.
When I was writing this email I've noticed that PartitionSpec need the
same workaround for partition keys that are expressions. I want to study
more the code to understand how we could properly fix this. Any idea is
welcome.
> Comments are also being ignored, but I guess it was already mentioned
> upthread:
>
It should work... I'll investigate this.
> I also just noticed that UNLOGGED tables are cloned as normal tables:
> ...
> Adding this to collectSchemaTablesLike in schemacmds.c could do the trick:
> newRelation->relpersistence = classForm->relpersistence;
>
I've also fixed this.
> > I think the approach will fail at some point if you keep using CREATE
> > TABLE LIKE, because so many things will be incomplete or at least
> > strange, that you'll have to redo many of them.
> > Sequencevalues will be shared with the old table.
> > Constraints/Indexes names will have to be renamed.
> > Partitioned tables will have to be attached.
> > Foreign Keys are not created either.
>
> Quite right. Either we draw a clear line here, or it will be a tough nut
> to crack.
>
The idea is not to use CREATE TABLE LIKE for all scenarios. Sorry if I
was not clear about to mention this.
As CreateSchemaCommand() use ProcessUtility() to process the
schema_element's of CREATE SCHEMA the overall idea of adding support for
LIKE was to generate a bunch of parsenodes that re-create the elements
of the source schema into the new schema and append it on this list of
schema_elements.
I think that using CREATE TABLE LIKE is the simple way to do this for
normal tables without complex data types but it certanately will not
work for all kind of objects that a schema can have. For example, on FK
I've generated a AlterTableStmt to include a FK on a table after it is
created. For domains for another case I think it would need to generate
a CreateDomainStmt.
I also want to mention that I don't think that we would be able to
properly re-created 100% all objects from the source schema into the new
schema. Some objects will be hard to copy and can still generate bougy
objects like functions for example as David mention on [1] (we can
support some kind of functions but some others will be hard).
Another issue is to handle complex relations like the following:
- Function A returns a boolean type
- Custom DOMAIN type call function A on CHECK constraint
- Function B return/use a type of custom DOMAIN
What we should create first? It can have functions that depends on
domains, so domains should be created first, but it can also have
domains that depends on functions, so functions would need to be created
first. This would be trick to fix.
But I still think that we could have support for some kind of objects. I
think that the following would be a good start point:
- tables
- partitioned tables
- indexes
- fks
- sequences
- types
For more complex scenarios we could document the limitation and perhaps
try to including WARNING's messages to mention these limitations when
re-creating a schema.
Overall, on this new patch version I've fixed/added the following:
- Index names are preserved on the new schema
- FK's are created on the new schema
- Support for partitioned tables
- More documentation (all documentation is on 0004)
Know issues remaining:
- Comment's are not being created
- Sequence of SERIAL columns are shared
- Workaround with is_transformed field
- Certanately a bunch of other things...
Thgouths?
[1] https://www.postgresql.org/message-id/CAKFQuwZFAkGMoV0fLtf%2BHJL4_cwivz0Vqfk1r5SemUZvNNfxkg%40mail.gmail.com
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Wednesday, February 11, 2026, Matheus Alcantara <matheusssilv97@gmail.com> wrote:
I also want to mention that I don't think that we would be able to
properly re-created 100% all objects from the source schema into the new
schema. Some objects will be hard to copy and can still generate bougy
objects like functions for example as David mention on [1] (we can
support some kind of functions but some others will be hard).
Another issue is to handle complex relations like the following:
- Function A returns a boolean type
- Custom DOMAIN type call function A on CHECK constraint
- Function B return/use a type of custom DOMAIN
What we should create first? It can have functions that depends on
domains, so domains should be created first, but it can also have
domains that depends on functions, so functions would need to be created
first. This would be trick to fix.
This is a solved problem in pg_dump, no? It understands and follows the dependency graph. Even allows schema-only dumps.
David J.
Re: Add CREATE SCHEMA ... LIKE support
От:
"Matheus Alcantara" <matheusssilv97@gmail.com>
Дата:
On Wed Feb 11, 2026 at 5:51 PM -03, David G. Johnston wrote: >> I also want to mention that I don't think that we would be able to >> properly re-created 100% all objects from the source schema into the new >> schema. Some objects will be hard to copy and can still generate bougy >> objects like functions for example as David mention on [1] (we can >> support some kind of functions but some others will be hard). >> >> Another issue is to handle complex relations like the following: >> - Function A returns a boolean type >> - Custom DOMAIN type call function A on CHECK constraint >> - Function B return/use a type of custom DOMAIN >> >> What we should create first? It can have functions that depends on >> domains, so domains should be created first, but it can also have >> domains that depends on functions, so functions would need to be created >> first. This would be trick to fix. >> > > This is a solved problem in pg_dump, no? It understands and follows the > dependency graph. Even allows schema-only dumps. > Yes, I think so. I was actually planning to look at pg_dump code to see what we can reuse to re-create the objects from source schema into the new schema. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 11/02/2026 21:24, Matheus Alcantara wrote:
> I've fixed this by adding a WARNING message and skipping the table
> partition.
Nice! The system now issues a WARNING if the parent table lives in a
different schema
CREATE SCHEMA s3 LIKE s2 INCLUDING ALL;
WARNING: skipping partition "s2.p1" because its parent table is in
schema "s1"
I'm wondering if the same should apply for a schema containing only the
parent table. Currently, it creates a partitioned table with 0 partitions:
CREATE SCHEMA s1;
CREATE TABLE s1.m (
city_id int NOT NULL,
logdate date NOT NULL
) PARTITION BY RANGE (logdate);
CREATE SCHEMA s2;
CREATE TABLE s2.p1 PARTITION OF s1.m
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE s2.p2 PARTITION OF s1.m
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
CREATE SCHEMA s3 LIKE s1 INCLUDING ALL;
\d s3.m
Partitioned table "s3.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition key: RANGE (logdate)
Number of partitions: 0
\d s1.m
Partitioned table "s1.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition key: RANGE (logdate)
Number of partitions: 2 (Use \d+ to list them.)
> On this new version of the patch I've also added support for FK's and it
> has the same behaviour, if a FK reference a table outside from the
> source schema the FK will not be created.
>
> I think that any object that reference an object outside of the source
> schema should be skipped. It fells more safe to me to avoid sharing the
> same object by multiple schemas.
Foreign keys also seem to work now:
CREATE SCHEMA s1;
CREATE TABLE s1.p (
id int PRIMARY KEY,
txt text NOT NULL
);
CREATE TABLE s1.c (
id int PRIMARY KEY,
p_id int REFERENCES s1.p(id)
);
CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
\d s2.p
Table "s2.p"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
txt | text | | not null |
Indexes:
"p_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "s2.c" CONSTRAINT "c_p_id_fkey" FOREIGN KEY (p_id) REFERENCES
s2.p(id)
\d s2.c
Table "s2.c"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
p_id | integer | | |
Indexes:
"c_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"c_p_id_fkey" FOREIGN KEY (p_id) REFERENCES s2.p(id)
A WARNING is now issued if a foreign key references to a table in a
different schema than the one being used as a template:
CREATE SCHEMA s1;
CREATE TABLE s1.p (
id int PRIMARY KEY,
txt text NOT NULL
);
CREATE SCHEMA s2;
CREATE TABLE s2.c (
id int PRIMARY KEY,
p_id int REFERENCES s1.p(id)
);
CREATE SCHEMA s3 LIKE s2 INCLUDING ALL;
WARNING: skipping foreign key "c_p_id_fkey" on table "s2.c" because it
references table "s1.p" in a different schema
\d s3.c
Table "s3.c"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | not null |
p_id | integer | | |
Indexes:
"c_pkey" PRIMARY KEY, btree (id)
>
>> The same applies for creating schema that contains only the parent table
>> ...
>> Even if parent and children live in the same schema, they become
>> detached in the new copy -- I'd argue that this one is a bug.
>>
>
> I've added support for partitioned tables on this new version. Although
> this works for the test cases that I've added on create_schema.sql (make
> check is also happy) I'm not sure if it's the best way to do it. On
> getPartitionBoundSpec() I get PartitionBoundSpec from a given partitiond
> oid as a string and then call stringToNode to actually generate a
> PartitionBoundSpec. The problem IIUC is that fields like lowerdatums,
> upperdatums and listdatums are already transformed so when
> transformPartitionBoundValue() call transformExpr() the Node* will
> already be transformed (e.g PartitionRangeDatum vs T_A_Const) and it
> will fail on switch (nodeTag(Node))
Schemas containing both parent and children are now copied as expected.
CREATE SCHEMA s1;
CREATE TABLE s1.m (
city_id int NOT NULL,
logdate date NOT NULL
) PARTITION BY RANGE (logdate);
CREATE TABLE s1.p1 PARTITION OF s1.m
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE s1.p2 PARTITION OF s1.m
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
\d s2.m
Partitioned table "s2.m"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition key: RANGE (logdate)
Number of partitions: 2 (Use \d+ to list them.)
\d s2.p1
Table "s2.p1"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
city_id | integer | | not null |
logdate | date | | not null |
Partition of: s2.m FOR VALUES FROM ('2006-02-01') TO ('2006-03-01')
> I fixed this by adding a is_transformed field on PartitionBoundSpec and
> set it to true on getPartitionBoundSpec(). Hash partition bounds only
> have int values (modulus and remainder) and it shows to be required to
> still do the transformation for this case.
>
> When I was writing this email I've noticed that PartitionSpec need the
> same workaround for partition keys that are expressions. I want to study
> more the code to understand how we could properly fix this. Any idea is
> welcome.
>
>> Comments are also being ignored, but I guess it was already mentioned
>> upthread:> It should work... I'll investigate this.
I believe it's an unrelated bug at expandTableLikeClause(). I opened a
new thread for this:
https://www.postgresql.org/message-id/e08cb97f-0364-4002-9cda-3c16b42e4136%40uni-muenster.de
>> I also just noticed that UNLOGGED tables are cloned as normal tables:
>> ...
>> Adding this to collectSchemaTablesLike in schemacmds.c could do the trick:
>> newRelation->relpersistence = classForm->relpersistence;
>>
>
> I've also fixed this.
Nice. It now also works!
CREATE SCHEMA s1;
CREATE UNLOGGED TABLE s1.t(c int);
CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
\d s2.t
Unlogged table "s2.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
\d s1.t
Unlogged table "s1.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
> I also want to mention that I don't think that we would be able to
> properly re-created 100% all objects from the source schema into the new
> schema. Some objects will be hard to copy and can still generate bougy
> objects like functions for example as David mention on [1] (we can
> support some kind of functions but some others will be hard).
Yeah. I also think we need to draw a line at some point and document all
limitations. Specially regarding cross-schema dependencies, where it
might skip the dependencies for some objects (e.g. partitioned tables)
but works with others, e.g. functions in check constraints:
CREATE SCHEMA s1;
CREATE OR REPLACE FUNCTION s1.f(text)
RETURNS boolean LANGUAGE sql AS
$$ SELECT $1 <> ''; $$;
CREATE SCHEMA s2;
CREATE TABLE s2.t (id int, name text CHECK (s1.f(name)));
CREATE SCHEMA s3 LIKE s2 INCLUDING ALL;
\d s2.t
Table "s2.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
name | text | | |
Check constraints:
"t_name_check" CHECK (s1.f(name))
\d s3.t
Table "s3.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
name | text | | |
Check constraints:
"t_name_check" CHECK (s1.f(name))
I'll take a look at the code later today or tomorrow.
Thanks!
Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
От:
"Matheus Alcantara" <matheusssilv97@gmail.com>
Дата:
Thanks for testing this patch! On Thu Feb 12, 2026 at 7:45 AM -03, Jim Jones wrote: >> I've fixed this by adding a WARNING message and skipping the table >> partition. > > Nice! The system now issues a WARNING if the parent table lives in a > different schema > > CREATE SCHEMA s3 LIKE s2 INCLUDING ALL; > WARNING: skipping partition "s2.p1" because its parent table is in > schema "s1" > > I'm wondering if the same should apply for a schema containing only the > parent table. Currently, it creates a partitioned table with 0 partitions: > Yes, it sounds a good idea to log a WARNING to mention that table partitions are on different schema and only the parent table will be copied in this case. I'll include this on the next version. >>> Comments are also being ignored, but I guess it was already mentioned >>> upthread:> It should work... I'll investigate this. > I believe it's an unrelated bug at expandTableLikeClause(). I opened a > new thread for this: > > https://www.postgresql.org/message-id/e08cb97f-0364-4002-9cda-3c16b42e4136%40uni-muenster.de > Thanks, I'll find some time to review this patch. >> I also want to mention that I don't think that we would be able to >> properly re-created 100% all objects from the source schema into the new >> schema. Some objects will be hard to copy and can still generate bougy >> objects like functions for example as David mention on [1] (we can >> support some kind of functions but some others will be hard). > > > Yeah. I also think we need to draw a line at some point and document all > limitations. Specially regarding cross-schema dependencies, where it > might skip the dependencies for some objects (e.g. partitioned tables) > but works with others, e.g. functions in check constraints: > > CREATE SCHEMA s1; > CREATE OR REPLACE FUNCTION s1.f(text) > RETURNS boolean LANGUAGE sql AS > $$ SELECT $1 <> ''; $$; > > CREATE SCHEMA s2; > CREATE TABLE s2.t (id int, name text CHECK (s1.f(name))); > > CREATE SCHEMA s3 LIKE s2 INCLUDING ALL; > > \d s2.t > Table "s2.t" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > id | integer | | | > name | text | | | > Check constraints: > "t_name_check" CHECK (s1.f(name)) > > \d s3.t > Table "s3.t" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > id | integer | | | > name | text | | | > Check constraints: > "t_name_check" CHECK (s1.f(name)) > Definitely agree. I've started to add some documentation about the behaviour and limitations on the v3 version but I still need to include more information. I'm wondering if in this case we should not include the check constraint since it reference a function from a different schema and have the same behaviour that we have for partitioned tables and FK's. It seems to me that skipping any kind of object that reference another object from a different schema would be more resanable. Having this behaviour for just some objects(e.g partitioned tables, FKs) seems a bit confusing, what do you think? > I'll take a look at the code later today or tomorrow. > Thank you! -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 12/02/2026 13:43, Matheus Alcantara wrote: > Definitely agree. I've started to add some documentation about the > behaviour and limitations on the v3 version but I still need to include > more information. > > I'm wondering if in this case we should not include the check constraint > since it reference a function from a different schema and have the same > behaviour that we have for partitioned tables and FK's. > > It seems to me that skipping any kind of object that reference another > object from a different schema would be more resanable. Having this > behaviour for just some objects(e.g partitioned tables, FKs) seems a > bit confusing, what do you think? If we conclude that it isn't worth adding any references to other schemas, I believe we must let the user decide if the tables should be created or not, since it would IMHO significantly reduce the range of use cases for which this feature can be employed. Since we're brainstorming, imagine the following scenario: A schema contains hundreds of tables referencing objects in other schemas and the user creates a new schema based on it. Currently, the problematic tables are created only partially, and the user is warned about what has gone wrong. Now, the user has to decide if the incomplete tables are worth keeping or not, and in case they're not, DROP them manually. What do you think about introducing a clause similar to COPY .. ON_ERROR? Something like CREATE SCHEMA s2 LIKE s1 INCLUDING ALL ON ERROR [SKIP/IGNORE/ ...] CREATE SCHEMA s2 LIKE s1 INCLUDING ALL ON ERROR [STOP/ABORT/...] Best, Jim
Re: Add CREATE SCHEMA ... LIKE support
От:
Marcos Pegoraro <marcos@f10.com.br>
Дата:
Em qui., 12 de fev. de 2026 às 13:40, Jim Jones <jim.jones@uni-muenster.de> escreveu:
What do you think about introducing a clause similar to COPY .
A schema can have thousands of objects, and that schema will be ok only if all objects are copied.
It will be very difficult for the user to see which ones were not copied.
I think the whole process should be done or raise an exception. Ignoring items I don't think is fine.
I think the whole process should be done or raise an exception. Ignoring items I don't think is fine.
regards
Marcos
Re: Add CREATE SCHEMA ... LIKE support
От:
Álvaro Herrera <alvherre@kurilemu.de>
Дата:
Hello, On 2026-Feb-06, Matheus Alcantara wrote: > I was reading the TODO wiki page and found the "Add CREATE SCHEMA ... > LIKE that copies a schema" item and I thought that it could be a good > idea to have this at core. Egad. A TODO thing from way back which probably doesn't make much sense nowadays, or at least so I think. This whole thing seems like a giant can of worms, and I'm not sure it's a good idea to add DDL syntax for it. I didn't read the thread in detail, but the discussions downthread about adding weird clauses to CREATE SCHEMA look quite worrisome. Why not try to devise a way to reuse the DDL functions being proposed in various nearby pgsql-hackers threads? There are a bunch of such patches in the commitfest already; it's probably easy to have a way to generate a list of objects in a schema, then call the DDL function corresponding to each object type for each object, and then you're done. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Re: Add CREATE SCHEMA ... LIKE support
От:
"Matheus Alcantara" <matheusssilv97@gmail.com>
Дата:
On Thu Feb 12, 2026 at 5:38 PM -03, Álvaro Herrera wrote: >> I was reading the TODO wiki page and found the "Add CREATE SCHEMA ... >> LIKE that copies a schema" item and I thought that it could be a good >> idea to have this at core. > > Egad. A TODO thing from way back which probably doesn't make much sense > nowadays, or at least so I think. > > This whole thing seems like a giant can of worms, and I'm not sure it's > a good idea to add DDL syntax for it. I didn't read the thread in > detail, but the discussions downthread about adding weird clauses to > CREATE SCHEMA look quite worrisome. > > Why not try to devise a way to reuse the DDL functions being proposed in > various nearby pgsql-hackers threads? There are a bunch of such patches > in the commitfest already; it's probably easy to have a way to generate > a list of objects in a schema, then call the DDL function corresponding > to each object type for each object, and then you're done. IIUC you'are suggesting to have something like pg_get_schema_ddl() which would return the CREATE SCHEMA command and the DDL command used to create the objects within the schema? If that's the point it's sounds a better way to implement this. At some point when I was writing the last version I thought that if we have these patches already merged this LIKE clause could be implemented easier but I was thinking to reuse with the LIKE clause, but creating a function to get a schema definition seems more reasonable and follow the same pattern for these other patches. Thanks for the comments. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Matheus Alcantara <matheusssilv97@gmail.com>
Дата:
On 12/02/26 17:27, Marcos Pegoraro wrote: > Em qui., 12 de fev. de 2026 às 13:40, Jim Jones > escreveu: > >> What do you think about introducing a clause similar to COPY . > > > A schema can have thousands of objects, and that schema will be ok only if > all objects are copied. > It will be very difficult for the user to see which ones were not copied. > > I think the whole process should be done or raise an exception. Ignoring > items I don't think is fine. > Yeah, I agree. I think that we can be less restrictive. The behavior can be to allow reference objects from schemas different than source and in case some error happen it stop the process. This behavior should be documented. In case of e.g table partitions which the parent is in different schema the overlap error will happen and the the process will stop. For another cases like types in different schema it will work normally. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: Add CREATE SCHEMA ... LIKE support
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 13/02/2026 22:15, Matheus Alcantara wrote: > Yeah, I agree. I think that we can be less restrictive. The behavior can > be to allow reference objects from schemas different than source and in > case some error happen it stop the process. This behavior should be > documented. The more I think about it, the more it seems like the safest approach. As I mentioned upthread, the user might otherwise end up with pretty much useless tables and the pleasure of having to drop them manually :) > In case of e.g table partitions which the parent is in different schema > the overlap error will happen and the the process will stop. For another > cases like types in different schema it will work normally. +1 Best, Jim