Corrected a script, encountered some of the differences between the two databases, recorded:
Trigger:
| Difference |
Mysql |
ORACLE |
Description |
| Create statements different |
Create Trigger ' AA ' before INSERT on ' BB ' For each row |
Create or replace trigger AA before insert or update or delete on BB For each row |
1.Oracle can trigger the Insert,delete,update event on a trigger. MySQL each trigger supports only one event. In other words, each trigger needs to be split into 3 MySQL trigger at present. |
| Referencing new and old data is different |
Access to new data : Neo AA Get old data : oidbb |
Getting new data : : NewAA Get old data : : older. BB |
1.oracle multiple pairs of colons |
Stored procedures:
| Difference |
Mysql |
ORACLE |
Description |
| Create statements different |
DROP PROCEDURE IF EXISTS ' sd_user_p_add_usr '; CREATE PROCEDURE AA( AA varchar (+)) |
Create or Replace procedure AA( varchar AA) is |
1.oracle creation is relatively concise, MySQL must first execute the drop 2.mysql first variable re-type, Oracle opposite, and does not have to limit length 3. If you are number or VARCHAR2, you do not need to define the length. Otherwise the compilation cannot pass |
| Exception handling not the same |
DECLARE EXIT HANDLER for Aaexception BEGIN ... END; |
EXCEPTION When OTHERS Then ROLLBACK; .... |
1.mysql You cannot customize exceptions, and you need to define them when using internal exceptions |
| Calls are stored in different ways |
Call procedure (); |
procedure (); |
1. Different calling methods |
So how to willful delete triggers:
Declare
V_num number;
BEGIN
Select COUNT (0) into V_num from user_triggers where trigger_name = ' AA '; (Note case)
If V_num > 0 Then
Execute immediate ' DROP TRIGGER AA ';
End If;
END;
Differences between MySQL and Oracle's triggers and stored procedure syntax