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;