Re: About the CREATE TABLE LIKE indexes vs constraints issue

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: About the CREATE TABLE LIKE indexes vs constraints issue
Дата
Msg-id 16267.1261610957@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: About the CREATE TABLE LIKE indexes vs constraints issue  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes:
> Honestly, I've never used LIKE in a table definition aside from one-off
> design experiments. For that kind of thing, what I want is to just get
> everything (except perhaps FKs if the above situation applies), and I
> adjust it from there. Are there people out there who use LIKE in their
> production schema files?

The only concrete application I've heard of for LIKE is to create
something that is going to be part of a partitioned table later.
That is, instead of
create table partition23 () inherits (partition_parent);

you do
create table partition23 (like partition_parent);...alter table partition23 inherit partition_parent;

The advantage of the latter is you can tweak the new partition
(eg, load data into it) before you make it a live part of the
partition set.

So in this context it's entirely likely that people would be using
LIKE in scripted procedures.  However, it's not immediately obvious
to me whether the current definitions of the LIKE options are well
suited to this application.  The lack of any support for copying
foreign keys seems a bit questionable for instance.  Now if you plan
a bulk load before taking the partition live, maybe you'd not want
to enable foreign key checks till after --- but the same would hold
for indexes, so why is there an option to copy one but not the other?
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Removing pg_migrator limitations
Следующее
От: Greg Williamson
Дата:
Сообщение: Re: About the CREATE TABLE LIKE indexes vs constraints issue