doc-exports/docs/dws/tool/dws_mt_0110.html
Lu, Huayi 346ac31da9 DWS TG 8.1.3.200 VERSION
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-08-28 09:20:17 +00:00

96 lines
9.5 KiB
HTML

<a name="EN-US_TOPIC_0000001234200605"></a><a name="EN-US_TOPIC_0000001234200605"></a>
<h1 class="topictitle1">Index Migration</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p43073621235519">When an index is created in <span id="EN-US_TOPIC_0000001234200605__text1958020141713">GaussDB(DWS)</span>, a schema name cannot be specified along with the index name. The index will be automatically created in the schema where the index table is created.</p>
<div class="fignone" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_fig42490243195448"><span class="figcap"><b>Figure 1 </b>Input: INDEX</span><br><span><img id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_image19157625195448" src="figure/en-us_image_0000001233800835.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_fig8263792195448"><span class="figcap"><b>Figure 2 </b>Output: INDEX</span><br><span><img id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_image65387407195448" src="figure/en-us_image_0000001233922325.png"></span></div>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1934241210443"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b77161851175216">Input - Function-based indexes by using CASE</strong></p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p47691556155213">A function-based index is an index that is created on the results of a function or expression on top of a column.</p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1939991364417"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b7526122465313">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen10488521145516">CREATE
UNIQUE index GCC_RSRC_ASSIGN_U1
ON GCC_PLAN.GCC_RSRC_ASSIGN_T (
(CASE
WHEN( ENABLE_FLAG = 'Y' AND ASSIGN_TYPE = '13' AND WORK_ORDER_ID IS NOT NULL )
THEN WORK_ORDER_ID
ELSE NULL
END)
) ;</pre>
<div class="note" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_note3846258125615"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p17847658165614">The expression or function needs to be put inside brackets.</p>
</div></div>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1916862213467"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b1752284319572">Input - Function-based indexes by using DECODE</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen206397335815">CREATE UNIQUE index GCC_PLAN_N2
ON GCC_PLAN.GCC_PLAN_T (
DECODE (
ENABLE_FLAG
,'Y'
,BUSINESS_ID
,NULL
)
) ; </pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1663448135712"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b142331950155820">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen017916573588">CREATE UNIQUE index GCC_PLAN_N2
ON GCC_PLAN.GCC_PLAN_T (
(DECODE (
ENABLE_FLAG
,'Y'
,BUSINESS_ID
,NULL
))
) ; </pre>
<div class="note" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_note15143718155912"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p4144418175913">The expression or function needs to be put inside brackets.</p>
</div></div>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p7962752195812"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_b196018187534">ORA_HASH</strong></p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p926823113448">ORA_HASH is a function that computes a hash value for a given expression or column. If this function is specified on the column(s) in the CREATE INDEX statement, this function will be removed.</p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1166182483215"><strong id="EN-US_TOPIC_0000001234200605__b18163024816">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen18677132401610">create index SD_WO.WO_WORK_ORDER_T_N3 on SD_WO.WO_WORK_ORDER_T (PROJECT_NUMBER, ORA_HASH(WORK_ORDER_NAME));</pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p516632418328"><strong id="EN-US_TOPIC_0000001234200605__b767114577474">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen10859193913161">CREATE
index WO_WORK_ORDER_T_N3
ON SD_WO.WO_WORK_ORDER_T (
PROJECT_NUMBER
,ORA_HASH( WORK_ORDER_NAME )
) ;</pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p4480042153314"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_b67021331273">DECODE</strong></p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p1738915423224">If DECODE function in the CREATE INDEX statement is used as a part of a column, the following error will be reported: "syntax error at or near 'DECODE' (Script - gcc_plan_t.sql)".</p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p0408101317383"><strong id="EN-US_TOPIC_0000001234200605__b4175103644719">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen1414101524110">create unique index GCC_PLAN.GCC_PLAN_N2 on GCC_PLAN.GCC_PLAN_T (DECODE(ENABLE_FLAG,'Y',BUSINESS_ID,NULL));</pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p3179926997"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b773417214118">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen1464522172315">CREATE
UNIQUE index GCC_PLAN_N2
ON GCC_PLAN.GCC_PLAN_T (
DECODE (
ENABLE_FLAG
,'Y'
,BUSINESS_ID
,NULL
)
) ;</pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p17870134995218"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b106612255012">CASE statement</strong></p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p2582540609">The CASE statement is not supported in the CREATE INDEX statement.</p>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p154131459704"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b1828210127112">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen117921144804">CREATE
UNIQUE index GCC_RSRC_ASSIGN_U1
ON GCC_PLAN.GCC_RSRC_ASSIGN_T (
(CASE
WHEN( ENABLE_FLAG = 'Y' AND ASSIGN_TYPE = '13' AND WORK_ORDER_ID IS NOT NULL )
THEN WORK_ORDER_ID
ELSE NULL
END)
) ;</pre>
<p id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_p18295101108"><strong id="EN-US_TOPIC_0000001234200605__en-us_topic_0237712329_b1466810398112">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200605__en-us_topic_0238518385_en-us_topic_0237362193_en-us_topic_0202727464_screen629616492113">CREATE UNIQUE INDEX gcc_rsrc_assign_u1
ON gcc_plan.gcc_rsrc_assign_t ( (( CASE
WHEN( enable_flag = 'Y'
AND assign_type = '13'
AND work_order_id IS NOT NULL )
THEN work_order_id
ELSE NULL END )) ); </pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_mt_0106.html">Schema Objects</a></div>
</div>
</div>