Relation wide 'LIKE' clause - Mailing list pgsql-hackers

From Georgios
Subject Relation wide 'LIKE' clause
Date
Msg-id SLskGbTKe5ED2GWROv1jH-GZFthYD2XXvkFAcx_IL-QxBRiS_XnmqBC7ohnzu5U0-s876eebwteHXNNfyDLKGNzQlpa9E8ZebiwgP1l8n2M=@protonmail.com
Whole thread Raw
Responses Re: Relation wide 'LIKE' clause  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Hi,

Postgres create table statement supports `LIKE source_table [like_option... ]`
to specify `a table from which the new table automatically copies all column
names, their data types, and their not-null constraints.` according to
documentation [1].

I am wondering if a similar clause would make sense to copy relation wide
settings. For example consider a relation created like this:

`CREATE TABLE source_table ([column, ...]) USING customam WITH (storage_parameter1 = value1, ... )`

Maybe a statement similar to:

`CREATE TABLE target LIKE source_table`

which should be equivalent to:

`CREATE TABLE target (LIKE source_table INCLUDING ALL) USING customam WITH (storage_parameter1 = value1, ...)`

can be usefull as a syntactic shortcut. Maybe the usefulness of such sortcut
becomes a bit more apparent if one considers that custom access methods can
offer a diversity of storage parameters that interact both at relation and
column level, especially when the source relation is column oriented.

If the possibility for such a statment is not discarded, a patch can be readily
provided.

Cheers,
//Georgios

[1] https://www.postgresql.org/docs/13/sql-createtable.html




pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: typos in comments referring to macros
Next
From: Amit Kapila
Date:
Subject: Re: typos in comments referring to macros