Files
doc-exports/docs/dws/tool/DWS_DS_014.html
luhuayi a5e3903f6b DWS TG 910.211 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2025-04-23 13:53:01 +00:00

113 lines
17 KiB
HTML

<a name="EN-US_TOPIC_0000001813438788"></a><a name="EN-US_TOPIC_0000001813438788"></a>
<h1 class="topictitle1">Schema Management</h1>
<div id="body1584524312099"><p id="EN-US_TOPIC_0000001813438788__p183294419593">This section introduces how to use the database schema. All system schemas are grouped in <strong id="EN-US_TOPIC_0000001813438788__b17647820113611">Catalogs</strong>, and user schemas are grouped in <strong id="EN-US_TOPIC_0000001813438788__b15280154573612">Schemas</strong>.</p>
<div class="section" id="EN-US_TOPIC_0000001813438788__section116115315219"><h4 class="sectiontitle">Create Schema</h4><ol id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_ol34432747"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_li56122452"><span>In the <strong id="EN-US_TOPIC_0000001813438788__b1552011123719">Object Browser</strong> pane, right-click the selected <strong id="EN-US_TOPIC_0000001813438788__b12814121743717">Schemas</strong> group and select <strong id="EN-US_TOPIC_0000001813438788__b7441192114375">Create Schema</strong>.</span><p><div class="note" id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_note7107203112372"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_p2108123116379">Only refresh can be performed on <strong id="EN-US_TOPIC_0000001813438788__b16851539153810">Catalogs</strong> group.</p>
</div></div>
</p></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_li43969424"><span>Enter a schema name and click <strong id="EN-US_TOPIC_0000001813438788__b887665463819">OK</strong>. You can create the schema only if the database connection is active.</span><p><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_p141874823617">The status bar displays the status of the completed operation.</p>
<p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_p49496992">You can view the new schema in the <strong id="EN-US_TOPIC_0000001813438788__b115788125402">Object Browser</strong> pane.</p>
</p></li></ol>
<div class="note" id="EN-US_TOPIC_0000001813438788__note374850953"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001813438788__p19748305513">Data studio displays default schema of the user in the toolbar.</p>
<p id="EN-US_TOPIC_0000001813438788__p14518191359"><span><img id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264516_image136525873710" width="522.69" src="figure/en-us_image_0000001813439296.png" height="191.848776" title="Click to enlarge" class="imgResize"></span></p>
<ul id="EN-US_TOPIC_0000001813438788__ul8552173313510"><li id="EN-US_TOPIC_0000001813438788__li655211333516">When a CREATE query without mentioning the schema name is executed from SQL Terminal, the corresponding objects are created under the default schema of the user.</li><li id="EN-US_TOPIC_0000001813438788__li1055214331752">When a SELECT query is executed in SQL terminal without mentioning the schema name, the objects are queried based on the default schema.</li><li id="EN-US_TOPIC_0000001813438788__li65528331255">When Data Studio starts, the default schemas are set to &lt;username&gt;. The public schemas have the same priority.</li><li id="EN-US_TOPIC_0000001813438788__li1055217337520">If another schema is selected in the drop-down, the selected schema will be set as the default schema, overriding previous setting.</li><li id="EN-US_TOPIC_0000001813438788__li1055217338511">The selected schema is set as the default schema for all active connections of the database (selected in database list drop-down).</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001813438788__section105891556309"><h4 class="sectiontitle">Exporting Schema DDL and Data</h4><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p62435929">You can right-click <strong id="EN-US_TOPIC_0000001813438788__b1647111361817">Export DDL</strong> to export the DDL of functions/procedures, tables, sequences, and views of the schema. To export data, choose <strong id="EN-US_TOPIC_0000001813438788__b16894161619528">Export DDL and Data</strong>.</p>
<ol id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_ol24145451"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_li41061555"><span>In the <strong id="EN-US_TOPIC_0000001813438788__b11191007318926">Object Browser</strong> pane, right-click the selected schema and select <strong id="EN-US_TOPIC_0000001813438788__b2540616378926">Export DDL</strong>.</span><p><p id="EN-US_TOPIC_0000001813438788__p14770144218374">You need to customize the export path. To compress data, select <strong id="EN-US_TOPIC_0000001813438788__b7460185210523">.zip</strong>.</p>
<p id="EN-US_TOPIC_0000001813438788__p623194023315"><span><img id="EN-US_TOPIC_0000001813438788__image1021016599340" src="figure/en-us_image_0000001860199153.png" width="518.7" height="253.43150000000003" title="Click to enlarge" class="imgResize"></span></p>
<p id="EN-US_TOPIC_0000001813438788__p51431922154116"></p>
<p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p559426">You must select <strong id="EN-US_TOPIC_0000001813438788__b149531225558">I Agree</strong> under the <strong id="EN-US_TOPIC_0000001813438788__b2470735145515">Security Disclaimer</strong>, then click <strong id="EN-US_TOPIC_0000001813438788__b10451113713557">OK</strong>. You can select <strong id="EN-US_TOPIC_0000001813438788__b128191120145614">Do not show again</strong>. After the disclaimer is disabled, it will not be displayed when you export DDL. For details, see <a href="DWS_DS_005.html#EN-US_TOPIC_0000001813438860__table1510418570339">Table 1</a>.</p>
</p></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_li25693751192755"><span>Click <strong id="EN-US_TOPIC_0000001813438788__b1817311311578">OK</strong>. The operation progress is displayed on the status bar in the lower right corner.</span><p><div class="note" id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_note4325055192916"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_ul182591732164816"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_li9982918172613">If the file name contains characters that are not supported by Windows, the file name will be different from the schema name.</li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_li17561433124816">The Microsoft Visual C Runtime file (<strong id="EN-US_TOPIC_0000001813438788__b994919085919">msvcrt100.dll</strong>) is required for this operation. For details, see <a href="DWS_DS_039.html">Troubleshooting</a>.</li><li id="EN-US_TOPIC_0000001813438788__li2722142013364">You can select multiple objects and export their DDL. <a href="DWS_DS_040.html#EN-US_TOPIC_0000001813598528__en-us_topic_0185264547_li1037472864716">Batch Export</a> lists the objects whose DDL cannot be exported.</li></ul>
</div></div>
<p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p40980350192916">The <strong id="EN-US_TOPIC_0000001813438788__b20951114606">Data Exported Successfully</strong> dialog box and status bar display the status of the completed operation.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_table20789124652911" frame="border" border="1" rules="all"><caption><b>Table 1 </b>The supported DDL encoding formats</caption><thead align="left"><tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row485915510434"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.3.2.2.3.2.4.1.1"><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p18658615191019"><strong id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_b196581215101019">Database Encoding</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.3.2.2.3.2.4.1.2"><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p13658131510105"><strong id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_b8658111518105">File Encoding</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.3.2.2.3.2.4.1.3"><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p1765821511101"><strong id="EN-US_TOPIC_0000001813438788__b32994037522755">Support for Exporting a DDL</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row1465193611592"><td class="cellrowborder" rowspan="3" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p11711124110594">UTF-8</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p6562114412591">UTF-8</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.3 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p946516361597">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row6450163418591"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p15452183425919">GBK</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p94521734115915">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row12402232195917"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p19402632145916">LATIN1</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p840219321599">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row108601655164315"><td class="cellrowborder" rowspan="3" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p1786055514318">GBK</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p1786035594320">GBK</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.3 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p286045515433">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row166304144010"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p56301514407">UTF-8</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p126309145015">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row205945171408"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p9594317608">LATIN1</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p5594117608">No</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row1125843617458"><td class="cellrowborder" rowspan="3" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p11259163610455">LATIN1</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p172591836204513">LATIN1</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.3.2.2.3.2.4.1.3 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p12591636124510">Yes</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row1637216452013"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p5372545915">GBK</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p13721745310">No</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_row678318471115"><td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.1 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p1278394715113">UTF-8</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.3.2.2.3.2.4.1.2 "><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264706_p1578310471818">Yes</p>
</td>
</tr>
</tbody>
</table>
</div>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001813438788__section176318191854"><h4 class="sectiontitle">Renaming a Schema</h4><ol id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264705_ol3078623"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264705_li59981247"><span>In the <strong id="EN-US_TOPIC_0000001813438788__b09057438113">Object Browser</strong> pane, right-click the selected schema and select <strong id="EN-US_TOPIC_0000001813438788__b02251548912">Rename Schema</strong>.</span></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264705_li26642810"><span>Enter a schema name and click <strong id="EN-US_TOPIC_0000001813438788__b136161355414">OK</strong>.</span><p><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264705_p20948058192538">You can view the renamed schema in <strong id="EN-US_TOPIC_0000001813438788__b1668912291523">Object Browser</strong>.</p>
<p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264705_p1163514262374">The status bar displays the status of the completed operation.</p>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001813438788__section159988121213"><h4 class="sectiontitle">Granting/Revoking a Privilege</h4><ol id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_ol54022224212"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_li222516181158"><span>Right-click the schema group and select <strong id="EN-US_TOPIC_0000001813438788__b193871958338">Grant/Revoke</strong>.</span><p><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_p72251118141518">The <strong id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_b1934314385582">Grant/Revoke</strong> dialog box is displayed.</p>
</p></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_li1851919178165"><span>Open the <strong id="EN-US_TOPIC_0000001813438788__b1733517612415">Object Selection</strong> tab to select the desired objects, and click <strong id="EN-US_TOPIC_0000001813438788__b1833510616413">Next</strong>.</span></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_li1285194971613"><span>Select the role from the <strong id="EN-US_TOPIC_0000001813438788__b581954418414">Role</strong> drop-down list in the <strong id="EN-US_TOPIC_0000001813438788__b129389472046">Privilege Selection</strong> tab. Select the permissions to be granted or revoked.</span></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_li1366271912272"><span>On the <strong id="EN-US_TOPIC_0000001813438788__b7544171271220">SQL Preview</strong> tab, you can check the automatically generated SQL query. If the result does not meet the expectation, return to the previous step until the result meets the expectation.</span></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_li88071635142816"><span>Click <strong id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264907_b16553720145919">Finish</strong>.</span></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001813438788__section1640183610153"><h4 class="sectiontitle">Dropping a Schema</h4><ol id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264861_ol6703932"><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264861_li28195225"><span>In the <strong id="EN-US_TOPIC_0000001813438788__b360819319138">Object Browser</strong> pane, right-click the selected schema and select <strong id="EN-US_TOPIC_0000001813438788__b1768973311318">Drop Schema</strong>. A confirmation dialog is displayed, prompting you to confirm the deletion.</span></li><li id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264861_li63161481"><span>Click <strong id="EN-US_TOPIC_0000001813438788__b1169319402143">OK</strong>. This action will remove the schema from <strong id="EN-US_TOPIC_0000001813438788__b194845621515">Object Browser</strong>.</span><p><p id="EN-US_TOPIC_0000001813438788__en-us_topic_0185264861_p121761945398">A pop-up message and the status bar display the status of the completed operation.</p>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001813438788__section1054254517155"><h4 class="sectiontitle">Refreshing a Schema</h4><p id="EN-US_TOPIC_0000001813438788__p1158312441620">Right-click a schema name and choose <strong id="EN-US_TOPIC_0000001813438788__b1938983816163">Refresh</strong> to refresh all objects in the schema.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="DWS_DS_012.html">Database Management</a></div>
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>