Skip to main content

CREATE SCRIPT TO DISABLE AND ENABLE CONSTRAINT

DISABLE

SELECT 'ALTER TABLE "' || A.TABLE_NAME || '" DISABLE CONSTRAINT "' || A.CONSTRAINT_NAME || '";' ENABLE_CONSTRAINTS
FROM   USER_CONSTRAINTS A
WHERE  
       A.CONSTRAINT_TYPE = 'R' 
AND    A.R_CONSTRAINT_NAME IN (SELECT A1.CONSTRAINT_NAME
                               FROM   USER_CONSTRAINTS A1
                               WHERE  A1.TABLE_NAME = DECODE(UPPER('&1'),'ALL',A.TABLE_NAME,UPPER('&1'))
                               );


ENABLE

SELECT 'ALTER TABLE "' || A.TABLE_NAME || '" ENABLE CONSTRAINT "' || A.CONSTRAINT_NAME || '";'
FROM   USER_CONSTRAINTS A
WHERE  A.CONSTRAINT_TYPE = 'R'
AND    A.TABLE_NAME      = DECODE(UPPER('&1'),'ALL',A.TABLE_NAME,UPPER('&1'))
AND    A.STATUS          = 'DISABLED';

Comments

Popular posts from this blog

Behavior Driven Development

Behavior Driven Development (BDD) is a development process that originally associated with Test-Driven Development (TDD).  BDD is written in a readable format in an understandable language for anyone involved in software development.  BDD Features Providing better readability and visibility.  Verifying the software against customer requirements.  Assure the implementation of the system is correct. Derives examples of different expected behaviors of the system. Uses examples as acceptance tests. Focus on customer requirements throughout the development. BDD Practice There are two practices in BDD:-  Specification by Example (SbE). Test-Driven Development (TDD). Specification by example (SbE) uses examples in conversation to illustrate the business rules and the behavior of the software.  This uses to have a better understanding for Business Analyst, Product Owners, Testers and the Developers to reduce the misunderstanding abou...