Relation wide 'LIKE' clause

From: Georgios <gkokolatos(at)protonmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Relation wide 'LIKE' clause
Date: 2020-06-10 09:42:35
Message-ID: SLskGbTKe5ED2GWROv1jH-GZFthYD2XXvkFAcx_IL-QxBRiS_XnmqBC7ohnzu5U0-s876eebwteHXNNfyDLKGNzQlpa9E8ZebiwgP1l8n2M=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-06-10 09:49:28 Re: typos in comments referring to macros
Previous Message John Naylor 2020-06-10 09:17:31 typos in comments referring to macros