zoukankan      html  css  js  c++  java
  • oracle批量生成表主键及索引语句

    主键:

    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;

  • 相关阅读:
    Django之POST GET与前后端交互
    Django中用户权限模块
    Django运算表达式与Q对象/F对象
    Django中Middleware中间件
    Form表单 JSON Content-type解析
    浅析ajax原理与用法
    浅析Django之session与cookie
    浅谈HTTP协议
    Django 项目搭建(ubuntu系统)
    h5 和之前版本的区别
  • 原文地址:https://www.cnblogs.com/gnwzj/p/13141810.html
Copyright © 2011-2022 走看看