【Oracle】表追加字段

前端之家收集整理的这篇文章主要介绍了【Oracle】表追加字段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/**   
 *  描述:帮扶对象追加字段脚本
 */
DECLARE
    num1 NUMBER;
    num2 NUMBER;
BEGIN
    SELECT COUNT(1) INTO num1 FROM cols
        WHERE table_name = upper('T_ZZ_SUPPORT_OBJECT')
        AND column_name = upper('creator_id');

    SELECT COUNT(1) INTO num2 FROM cols
        WHERE table_name = upper('T_ZZ_SUPPORT_OBJECT')
        AND column_name = upper('create_time');

    IF num1 < 1 THEN
        execute immediate 'alter table T_ZZ_SUPPORT_OBJECT add creator_id NUMBER(9)';
    END IF;

    IF num2 < 1 THEN
        execute immediate 'alter table T_ZZ_SUPPORT_OBJECT add create_time DATE';
    END IF;
END;
/
COMMIT;
原文链接:https://www.f2er.com/oracle/210077.html

猜你在找的Oracle相关文章