oracle批量生成表主键及索引语句
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了oracle批量生成表主键及索引语句,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1410字,纯文字阅读大概需要3分钟。
内容图文
![oracle批量生成表主键及索引语句](/upload/InfoBanner/zyjiaocheng/525/5774cb84c0f340e8af8c5e2958461f23.jpg)
主键:
select *
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = ‘P‘
and a.table_name = upper(‘表名‘)
select a.constraint_name,a.TABLE_NAME,count(a.constraint_name),concat(‘alter table ‘, concat(a.TABLE_NAME,concat(‘ add constraint ‘,concat(a.constraint_name , concat(‘ primary key (‘,concat(wmsys.wm_concat(a.column_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 ( ‘表名1‘,‘表名2‘) group by a.constraint_name,a.TABLE_NAME
-- 索引 create index IDX_USER_STA on USERTAB (STATUS);
select c.INDEX_NAME,count(c.INDEX_NAME), c.TABLE_NAME,
concat( ‘ create ‘ ,concat( ‘ index ‘ ,concat( c.INDEX_NAME ,concat( ‘ on ‘,concat(c.TABLE_NAME,concat(‘ (‘,concat(wmsys.wm_concat(c.COLUMN_NAME),‘);‘)))))))
,i.index_type
from user_ind_columns c, user_indexes i
where c.index_name = i.INDEX_NAME
and i.table_name in (‘表名‘)
and i.index_name not in (
‘主键索引名字‘
) group by c.INDEX_NAME, c.TABLE_NAME, i.index_type order by table_name;
oracle批量生成表主键及索引语句
标签:exe upper from select order 索引 bsp concat 语句
本文系统来源:https://www.cnblogs.com/gnwzj/p/13141810.html
内容总结
以上是互联网集市为您收集整理的oracle批量生成表主键及索引语句全部内容,希望文章能够帮你解决oracle批量生成表主键及索引语句所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。