SET SERVEROUTPUT ON; --ENABLE
EXEC DBMS_OUTPUT.ENABLE(1000000);
DECLARE
B NUMBER;
BEGIN
SELECT COUNT(*)
INTO B
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = 'TABLE_A' AND COLUMN_NAME = 'COLUMN_A';
IF B = 0
THEN
EXECUTE IMMEDIATE 'ALTER TABLE TABLE_A ADD(COLUMN_A NVARCHAR2(100) DEFAULT ''IB'' )';
DBMS_OUTPUT.PUT_LINE('ALTER TABLE TABLE_A ADD(COLUMN_A NVARCHAR2(100) DEFAULT ''IB'' )');
END IF;
沒有留言:
張貼留言