存儲(chǔ)過程關(guān)于更改數(shù)據(jù)表結(jié)構(gòu)的語句(pl/sql) - asp.net(c#),js,htc...
declare
mycountINT;
begin
select count(*) into mycount from user_tab_columns where COLUMN_NAME=‘U_ID‘ AND TABLE_NAME=‘UINFOR‘;
if mycount = 0 then
--1. 刪除原主鍵
execute immediate ‘alter table uinfor drop constraint PK_uinfor‘;
--2. 刪除字段
execute immediate ‘alter table uinfor drop column u_id‘;
--3. 添加字段
execute immediate ‘alter table uinfor add u_note varchar(1) NULL‘;
--4. 修改字段
execute immediate ‘ALTER TABLE uinfor modify u_key NOT NULL‘;
--5. 添加新主鍵
execute immediate ‘alter table uinfor add primary key(u_key ,u_name )‘;
end if;
end;
/
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。