发布网友 发布时间:2022-05-03 10:24
共4个回答
懂视网 时间:2022-05-03 14:45
主键:
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 语句
热心网友 时间:2022-05-03 11:53
Oracle的序列原理是先根据需求建立个序列,然后在表insert数据时应用某个序列,因此序列是公用的。也就是说如果一个表用了一个序列,起始1递增1,如果已经递增使用到100,用另一个表也引用这个序列,那就是从100开始算了,也即是如果两张以上的表同时使用一个序列,那序列就不会安你所需的那样递增了。热心网友 时间:2022-05-03 13:11
SQL语句创建或使用工具创建热心网友 时间:2022-05-03 14:46
在建表语句中指定。电脑啥够给你干了,要人类干嘛。