forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
107 lines
18 KiB
HTML
107 lines
18 KiB
HTML
<a name="EN-US_TOPIC_0000001819336081"></a><a name="EN-US_TOPIC_0000001819336081"></a>
|
|
|
|
<h1 class="topictitle1">Oracle SQL Migration</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p1954041116453">DSC supports the migration from Oracle to GaussDB(DWS), including the migration of schemas, DML, queries, system functions, and PL/SQL.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_section1666816415313"><h4 class="sectiontitle">Performing Oracle SQL Migration</h4><p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p196641241232">Run the following commands to set the source database, input and output folder paths, log paths, application language, and conversion type:</p>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p114605492611"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b793120551966">Linux</strong>:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen52461094"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b18941162214269">./runDSC.sh</strong>
|
|
<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b59194389">--source-db</strong> Oracle
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b94431321165613">--input-folder</strong> <input-script-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b547482518567">--output-folder</strong> <output-script-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b13025283561">--log-folder</strong> <log-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b86041222201018">--application-lang </strong>Oracle]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b829783418103">--conversion-type</strong> <conversion-type>]</pre>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p188654285193"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b68391850171916">Windows</strong>:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen56736032011"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b167390122011">runDSC.bat</strong>
|
|
<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b198803456106">--source-db</strong> Oracle
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b688015453109">--input-folder</strong> <input-script-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b13880194510102">--output-folder</strong> <output-script-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b1688164541017">--log-folder</strong> <log-path>]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b1488174591018">--application-lang </strong>Oracle]
|
|
[<strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b2088114456109">--conversion-type</strong> <conversion-type>]</pre>
|
|
<ul id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_ul165421019191014"><li id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_li6878152711359">When migrating common DDL statements (such as tables, views, indexes, sequences, and so on) that do not contain PL/SQL statements, use the Bulk mode (that is, set <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b17933101819519">conversion-type</strong> to <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b163211339125520">Bulk</strong>).<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p134611348134618">Run the following commands to set <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b870514872713">conversion-type</strong> to <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b1211792262814">Bulk</strong>. The commands include the folder paths in the example.</p>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p6830174117466"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b20495996816">Linux</strong>:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen1883113415469"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b4925174883311">./runDSC.sh --source-db</strong> Oracle --input-folder /opt/DSC/DSC/input/oracle/ --output-folder /opt/DSC/DSC/output/ --log-folder /opt/DSC/DSC/log/ <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b14925204853311">--application-lang </strong>SQL <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b119251648173315">--conversion-type</strong> bulk <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b19925114820332">--target-db</strong> gaussdbA</pre>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p1083134114463"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b20248121216811">Windows</strong>:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen10831441144614"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b0107183310119">runDSC.bat --source-db</strong> Oracle <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b51071733101113">--input-folder</strong> D:\test\conversion\input <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b111079338111">--output-folder</strong> D:\test\conversion\output <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b410733313114">--log-folder</strong> D:\test\conversion\log <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b15107833171115">--application-lang </strong>SQL <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b610783301116">--conversion-type</strong> bulk <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b4107123316114">--target-db</strong> gaussdbA</pre>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p583134110469">During the execution of DSC, the migration summary, including the progress and completion status, is displayed on the console. Execution information and errors will be recorded in <a href="dws_16_0033.html#EN-US_TOPIC_0000001819416117">SQL Migration Logs</a>.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen138321741194617">********************** Schema Conversion Started *************************
|
|
DSC process start time : Mon Jan 20 17:24:49 IST 2020
|
|
Statement count progress 100% completed [FILE(1/1)]
|
|
|
|
Schema Conversion Progress 100% completed
|
|
**************************************************************************
|
|
Total number of files in input folder : 1
|
|
**************************************************************************
|
|
Log file path :....../DSC/DSC/log/dsc.log
|
|
DSC process end time : Mon Jan 20 17:24:49 IST 2020
|
|
DSC total process time : 0 seconds
|
|
********************* Schema Conversion Completed ************************</pre>
|
|
</li><li id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_li16965135214356">When migrating objects such as functions, procedures, and packages that contain PL/SQL statements, use the BLogic mode. That is, set <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b1375818208515">conversion-type</strong> to <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0237712365_b1790834716569">BLogic</strong>.<div class="p" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p7119205419357">Run the following command to set <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b145841149123618">conversion-type</strong> to <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b1176218573411">BLogic</strong>. The command includes the folder paths in the example.<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen1566717412032"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b136672416319"><strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b1987715401075">runDSC.bat </strong>--source-db</strong> Oracle <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b156671041333">--input-folder</strong> D:\test\conversion\input <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b56671411034">--output-folder</strong> D:\test\conversion\output <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b106678417310">--log-folder</strong> D:\test\conversion\log <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b466717413311">--application-lang </strong>SQL <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_b146675419318">--conversion-type</strong> blogic <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b134301212141">--target-db</strong> gaussdbA</pre>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p11159850332">During the execution of DSC, the migration summary, including the progress and completion status, is displayed on the console. Execution information and errors will be recorded in <a href="dws_16_0033.html#EN-US_TOPIC_0000001819416117">SQL Migration Logs</a>.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen33743900">********************** Schema Conversion Started *************************
|
|
DSC process start time : Mon Jan 20 17:24:49 IST 2020
|
|
Statement count progress 100% completed [FILE(1/1)]
|
|
|
|
Schema Conversion Progress 100% completed
|
|
**************************************************************************
|
|
Total number of files in input folder : 1
|
|
Total number of valid files in input folder : 1
|
|
**************************************************************************
|
|
Log file path :....../DSC/DSC/log/dsc.log
|
|
Error Log file :
|
|
DSC process end time : Mon Jan 20 17:24:49 IST 2020
|
|
DSC total process time : 0 seconds
|
|
********************* Schema Conversion Completed ************************</pre>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p10931173201612">Common DDL scripts and PL/SQL scripts should be stored in different input folders for migration.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_section165227516137"><h4 class="sectiontitle">Oracle PACKAGE Migration Precautions</h4><p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p10822123314">1. The package specifications (that is, the package header) and the package body should be stored in different files and in the same input path for migration.</p>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p5949111315714">2. You need to migrate common DDL statements in Bulk mode, including all table structure information referenced in the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b124726218357">PACKAGE</strong> script, to form a dictionary in the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b2047262163511">config/create-types-UDT.properties</strong> file. Then, migrate the package specifications (that is, the package header) and the package body in Blogic mode. The details are as follows:</p>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p106141383712">When some Oracle <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b186817301241">PACKAGE</strong> packages define package specifications, the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b1228467111">tbName.colName%TYPE</strong> syntax is used to declare custom record types based on other table objects.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen1298344115710"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
|
|
<span class="normal"> 2</span>
|
|
<span class="normal"> 3</span>
|
|
<span class="normal"> 4</span>
|
|
<span class="normal"> 5</span>
|
|
<span class="normal"> 6</span>
|
|
<span class="normal"> 7</span>
|
|
<span class="normal"> 8</span>
|
|
<span class="normal"> 9</span>
|
|
<span class="normal">10</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">For</span><span class="w"> </span><span class="n">example</span><span class="p">:</span>
|
|
<span class="w"> </span><span class="k">CREATE</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="k">REPLACE</span><span class="w"> </span><span class="n">PACKAGE</span><span class="w"> </span><span class="n">p_emp</span>
|
|
<span class="w"> </span><span class="k">AS</span>
|
|
<span class="w"> </span><span class="c1">--Define the RECORD type</span>
|
|
<span class="w"> </span><span class="k">TYPE</span><span class="w"> </span><span class="n">re_emp</span><span class="w"> </span><span class="k">IS</span><span class="w"> </span><span class="n">RECORD</span><span class="p">(</span>
|
|
<span class="w"> </span><span class="n">rno</span><span class="w"> </span><span class="n">emp</span><span class="p">.</span><span class="n">empno</span><span class="o">%</span><span class="k">TYPE</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="n">rname</span><span class="w"> </span><span class="n">emp</span><span class="p">.</span><span class="n">empname</span><span class="o">%</span><span class="k">TYPE</span>
|
|
<span class="w"> </span><span class="p">);</span>
|
|
|
|
<span class="w"> </span><span class="k">END</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p18375201211144">The column data type cannot be specified using the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b3598144411418">tbName.colName%TYPE</strong> syntax in a <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b5163551265">CREATE TYPE</strong> statement on GaussDB(DWS). Therefore, DSC needs to build a database context environment containing the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b693520181680">EMP</strong> table information during migration. In this case, you need to use DSC to migrate all table creation scripts, that is, to migrate common DDL statements in Bulk mode. DSC automatically generates corresponding data dictionaries. After the context environment containing various table information is built, you can migrate the Oracle PACKAGE in Blogic mode. In this case, the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b15150192721118">re_emp</strong> record type is migrated based on the column type of the <strong id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_b172671750181114">EMP</strong> table.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_screen265082917920"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span>
|
|
<span class="normal">4</span>
|
|
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">Expected</span><span class="w"> </span><span class="k">output</span>
|
|
<span class="w"> </span><span class="k">CREATE</span><span class="w"> </span><span class="k">TYPE</span><span class="w"> </span><span class="n">p_emp</span><span class="p">.</span><span class="n">re_emp</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="p">(</span>
|
|
<span class="w"> </span><span class="n">rno</span><span class="w"> </span><span class="nb">NUMBER</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
|
|
<span class="w"> </span><span class="n">rname</span><span class="w"> </span><span class="n">VARCHAR2</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
|
|
<span class="w"> </span><span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001819336081__en-us_topic_0000001658024586_en-us_topic_0218440546_p1154912516137">For details about how to migrate Oracle SQL using DSC, see <a href="dws_16_0020.html#EN-US_TOPIC_0000001819416093">Executing DSC</a>.</p>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0024.html">Database Schema Conversion</a></div>
|
|
</div>
|
|
</div>
|
|
|