The specific Dynamically delete indexes DROP PROCEDURE IF EXISTS UPGRADE; DELIMITER $$ CREATE PROCEDURE UPGRADE() BEGIN -- RESOURCE.AUDIO_ATTRIBUTE IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = 'RESOURCE' AND TABLE_NAME = 'AUDIO_ATTRIBUTE' AND INDEX_NAME = 'resource_publish_resource_id_index') THEN ALTER TABLE `AUDIO_ATTRIBUTE` DROP INDEX resource_publish_resource_id_index; END IF; END$$ DELIMITER ; CALL UPGRADE(); DROP PROCEDURE IF EXISTS UPGRADE; Dynamically adding fields DROP PROCEDURE IF EXISTS UPGRADE; DELIMITER $$ CREATE PROCEDURE UPGRADE() BEGIN -- HOMEWORK.HOMEWORK_QUESTION_GROUP.FROM_ID IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'HOMEWORK' AND TABLE_NAME = 'HOMEWORK_QUESTION_GROUP' AND COLUMN_NAME = 'FROM_ID') THEN ALTER TABLE `HOMEWORK_QUESTION_GROUP` ADD COLUMN FROM_ID VARCHAR(50) NULL; END IF; -- HOMEWORK.HOMEWORK_QUESTION_GROUP.QUESTION_TYPE IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'HOMEWORK' AND TABLE_NAME = 'HOMEWORK_QUESTION_GROUP' AND COLUMN_NAME = 'QUESTION_TYPE') THEN ALTER TABLE `HOMEWORK_QUESTION_GROUP` ADD COLUMN QUESTION_TYPE VARCHAR(50) NULL; END IF; --HOMEWORK.HOMEWORK_QUESTION_GROUP.DIFFICULTY IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'HOMEWORK' AND TABLE_NAME = 'HOMEWORK_QUESTION_GROUP' AND COLUMN_NAME = 'DIFFICULTY') THEN ALTER TABLE `HOMEWORK_QUESTION_GROUP` ADD COLUMN DIFFICULTY VARCHAR(50) NULL; END IF; END$$ DELIMITER ; CALL UPGRADE(); DROP PROCEDURE IF EXISTS UPGRADE; The other syntaxes are similar, mainly distinguishing between the usage of Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: How to install nginx on win10
>>: Three examples of nodejs methods to obtain form data
I started configuring various environments this a...
Win10 system locally installed MySQL8.0.20, perso...
When deploying uwsgi+nginx proxy Django, access u...
The data type of MySQL is datetime. The data stor...
Last year, due to project needs, I wrote a crawle...
As shown above, padding values are composite at...
Preface In Windows, you can start multiple MySQL ...
Table of contents 1. Introduction to the basic fu...
What does text-fill-color mean? Just from the lit...
Use Javascript to implement a drop-down menu for ...
Require The div under the body is vertically cent...
Designers have their own font library, which allo...
There are many tools available for backing up MyS...
Preface Normal business needs: upload pictures, E...
Implementation effect: 1. count(1) and count(*) W...