时间:2021-07-01 10:21:17 帮助过:12人阅读
某个字段处理:
1 -- ---------------------------------- 2 -- 字段is_online处理--- 3 -- ---------------------------------- 4 5 DROP PROCEDURE IF EXISTS camera_info_is_online; 6 CREATE PROCEDURE camera_info_is_online() 7 BEGIN 8 DECLARE CurrentDatabase VARCHAR(100); 9 SELECT DATABASE() INTO CurrentDatabase; 10 IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema=CurrentDatabase AND table_name = ‘camera_info‘ AND column_name = ‘is_online‘) THEN 11 ALTER TABLE camera_info ADD is_online int(2) DEFAULT -1 COMMENT ‘监控点在线状态:0-不在线,1-在线,-1-未知‘; 12 END IF; 13 END; 14 CALL camera_info_is_online(); 15 DROP PROCEDURE IF EXISTS camera_info_is_online; 16 17 -- ---------------------------------- 18 -- 更新is_online字段默认值--- 19 -- ---------------------------------- 20 update camera_info set is_online=-1 ;View Code
sql脚本存储过程
标签:schema 升级 dev var begin update ide 监控 info