在当前现有模式中,大多数索引/约束名称都是由oracle生成的,如SYS_CXXXXX,我试图将它们导出为DDL语句,这里我需要用类似PK_(tablename)或PK_(tablename)1替换系统生成的名称。谢谢
答案 0 :(得分:1)
您可以使用ALTER命令的RENAME选项重命名约束/索引:
SQL> create table t (x int primary key);
SQL> select constraint_name from user_constraints
2 where table_name = 'T';
CONSTRAINT_NAME
----------------------
SYS_C0010667
SQL> alter table t rename constraint sys_c0010667 to t_pk;
SQL> select constraint_name from user_constraints
2 where table_name = 'T';
CONSTRAINT_NAME
----------------------
T_PK
SQL> select index_name from user_indexes where table_name = 'T';
INDEX_NAME
----------------------
SYS_C0010667
SQL> alter index sys_c0010667 rename to t_pk;
Индекс изменен.
SQL> select index_name from user_indexes where table_name = 'T';
INDEX_NAME
----------------------
T_PK