您的位置:首页 > 数据库 > Oracle

Oracle的添加主键

2016-03-25 15:20 525 查看
select 'update ' || tname || ' set uuid =sys_guid() where uuid is null;',
'alter table ' || tname || ' modify  uuid VARCHAR2(64) not null;',
' alter table ' || tname || ' add constraint PK_' || tname ||
' primary key (UUID) ;'

from t_emp_rec
where tname not in
(select a.table_name
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'P'
and a.table_name in (select tname from t_emp_rec group by tname))
group by tname
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle