gpt4 book ai didi

Regarding creating the index(关于创建索引)

转载 作者:bug小助手 更新时间:2023-10-24 17:55:06 28 4
gpt4 key购买 nike




there are two db we migrated the data from db1 to db2 now the db2 have some indexes missing in it and we need to create all those index in db 2 but we only have the indexes name nothing else is known

有两个数据库我们将数据从DB1迁移到DB2,现在DB2中缺少一些索引,我们需要在DB2中创建所有这些索引,但我们只有索引名,其他内容未知


i want to all index should be created but i shouldnt create it manually i take the uncreated index from db1 and create it to db2

我希望应该创建所有索引,但我不应该手动创建它,我从DB1中获取未创建的索引,并将其创建到DB2中


更多回答
优秀答案推荐

One option is to extract DDL yourself.

一种选择是自己提取DDL。


First, check which indexes you have:

首先,检查您有哪些索引:


SQL> set long 10000
SQL> select table_name, index_name from user_indexes;

TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
ROLES PK_ROLES
DEPT PK_DEPT
EMP PK_EMP
TEST SYS_IL0000590731C00001$$

Then use dbms_metadata.get_ddl for any index you want. If you remove where clause, you'll get them all.

然后对所需的任何索引使用DBMS_metadata.get_ddl。如果您删除WHERE子句,您将获得所有这些子句。


SQL> select dbms_metadata.get_ddl('INDEX', index_name) from user_indexes where index_name = 'PK_ROLES';

DBMS_METADATA.GET_DDL('INDEX',INDEX_NAME)
--------------------------------------------------------------------------------

CREATE UNIQUE INDEX "SCOTT"."PK_ROLES" ON "SCOTT"."ROLES" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
TABLESPACE "USER_DATA"


SQL>

This option might be interesting because you can spool result into a file and then just run that script in target database.

这个选项可能很有趣,因为您可以将结果假脱机到一个文件中,然后在目标数据库中运行该脚本。




Another option is to use some GUI tool which lets you visually examine list of indexes and copy/paste create index commands.

另一种选择是使用某种图形用户界面工具,该工具允许您直观地检查索引列表和复制/粘贴创建索引命令。


更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com