Thread: Reverting from subtables to no subtables.

Reverting from subtables to no subtables.

From
Gan Uesli Starling
Date:
I have a table which has sub-tables. I'd like to lose the
sub-tables but keep any sub-table rows which are common to
the parent table...including their primary key which is also
common to the main table.

If I DROP the subtable, will I lose all its rows? Or only
the columns not common to the parent table?

How best should I do this?

TIA,

Gan Starling
Kalamazoo MI

Re: Reverting from subtables to no subtables.

From
Tom Lane
Date:
Gan Uesli Starling <alias@starling.us> writes:
> If I DROP the subtable, will I lose all its rows?

Yes.

> How best should I do this?

Something like
    INSERT INTO parent SELECT appropriate-columns FROM ONLY child;

            regards, tom lane