mysql通过存储过程判断字段是否存在

DROP PROCEDURE IF EXISTS pro_AddColumn;
CREATE PROCEDURE pro_AddColumn() BEGIN
IF NOT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name='print_template' AND COLUMN_NAME='PrintConfig') THEN
ALTER TABLE component ADD PRINT_CHECK_STATUS int(10) default 0;
END IF;
END;
CALL pro_AddColumn;
DROP PROCEDURE IF EXISTS pro_AddColumn;

posted @ 2021-11-15 11:20  程序员小艺  阅读(338)  评论(0编辑  收藏  举报