-- ------------------------------determines whether the Vrv_paw_rule table exists thresholdmin field, does not exist, and then modifies the field type.DELIMITER??DROP PROCEDURE IF EXISTSschema_change??CREATE PROCEDURESchema_change ()BEGINIF not EXISTS(SELECT * fromInformation_schema.columnsWHERETable_schema= DATABASE() andtable_name= 'Vrv_paw_rule' andcolumn_name= 'Thresholdmin') Then ALTER TABLEVrv_paw_ruleADD COLUMNThresholdminBIGINT;ELSE ALTER TABLEVrv_paw_rule MODIFYCOLUMNThresholdminBIGINT ;END IF; END?? DELIMITER; Call Schema_change ();
Delimit command:
is to tell the MySQL interpreter if the command is over, and if MySQL can execute it, change the input terminator.
By default, delimiter is a semicolon ";".
In the command-line client, if a single line of commands ends with a semicolon,
Then after the carriage return, MySQL will execute the command.
But sometimes, you don't want MySQL to do this. Because more statements may be entered, and the statement contains a semicolon.
By default, it is not possible to wait until the user has entered all of these statements before executing the entire statement.
Since MySQL encounters a semicolon, it will be executed automatically.
In this case, you can use delimiter to change the delimiter back to another symbol, such as//or $$.
At this point, the delimiter function is to make a simple encapsulation of the entire small segment statement.
This command is used in the definition subroutine, triggers the program and so on MySQL own embedded small program.
MySQL determines if a table field exists and then modifies