Re: DB migration : Sybase to Postgres

From: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
To: Sengottaiyan T <techsenko(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: DB migration : Sybase to Postgres
Date: 2023-05-26 10:39:04
Message-ID: CAB-JLwZdCDV6OhZyR5282svD0=mMYfHj8E7Kipk6uF-PbLyB4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Em qui., 25 de mai. de 2023 às 08:30, Sengottaiyan T <techsenko(at)gmail(dot)com>
escreveu:

> Is there an option to set novalidate constraints in postgres? In my source
> Sybase DB, table structures are not defined properly (only primary keys
> exist and no foreign key) - I'm making necessary changes on target Postgres
> DB (created tables, identifying relationship between table columns with
> respective team). After creating proper structure on target, the next step
> is to load data - I'm sure there will be a lot of errors during initial
> data load (no parent record found). How to handle it?
>
>>
>> Other options:

create all foreign keys before importing your data and do ...

This way table triggers are disabled for all users;
ALTER TABLE T1 DISABLE TRIGGER ALL; ALTER TABLE T2 DISABLE TRIGGER ALL; ALTER
TABLE T3 DISABLE TRIGGER ALL;
--Import all your data
ALTER TABLE T1 ENABLE TRIGGER ALL; ALTER TABLE T2 ENABLE TRIGGER ALL; ALTER
TABLE T3 ENABLE TRIGGER ALL;

or

This way table triggers are disabled for this session only;
SET SESSION_REPLICATION_ROLE = REPLICA;
--Import all your data
SET SESSION_REPLICATION_ROLE = ORIGIN;

Obviously if your data doesn't have correct foreign keys matching to their
parent you'll never be able to do a dump/restore properly.

Marcos

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Dunstan 2023-05-26 12:33:19 Re: Adding SHOW CREATE TABLE
Previous Message Peter J. Holzer 2023-05-26 10:17:14 Re: Having issue with SSL.