DROP PROCEDURE IF EXISTS add_att_batch_id;
DELIMITER // #将“;”转意
CREATE PROCEDURE add_att_batch_id()
BEGIN
DECLARE CurrentDatabase VARCHAR (100) ;
SELECT
DATABASE() INTO CurrentDatabase ; #获得当前数据库名称
IF NOT EXISTS
(SELECT
*
FROM
information_schema.columns
WHERE table_schema = CurrentDatabase
AND table_name = 'test'
AND column_name = 'attbatch_id')
THEN ALTER TABLE test
ADD COLUMN `attbatch_id` VARCHAR (36) COMMENT '附件批ID' ;
END IF ;
END //
DELIMITER ; #结束转意
CALL add_att_batch_id();
DROP PROCEDURE IF EXISTS add_att_batch_id;
存储过程
最新推荐文章于 2024-09-10 14:35:22 发布