I have a table "company" and another named "school" ("school" table inherits "company"). Most of the data is community generated and sometimes a cleaning is needed. I would like to be able to "transfer" a row from the company table to the school table without modifying its ID (because there could be some foreign keys linked to it).

Is there a clean way to do this ?

Thanks for your help.


You can use this method (assuming both tables have same columns in same order):

with T as (delete from only company where id=? returning *) 
    insert into school select * from T

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.