Default settings for the export, table definitions will have ddl for primary key and unique index, causes error when installing table
daust opened this issue · comments
It is just a nuisance, the export of tables will create ddl statements for the primary key and the supporting unique index. The index definition should be left out.
-- #111 Default settings for the export, table definitions will have ddl for primary key and unique index, causes error when installing table
-- can only be done when the unique index is created BEFORE the constraints
-- => exlude constraints by default, then add constraints through conf/opal-export.conf file
--DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS', FALSE);
it is not perfect and quite verbose ... but this is the only way that the generated DDL creates the index first ... so that it can be picked up by the add constraint
statement.
Can be configured manually in an existing configuration as well:
conf/opal-export.conf
:
# #111 Default settings for the export, table definitions will have ddl for primary key and unique index, causes error when installing table
# can only be done when the unique index is created BEFORE the constraints
# => exlude constraints by default, then add constraints through conf/opal-export.conf file
--dependent-objects table:index,constraint,comment,object_grant view:comment,object_grant,trigger "materialized view:comment,index,materialized_view_log,object_grant"
scripts/opal-export-pre-script.sql
:
BEGIN
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE); --undocumented remove segement creation
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'EMIT_SCHEMA', FALSE); --undocumented remove schema
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_CREATION', FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'PRETTY', TRUE);
-- #111 Default settings for the export, table definitions will have ddl for primary key and unique index, causes error when installing table
-- can only be done when the unique index is created BEFORE the constraints
-- => exlude constraints by default, then add constraints through conf/opal-export.conf file
--DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS', FALSE);
-- don't export ref_constraints with table, should be separate in
-- directory ref_constraints
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM, 'REF_CONSTRAINTS', FALSE);
END;
/