Skip to content

Instantly share code, notes, and snippets.

@stefanborghys
Last active March 11, 2016 16:20
Show Gist options
  • Save stefanborghys/5197947 to your computer and use it in GitHub Desktop.
Save stefanborghys/5197947 to your computer and use it in GitHub Desktop.
Drop a trigger from an Oracle database using Liquibase (http://www.liquibase.org).
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../xsd/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../xsd/dbchangelog-ext.xsd"
logicalFilePath="drop_trigger_changelog.xml">
<changeSet id="1" author="stefanborghys" runOnChange="true">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT DECODE(COUNT(*),0,0,1) FROM DBA_OBJECTS WHERE OBJECT_TYPE = 'TRIGGER' AND OBJECT_NAME = 'TRIGGER_NAME';
</sqlCheck>
</preConditions>
<comment>Drop a trigger from an Oracle database.</comment>
<sql><![CDATA[DROP TRIGGER TRIGGER_NAME;]]></sql>
<rollback>
<![CDATA[
create or replace
trigger SCHEMA_NAME.TRIGGER_NAME
BEFORE INSERT OR UPDATE ON TABLE_NAME
BEGIN
-- The trigger's logic
END;
]]>
</rollback>
</changeSet>
</databaseChangeLog>
@Teqqles
Copy link

Teqqles commented May 7, 2014

You can use the same syntax should you wish to drop an Oracle package. There aren't many in the wild but still good to know. (e.g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment