darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
991 stars 342 forks source link

[Oracle] NOT NULL constraint shows twice in the exported schema #1639

Closed shubham-yb closed 11 months ago

shubham-yb commented 1 year ago

Hi Team, If we have a not null constraint on any column in Oracle, the constraint shows up twice. Once in the table definition and once as an alter table statement.

Source schema:

CREATE TABLE not_null_check (
    id int ,
    first_name VARCHAR(50) not null,
    last_name VARCHAR(50) not null
);

Table.sql

CREATE TABLE not_null_check (
        id numeric(38),
        first_name varchar(50) NOT NULL,
        last_name varchar(50) NOT NULL
) ;

CONSTRAINTS_table.sql

ALTER TABLE not_null_check ALTER COLUMN FIRST_NAME SET NOT NULL;
ALTER TABLE not_null_check ALTER COLUMN LAST_NAME SET NOT NULL;

I understand that this does not affect the migration in any way. Adding the ticket just in case.

darold commented 11 months ago

Yes, this is intentional. The reason is to have the CONSTRAINT_table.sql file containing all constraints.