⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dba_trg_disable.sql

📁 Java写的ERP系统
💻 SQL
字号:
/*************************************************************************
 * The contents of this file are subject to the Compiere License.  You may
 * obtain a copy of the License at    http://www.compiere.org/license.html
 * Software is on an  "AS IS" basis,  WITHOUT WARRANTY OF ANY KIND, either
 * express or implied. See the License for details. Code: Compiere ERP+CRM
 * Copyright (C) 1999-2002 Jorg Janke, ComPiere, Inc. All Rights Reserved.
 *************************************************************************
 * $Id: DBA_Trg_Disable.sql,v 1.3 2002/06/16 05:28:09 jjanke Exp $
 ***
 * Title:	Disable all triggers and felf referencing constraints
 * Description:
 *		- required for initial DB create
 ************************************************************************/
DECLARE
	--	Trigger
	CURSOR Cur_Trg IS
		SELECT 	TRIGGER_NAME
		FROM 	USER_TRIGGERS
		WHERE	STATUS <> 'DISABLED'
		ORDER BY 1;
	-- Self referencing Constraints
	CURSOR Cur_Constraint IS
		SELECT 	Table_Name, Constraint_Name
		FROM 	USER_CONSTRAINTS c
		WHERE	c.Constraint_Type='R'
		  AND	c.Status <> 'DISABLED'
		  AND EXISTS (SELECT * FROM USER_CONSTRAINTS cc 
		  	WHERE c.R_Constraint_Name=cc.Constraint_Name
			  AND c.Table_Name=cc.Table_Name)
		ORDER BY 1;
 	v_Cmd					VARCHAR2(256);
BEGIN
	DBMS_OUTPUT.PUT_LINE('Disabling:');
	FOR t IN CUR_Trg LOOP
		DBMS_OUTPUT.PUT_LINE('.. ' || t.Trigger_Name);
		v_Cmd := 'ALTER TRIGGER ' || t.Trigger_Name || ' DISABLE';
		EXECUTE IMMEDIATE v_Cmd;
	END LOOP;
	FOR c IN CUR_Constraint LOOP
		DBMS_OUTPUT.PUT_LINE('.. ' || c.Table_Name || ' ' || c.Constraint_Name);
		v_Cmd := 'ALTER TABLE ' || c.Table_Name || ' MODIFY CONSTRAINT ' || c.Constraint_Name || ' DISABLE';
		EXECUTE IMMEDIATE v_Cmd;
	END LOOP;
END;
/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -