Giter Club home page Giter Club logo

Comments (6)

darold avatar darold commented on September 28, 2024

Hi,

Yes this is right, system auto-generated constraint are not exported, just because they are also auto-generated with PostgreSQL. Is there's any constraint that you think must be exported and that are not?

Best regards,

from ora2pg.

mrojasaquino avatar mrojasaquino commented on September 28, 2024

Well, problem is that those CHECKS where created by the user in Oracle, but as they assigned no name, Oracle created a name. For example, creating a table in Oracle this way

create table myTable (
  record_id number(10) not null,
  is_active char(1) check (is_active in ('Y', 'N'))
);

with or2pg I get

CREATE TABLE mytable (
    record_id numeric(10) NOT NULL,
    is_active char(1)
);

and the CHECK constraint does not show up :(

Best regards.

from ora2pg.

darold avatar darold commented on September 28, 2024

That's right this kind constraint was not exported, it is not fixed in commit c4df0c4. There's still some work to do to export those constraints into the create statement instead of ALTER command.

Thanks for your report.

from ora2pg.

mrojasaquino avatar mrojasaquino commented on September 28, 2024

Thanks to you for your attention to this one, and glad to being helping :)

Regards.

from ora2pg.

mrojasaquino avatar mrojasaquino commented on September 28, 2024

If it is of any help, I've used this SQL to get all the CHECK constraints, even the ones with SYS_ on the name:

drop table const_check;
create table const_check asselect constraint_name, table_name, to_lob(search_condition) as condition
  from user_constraints
  where constraint_type = 'C';
select * from const_check where condition not like '%NULL';
select 'alter table ' || table_name ||' add constraint '|| 
  constraint_name ||' CHECK('||condition||');'from const_check
where table_name not like 'BIN%'and condition not like '%NULL' and constraint_name like 'SYS_%';

from ora2pg.

darold avatar darold commented on September 28, 2024

Ora2Pg use this one:

SELECT CONSTRAINT_NAME, R_CONSTRAINT_NAME, SEARCH_CONDITION, DELETE_RULE, DEFERRABLE, DEFERRED, R_OWNER, TABLE_NAME ,OWNER
FROM ALL_CONSTRAINTS WHERE CONSTRAINT_TYPE='C' AND STATUS='ENABLED'

the previous bug comes from the additional condition: AND GENERATED != 'GENERATED NAME', this is what I'd removed from the SQL query.

from ora2pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.