declare num number;
begin
select count(1) into num FROM all_tab_columns WHERE table_name = 'T_USER' AND nullable = 'N' AND column_name = 'ACCOUNTID';
if num=1 then
execute immediate'ALTER TABLE T_USER MODIFY ACCOUNTID VARCHAR2(1024) null';
end if;
end;
select count(1) FROM all_tab_columns WHERE table_name = 'T_USER' AND nullable = 'N' AND column_name = 'ACCOUNTID';
该sql是查询T_USER表中ACCOUNTID字段是否非空 必填则返回1也就是查出来一条数据,否则返回0
ALTER TABLE T_USER MODIFY ACCOUNTID VARCHAR2(1024) null
该sql是将必填字段改为非必填