分享

存储过程关于更改数据表结构的语句(pl/sql) - asp.net(c#),js,htc...

 johnlane 2007-08-03
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;

/

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多