java - Informix DDL execution for constraint disabling -


i planning disable foreign key constraint avoid recursive relationship while purging data. main steps written below:

connection conn = getconnection(si_single_url2, si_uname2, si_pass2); // return valid java,sql.connection statement stmt = conn.createstatement();   boolean isconstraintdisabled = stmt.execute("alter table zee_temp_tab_2 nocheck constraint all");   stmt.executequery("delete zee_temp_tab_2 id = 'a'"); boolean isconstraintenabled =  stmt.execute("alter table zee_temp_tab_2 check constraint all"); 

please advise how it.

to disable constraints table (pk, uniques, not null, check)

 set constraints table <table> disabled; 

or specific contraint

 set constraints <constraint_name> disabled; 

to enable, use "enabled" parameter. observation: pk, fks , uniques recreate internal index... depending of # of records, maybe take time.... careful.

other options use "deferred" option (this way don't need disable, need single transaction.)

set constraints <all|constraint_name> deferred; begin work; -- have commit work; -- constraints validated here... set constraints <all|constraint_name> immediate; 

and there option "filtered"... little more complex , need support of dba.

for more information, search commands online manual


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -