DWS DEVG 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>
This commit is contained in:
2025-05-05 07:44:03 +00:00
committed by zuul
parent 317d6d2384
commit 177cd61a57
1299 changed files with 76719 additions and 57076 deletions

138
a Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
<a name="EN-US_TOPIC_0000001764817397"></a><a name="EN-US_TOPIC_0000001764817397"></a>
<a name="EN-US_TOPIC_0000001764650496"></a><a name="EN-US_TOPIC_0000001764650496"></a>
<h1 class="topictitle1">Using DSC to Migrate SQL Scripts</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p316010150300">The DSC is a CLI tool running on the Linux or Windows OS. It is dedicated to providing customers with simple, fast, and reliable application SQL script migration services. It parses the SQL scripts of source database applications using the built-in syntax migration logic, and converts them to SQL scripts applicable to GaussDB(DWS) databases. You do not need to connect the DSC to a database. It can migrate data in offline mode without service interruption. In GaussDB(DWS), you can run the migrated SQL scripts to restore the database, thereby easily migrating offline databases to the cloud.</p>
<p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p8173195612411">The DSC can migrate SQL scripts of Teradata, Oracle, Netezza, MySQL, and DB2 databases.</p>
<div class="section" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_section1728325511316"><h4 class="sectiontitle">Downloading the DSC SQL Migration Tool</h4><ol id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_ol868111584130"><li id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li14681658161317"><span>Log in to the GaussDB(DWS) console.</span></li><li id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1068220583130"><span>In the navigation tree on the left, choose <strong id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_b17291513171512">Management</strong> &gt; <strong id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_b572931391515">Client Connections</strong>.</span></li><li id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1682145812134"><span>In the <span class="wintitle" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001081821879_wintitle17495719886"><b>Download Client and Driver</b></span> area, click <span class="uicontrol" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001081821879_uicontrol1949551917818"><b>here</b></span> to download the DSC migration tool.</span><p><p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p668255812132">If you have clusters of different versions, the system displays a dialog box, prompting you to select the cluster version and download the client corresponding to the cluster version. In the cluster list on the <span class="wintitle" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001081821879_wintitle38209217615"><b>Cluster Management</b></span> page, click the name of the specified cluster and click the <span class="parmname" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001081821879_parmname1082042564"><b>Basic Information</b></span> tab to view the cluster version.</p>
<div class="fignone" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_fig1990923102215"><span class="figcap"><b>Figure 1 </b>Downloading the tool</span><br><span><img id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_image1146921172210" src="figure/en-us_image_0000001188642272.png" height="142.62055500000002" width="458.85" title="Click to enlarge" class="imgResize"></span></div>
<p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p15720203711118"></p>
</p></li><li id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li2682758191314"><span>After downloading the DSC tool to the local PC, use WinSCP to upload it to a Linux host.</span><p><p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p156822585132">The user who uploads the tool must have the full control permission on the target directory of the Linux host.</p>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p316010150300">The DSC is a CLI tool running on the Linux or Windows OS. It is dedicated to providing customers with simple, fast, and reliable application SQL script migration services. It parses the SQL scripts of source database applications using the built-in syntax migration logic, and converts them to SQL scripts applicable to GaussDB(DWS) databases. You do not need to connect the DSC to a database. It can migrate data in offline mode without service interruption. In GaussDB(DWS), you can run the migrated SQL scripts to restore the database, thereby easily migrating offline databases to the cloud.</p>
<p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p8173195612411">The DSC can migrate SQL scripts of Teradata, Oracle, Netezza, MySQL, and DB2 databases.</p>
<div class="section" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_section1728325511316"><h4 class="sectiontitle">Downloading the DSC SQL Migration Tool</h4><ol id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_ol868111584130"><li id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li14681658161317"><span>Log in to the GaussDB(DWS) console.</span></li><li id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1068220583130"><span>In the navigation tree on the left, choose <strong id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_b17291513171512">Management</strong> &gt; <strong id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_b572931391515">Client Connections</strong>.</span></li><li id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1682145812134"><span>In the <span class="wintitle" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001081821879_wintitle17495719886"><b>Download Client and Driver</b></span> area, click <span class="uicontrol" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001081821879_uicontrol1949551917818"><b>here</b></span> to download the DSC migration tool.</span><p><p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p668255812132">If you have clusters of different versions, the system displays a dialog box, prompting you to select the cluster version and download the client corresponding to the cluster version. In the cluster list on the <span class="wintitle" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001081821879_wintitle38209217615"><b>Cluster Management</b></span> page, click the name of the specified cluster and click the <span class="parmname" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001081821879_parmname1082042564"><b>Basic Information</b></span> tab to view the cluster version.</p>
<div class="fignone" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_fig1990923102215"><span class="figcap"><b>Figure 1 </b>Downloading the tool</span><br><span><img id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_image18891182455119" src="figure/en-us_image_0000002110071384.png"></span></div>
<p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p15720203711118"></p>
</p></li><li id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_li2682758191314"><span>After downloading the DSC tool to the local PC, use WinSCP to upload it to a Linux host.</span><p><p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p156822585132">The user who uploads the tool must have the full control permission on the target directory of the Linux host.</p>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_section72376514154"><h4 class="sectiontitle">Operation Guide for the DSC SQL Syntax Migration Tool</h4><p id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p723765121510">For details, see "DSC - SQL Syntax Migration Tool" in the <em id="EN-US_TOPIC_0000001764817397__en-us_topic_0000001233761831_i1968013441492">Data Warehouse Service Tool Guide</em>.</p>
<div class="section" id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_section72376514154"><h4 class="sectiontitle">Operation Guide for the DSC SQL Syntax Migration Tool</h4><p id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_en-us_topic_0000001082831067_en-us_topic_0000001081821879_p723765121510">For details, see "DSC - SQL Syntax Migration Tool" in the <em id="EN-US_TOPIC_0000001764650496__en-us_topic_0000001233761831_i1968013441492">Data Warehouse Service Tool Guide</em>.</p>
</div>
</div>
<div>
@ -18,10 +18,3 @@
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,29 @@
<a name="EN-US_TOPIC_0000001510163029"></a><a name="EN-US_TOPIC_0000001510163029"></a>
<a name="EN-US_TOPIC_0000001764651048"></a><a name="EN-US_TOPIC_0000001764651048"></a>
<h1 class="topictitle1">Defining Database Objects</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001510163029__en-us_topic_0000001233761859_en-us_topic_0059778336_p8060118"></p>
<h1 class="topictitle1">Creating and Managing GaussDB(DWS) Database Objects</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764651048__en-us_topic_0000001233761859_en-us_topic_0059778336_p8060118"></p>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0025.html">Creating and Managing Databases</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0025.html">Creating and Managing GaussDB(DWS) Databases</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0036.html">Creating and Managing Schemas</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0036.html">Creating and Managing GaussDB(DWS) Schemas</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0028.html">Creating and Managing Tables</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0028.html">Creating and Managing GaussDB(DWS) Tables</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0026.html">Selecting a Table Storage Mode</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0026.html">Selecting a GaussDB(DWS) Table Storage Model</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0037.html">Defining Table Partitions</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0037.html">Creating and Managing GaussDB(DWS) Partitioned Tables</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0038.html">Creating and Managing Indexes</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0038.html">Creating and Managing GaussDB(DWS) Indexes</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0040.html">Creating and Using Sequences</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0040.html">Creating and Using GaussDB(DWS) Sequences</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0039.html">Creating and Managing Views</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0039.html">Creating and Managing GaussDB(DWS) Views</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0041.html">Creating and Managing Scheduled Tasks</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0041.html">Creating and Managing GaussDB(DWS) Scheduled Tasks</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0034.html">Viewing a System Catalog</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0034.html">Viewing GaussDB(DWS) System Catalogs</a></strong><br>
</li>
</ul>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,38 @@
<a name="EN-US_TOPIC_0000001460562756"></a><a name="EN-US_TOPIC_0000001460562756"></a>
<a name="EN-US_TOPIC_0000001764491996"></a><a name="EN-US_TOPIC_0000001764491996"></a>
<h1 class="topictitle1">Creating and Managing Databases</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p1424483702418">A database is a collection of objects such as tables, indexes, views, stored procedures, and operators. GaussDB (DWS) supports the creation of multiple databases. However, a client program can connect to and access only one database at a time, and cross-database query is not supported.</p>
<div class="section" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_section122544389266"><h4 class="sectiontitle">Template and Default Databases</h4><ul id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_ul967143111312"><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li1467163131318">GaussDB (DWS) provides two template databases <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b162801117153210">template0</strong> and <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b1951392133215">template1</strong> and a default database <span id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_text1462184614508">gaussdb</span>.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li81174559332">By default, each newly created database is based on a template database. The GaussDB(DWS) database uses <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b10799102093619">template1</strong> as the template by default. The encoding format is SQL_ASCII, and user-defined character encoding is not allowed. If you need to specify the character encoding when creating a database, use <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b538912818381">template0</strong> to create the database.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li127281040151617">Do not use a client or any other tools to connect to or to perform operations on both the two template databases.<div class="note" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_note04711502378"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p140117143366">You can run the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b69417832541155">show server_encoding</strong> command to view the current database encoding.</p>
<h1 class="topictitle1">Creating and Managing GaussDB(DWS) Databases</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p1424483702418">A database is a collection of objects such as tables, indexes, views, stored procedures, and operators. GaussDB (DWS) supports the creation of multiple databases. However, a client program can connect to and access only one database at a time, and cross-database query is not supported.</p>
<div class="section" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_section122544389266"><h4 class="sectiontitle">Template and Default Databases</h4><ul id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_ul967143111312"><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li1467163131318">GaussDB (DWS) provides two template databases <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b162801117153210">template0</strong> and <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b1951392133215">template1</strong> and a default database <span id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_text1462184614508">gaussdb</span>.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li81174559332">By default, each newly created database is based on a template database. The GaussDB(DWS) database uses <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b10799102093619">template1</strong> as the template by default. The encoding format is SQL_ASCII, and user-defined character encoding is not allowed. If you need to specify the character encoding when creating a database, use <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b538912818381">template0</strong> to create the database.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li127281040151617">Do not use a client or any other tools to connect to or to perform operations on both the two template databases.<div class="note" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_note04711502378"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p140117143366">You can run the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b69417832541155">show server_encoding</strong> command to view the current database encoding.</p>
</div></div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_section17897114011280"><h4 class="sectiontitle">Creating a Database.</h4><p id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p1668754282810">Run the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b787319574112">CREATE DATABASE</strong> statement to create a database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen15688133611315"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_section17897114011280"><h4 class="sectiontitle">Creating a Database.</h4><p id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p1668754282810">Run the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b787319574112">CREATE DATABASE</strong> statement to create a database.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen15688133611315"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_n8dc53fedcf784d9d893889ddf4f017a9"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_u26fc21318fdc40be947784c5bb32d12e"><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li531613183910">When you create a database, if the length of the database name exceeds 63 bytes, the server truncates the database name and retains the first 63 bytes. Therefore, you are advised to set the length of the database name to a value less than or equal to 63 bytes. Do not use multi-byte characters as object names. If an object whose name is truncated mistakenly cannot be deleted, delete the object using the name before the truncation, or manually delete it from the corresponding system catalog on each node.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_le053a9b8847849e4a5ad2b0b8a1f5cb5">Database names must comply with the naming convention of SQL identifiers. The current user automatically becomes the owner of this new database.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_l83e13eb3fd8342088f1842d8988073f2">If a database system is used to support independent users and projects, store them in different databases.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_l97f426d01b6849aca030305671998995">If the projects or users are associated with each other and share resources, store them in different schemas in the same database.</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li62226497411">A maximum of 128 databases can be created in GaussDB(DWS).</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li136513131362">You must have the permission to create a database or the permission that the system administrator owns.</li></ul>
<div class="note" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_n8dc53fedcf784d9d893889ddf4f017a9"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_u26fc21318fdc40be947784c5bb32d12e"><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li531613183910">When you create a database, if the length of the database name exceeds 63 bytes, the server truncates the database name and retains the first 63 bytes. Therefore, you are advised to set the length of the database name to a value less than or equal to 63 bytes. Do not use multi-byte characters as object names. If an object whose name is truncated mistakenly cannot be deleted, delete the object using the name before the truncation, or manually delete it from the corresponding system catalog on each node.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_le053a9b8847849e4a5ad2b0b8a1f5cb5">Database names must comply with the naming convention of SQL identifiers. The current user automatically becomes the owner of this new database.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_l83e13eb3fd8342088f1842d8988073f2">If a database system is used to support independent users and projects, store them in different databases.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_l97f426d01b6849aca030305671998995">If the projects or users are associated with each other and share resources, store them in different schemas in the same database.</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li62226497411">A maximum of 128 databases can be created in GaussDB(DWS).</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li136513131362">You must have the permission to create a database or the permission that the system administrator owns.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_section463533692716"><h4 class="sectiontitle">Viewing Databases</h4><div class="p" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p1318563110321">To view databases, perform the following steps:<ul id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_ul2037492910324"><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li1537514296324">Run the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b201325624441155">\l</strong> meta-command to view the database list of the database system.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen163751293321"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="err">\</span><span class="n">l</span>
<div class="section" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_section463533692716"><h4 class="sectiontitle">Viewing Databases</h4><div class="p" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p1318563110321">To view databases, perform the following steps:<ul id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_ul2037492910324"><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li1537514296324">Run the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b201325624441155">\l</strong> meta-command to view the database list of the database system.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen163751293321"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="err">\</span><span class="n">l</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li123751029193212">Querying the database list using the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b6289120103110">pg_database</strong> system catalog<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen33751129193214"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_database</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li123751029193212">Querying the database list using the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b6289120103110">pg_database</strong> system catalog<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen33751129193214"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_database</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_section1548916712337"><h4 class="sectiontitle">Modifying a Database</h4><p id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p2010818293414">You can use the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b66291032302">ALTER DATABASE</strong> statement modify database configuration such as the database owner, name, and default settings.</p>
<ul id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_ul1110892918418"><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li7108929134119">Run the following command to set the default search path for the database:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen11108152994110"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="w"> </span><span class="k">SET</span><span class="w"> </span><span class="n">search_path</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">pa_catalog</span><span class="p">,</span><span class="k">public</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_section1548916712337"><h4 class="sectiontitle">Modifying a Database</h4><p id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p2010818293414">You can use the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b66291032302">ALTER DATABASE</strong> statement modify database configuration such as the database owner, name, and default settings.</p>
<ul id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_ul1110892918418"><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li7108929134119">Run the following command to set the default search path for the database:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen11108152994110"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="w"> </span><span class="k">SET</span><span class="w"> </span><span class="n">search_path</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">pa_catalog</span><span class="p">,</span><span class="k">public</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_li15111529124112">Rename the database.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen611152911411"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">newdatabase</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_li15111529124112">Rename the database.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen611152911411"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">mydatabase</span><span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">newdatabase</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_section025425719419"><h4 class="sectiontitle">Deleting a Database</h4><p id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p29356392422">You can run <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b126202815241155">DROP DATABASE</strong> statement to delete a database. This statement deletes the system catalog of the database and the database directory on the disk. Only the database owner or system administrator can delete a database. A database being accessed by users cannot be deleted, You need to connect to another database before deleting this database.</p>
<div class="p" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_p10381143414217">Run the <strong id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_b18151515143112">DROP DATABASE</strong> statement to delete a database:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001460562756__en-us_topic_0000001188323600_screen6381134114216"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">newdatabase</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_section025425719419"><h4 class="sectiontitle">Deleting a Database</h4><p id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p29356392422">You can run <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b126202815241155">DROP DATABASE</strong> statement to delete a database. This statement deletes the system catalog of the database and the database directory on the disk. Only the database owner or system administrator can delete a database. A database being accessed by users cannot be deleted, You need to connect to another database before deleting this database.</p>
<div class="p" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_p10381143414217">Run the <strong id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_b18151515143112">DROP DATABASE</strong> statement to delete a database:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491996__en-us_topic_0000001188323600_screen6381134114216"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">DATABASE</span><span class="w"> </span><span class="n">newdatabase</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
@ -40,7 +40,7 @@
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Defining Database Objects</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Creating and Managing GaussDB(DWS) Database Objects</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
<a name="EN-US_TOPIC_0000002125650482"></a><a name="EN-US_TOPIC_0000002125650482"></a>
<h1 class="topictitle1">GaussDB(DWS) Foreign Table Function Development Specifications</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_section7984144034412"><h4 class="sectiontitle">Rule 4.1 Deploying GDS on an Independent Server Outside the GaussDB(DWS) Cluster</h4><div class="note" id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_note1893311844614"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p1418881295812"><strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b1963863015016">Impact of rule violation:</strong></p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p0738165017216">If GDS is deployed in a GaussDB(DWS) cluster, it contends for resources with CNs or DNs in the cluster, which leads to a decline in the performance of both GDS and CNs or DNs.</p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p10188141245817"><strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b7519124332017">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_ul1173125635215"><li id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_li77841258105210">Deploy GDS on an independent server outside the GaussDB(DWS) cluster.</li><li id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_li138341507506">Ensure that the disk capacity of the GDS server and the network bandwidth between the GDS server and the GaussDB(DWS) cluster are planned according to the requirements.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_section171861828194514"><h4 class="sectiontitle">Rule 4.2 Avoiding Concurrent Access to Multiple Collaborative Analysis Foreign Tables Across Clusters</h4><div class="note" id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_note319293211509"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p4608437155020"><strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b199031941205312">Principle description</strong>: When cluster A accesses data in cluster B through collaborative analysis, all DNs in cluster A establish connections and active sessions with the CNs in cluster B.</p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p181920321503"><strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b106133351773">Impact of rule violation:</strong></p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p81642546215">The CNs in cluster B are overloaded. As a result, the number of connections and active sessions exceeds the threshold, and the access is abnormal.</p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p219293265013"><strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b319253245017">Solution:</strong></p>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p768125532113">Use foreign tables to access a single table instead of performing concurrent queries on multiple foreign tables. If it is not possible to avoid concurrent queries, calculate and limit the number of concurrent queries based on the number of DNs in cluster A and the normal service volume of cluster B. Additionally, increasing the values of <strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b297124619276">max_active_statements</strong> and <strong id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_b1350118582271">max_connections</strong> can help solve the problem.</p>
</div></div>
<p id="EN-US_TOPIC_0000002125650482__en-us_topic_0000002160959045_p41831541101620"></p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development Design Proposal</a></div>
</div>
</div>

View File

@ -1,13 +1,13 @@
<a name="EN-US_TOPIC_0000001510162977"></a><a name="EN-US_TOPIC_0000001510162977"></a>
<a name="EN-US_TOPIC_0000001764491252"></a><a name="EN-US_TOPIC_0000001764491252"></a>
<h1 class="topictitle1">Viewing a System Catalog</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_ae980e1a43a884b39b5f435b15277eef2">In addition to the created tables, a database contains many system catalogs These system catalogs contain cluster installation information and information about various queries and processes in <span id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_text1093275459">GaussDB(DWS)</span>. You can collect information about the database by querying the system catalog.</p>
<div class="section" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sa8ee1f08a3e74ba1ba2ff4920ee1054b"><h4 class="sectiontitle">Querying Database Tables</h4><p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_p143354763216">For example, query the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_b15601359195415">PG_TABLES</strong> system catalog for all tables in the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_b15833133575513">public</strong> schema.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sf44fb4207ae14ea895df3fa026f79728"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">distinct</span><span class="p">(</span><span class="n">tablename</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_tables</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">SCHEMANAME</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'public'</span><span class="p">;</span><span class="w"> </span>
<h1 class="topictitle1">Viewing GaussDB(DWS) System Catalogs</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_ae980e1a43a884b39b5f435b15277eef2">In addition to the created tables, a database contains many system catalogs These system catalogs contain cluster installation information and information about various queries and processes in <span id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_text1093275459">GaussDB(DWS)</span>. You can collect information about the database by querying the system catalog.</p>
<div class="section" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sa8ee1f08a3e74ba1ba2ff4920ee1054b"><h4 class="sectiontitle">Querying Database Tables</h4><p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_p143354763216">For example, query the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_b15601359195415">PG_TABLES</strong> system catalog for all tables in the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_b15833133575513">public</strong> schema.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sf44fb4207ae14ea895df3fa026f79728"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="k">distinct</span><span class="p">(</span><span class="n">tablename</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_tables</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">SCHEMANAME</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'public'</span><span class="p">;</span><span class="w"> </span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_p335347103213">Information similar to the following is displayed:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sd7ec8e21d0d44a5c844a70cbc5fb5983"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_p335347103213">Information similar to the following is displayed:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sd7ec8e21d0d44a5c844a70cbc5fb5983"><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>
@ -27,8 +27,8 @@
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s81b82ca0080346e397ff2c3313239101"><h4 class="sectiontitle">Viewing Database Users</h4><p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_a77389c483fb54cf49203dac0c87cda81">You can run the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695257">PG_USER</strong> command to view the list of all users in the database, and view the user ID (<strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_b96099368575">USESYSID</strong>) and permissions.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s737b1dfd4ede4c558aa03127ab48b783"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<div class="section" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s81b82ca0080346e397ff2c3313239101"><h4 class="sectiontitle">Viewing Database Users</h4><p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_a77389c483fb54cf49203dac0c87cda81">You can run the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695257">PG_USER</strong> command to view the list of all users in the database, and view the user ID (<strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_b96099368575">USESYSID</strong>) and permissions.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s737b1dfd4ede4c558aa03127ab48b783"><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>
@ -49,8 +49,8 @@
<span class="p">(</span><span class="mi">4</span><span class="w"> </span><span class="k">rows</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_p335144793215"><span id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_text821667906">GaussDB(DWS)</span> uses Ruby to perform routine management and maintenance. You can add <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695818">WHERE usesysid &gt; 10</strong> to the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695843">SELECT</strong> statement to filter queries so that only specified user names are displayed.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s24ee0dc1d2f84b7a9ce403e35c299414"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_p335144793215"><span id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_text821667906">GaussDB(DWS)</span> uses Ruby to perform routine management and maintenance. You can add <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695818">WHERE usesysid &gt; 10</strong> to the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270695843">SELECT</strong> statement to filter queries so that only specified user names are displayed.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s24ee0dc1d2f84b7a9ce403e35c299414"><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>
@ -70,24 +70,24 @@
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s1b3d6bd2b52e4a72ac757510c65946e8"><h4 class="sectiontitle">Viewing and Stopping the Running Query Statements</h4><p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_p15751841493">You can view the running query statements in the <a href="dws_04_0755.html">PG_STAT_ACTIVITY</a> view. Do as follows:</p>
<ol id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_ol4911599615"><li id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_l66435131bbcf4c2392f0e993b49df1bc"><span>Set the parameter <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617325">track_activities</strong> to <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617331">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s8e01a272003b4e4486b3c2620b42792a"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SET</span><span class="w"> </span><span class="n">track_activities</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">on</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s1b3d6bd2b52e4a72ac757510c65946e8"><h4 class="sectiontitle">Viewing and Stopping the Running Query Statements</h4><p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_p15751841493">You can view the running query statements in the <a href="dws_04_0757.html">PG_STAT_ALL_INDEXES</a> view. Do as follows:</p>
<ol id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_ol4911599615"><li id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_l66435131bbcf4c2392f0e993b49df1bc"><span>Set the parameter <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617325">track_activities</strong> to <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617331">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s8e01a272003b4e4486b3c2620b42792a"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SET</span><span class="w"> </span><span class="n">track_activities</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">on</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_af670d4cf94794f4784b7e07a529ac954">The database collects the running information about active queries only if the parameter is set to <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706102059">on</strong>.</p>
</p></li><li id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_ld2e98835f3994a039545608291001dc3"><span>View the running query statements. Run the following command to view the database names, users, query statuses, and PIDs of the running query statements:</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sc0d197d66e97482c842e552059ee04cd"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="p">,</span><span class="w"> </span><span class="n">usename</span><span class="p">,</span><span class="w"> </span><span class="k">state</span><span class="p">,</span><span class="n">pid</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_stat_activity</span><span class="p">;</span>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_af670d4cf94794f4784b7e07a529ac954">The database collects the running information about active queries only if the parameter is set to <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706102059">on</strong>.</p>
</p></li><li id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_ld2e98835f3994a039545608291001dc3"><span>View the running query statements. Run the following command to view the database names, users, query statuses, and PIDs of the running query statements:</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sc0d197d66e97482c842e552059ee04cd"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="p">,</span><span class="w"> </span><span class="n">usename</span><span class="p">,</span><span class="w"> </span><span class="k">state</span><span class="p">,</span><span class="n">pid</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_stat_activity</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_a6e7feb6c488d4e2994bfb839e1cc7b33">If the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617455">state</strong> column is <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706113432">idle</strong>, the connection is idle and requires a user to enter a command.</p>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_a64668f7f1609417092332c2482b65926">To identify only active query statements, run the following command:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sc436077ab0d84e7cb4268fb30b873889"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="p">,</span><span class="w"> </span><span class="n">usename</span><span class="p">,</span><span class="w"> </span><span class="k">state</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_stat_activity</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">state</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">'idle'</span><span class="p">;</span>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_a6e7feb6c488d4e2994bfb839e1cc7b33">If the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270617455">state</strong> column is <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706113432">idle</strong>, the connection is idle and requires a user to enter a command.</p>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_a64668f7f1609417092332c2482b65926">To identify only active query statements, run the following command:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sc436077ab0d84e7cb4268fb30b873889"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">datname</span><span class="p">,</span><span class="w"> </span><span class="n">usename</span><span class="p">,</span><span class="w"> </span><span class="k">state</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_stat_activity</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">state</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">'idle'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_lb1d9874cfd5f4ab3b0a60507a2fff2d1"><span>To cancel queries that have been running for a long time, use the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270614827">PG_TERMINATE_BACKEND</strong> function to end sessions based on the thread ID.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s3a8d2575846e4e8d8775980655550299"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">PG_TERMINATE_BACKEND</span><span class="p">(</span><span class="mi">139834759993104</span><span class="p">);</span>
</p></li><li id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_lb1d9874cfd5f4ab3b0a60507a2fff2d1"><span>To cancel queries that have been running for a long time, use the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b84235270614827">PG_TERMINATE_BACKEND</strong> function to end sessions based on the thread ID.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s3a8d2575846e4e8d8775980655550299"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">PG_TERMINATE_BACKEND</span><span class="p">(</span><span class="mi">139834759993104</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_ac3edfdcdfbf542e7974ef962fc9f9e17">If information similar to the following is displayed, the session is successfully terminated:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_sa32eca25959c47b2a9c5216e77c59fd4"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_ac3edfdcdfbf542e7974ef962fc9f9e17">If information similar to the following is displayed, the session is successfully terminated:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_sa32eca25959c47b2a9c5216e77c59fd4"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">PG_TERMINATE_BACKEND</span>
@ -96,13 +96,13 @@
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
<div class="p" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_p205727191681">If information similar to the following is displayed, a user has terminated the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s9493c1d58b234964b69411ba6eb0f73b"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<div class="p" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_p205727191681">If information similar to the following is displayed, a user has terminated the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s9493c1d58b234964b69411ba6eb0f73b"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">FATAL</span><span class="p">:</span><span class="w"> </span><span class="n">terminating</span><span class="w"> </span><span class="k">connection</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="n">administrator</span><span class="w"> </span><span class="n">command</span>
<span class="n">FATAL</span><span class="p">:</span><span class="w"> </span><span class="n">terminating</span><span class="w"> </span><span class="k">connection</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="n">administrator</span><span class="w"> </span><span class="n">command</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_nff00792959ee47f8acf42b49a212e23b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_a66709dd5c91841db983b6368abcdda10">If the <strong id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706143550">PG_TERMINATE_BACKEND</strong> function is used to terminate the backend threads of the current session, the gsql client will be reconnected automatically rather than be logged out. The message "The connection to the server was lost." is returned. Attempting reset: Succeeded."</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510162977__en-us_topic_0000001233761821_s7a418a861e944b4f82fecf05d22aeda8"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<div class="note" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_nff00792959ee47f8acf42b49a212e23b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_a66709dd5c91841db983b6368abcdda10">If the <strong id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_en-us_topic_0100315815_b842352706143550">PG_TERMINATE_BACKEND</strong> function is used to terminate the backend threads of the current session, the gsql client will be reconnected automatically rather than be logged out. The message "The connection to the server was lost." is returned. Attempting reset: Succeeded."</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491252__en-us_topic_0000001233761821_s7a418a861e944b4f82fecf05d22aeda8"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">FATAL</span><span class="p">:</span><span class="w"> </span><span class="n">terminating</span><span class="w"> </span><span class="k">connection</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="n">administrator</span><span class="w"> </span><span class="n">command</span>
<span class="n">FATAL</span><span class="p">:</span><span class="w"> </span><span class="n">terminating</span><span class="w"> </span><span class="k">connection</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="k">to</span><span class="w"> </span><span class="n">administrator</span><span class="w"> </span><span class="n">command</span>
@ -116,7 +116,7 @@
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Defining Database Objects</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Creating and Managing GaussDB(DWS) Database Objects</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,24 @@
<a name="EN-US_TOPIC_0000001510402221"></a><a name="EN-US_TOPIC_0000001510402221"></a>
<a name="EN-US_TOPIC_0000001764650996"></a><a name="EN-US_TOPIC_0000001764650996"></a>
<h1 class="topictitle1">Creating and Managing Views</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p1222114510216">Views allow users to save queries. Views are not physically stored on disks. Queries to a view run as subqueries. A database only stores the definition of a view and does not store its data. The data is still stored in the original base table. If data in the base table changes, the data in the view changes accordingly. In this sense, a view is like a window through which users can know their interested data and data changes in the database. A view is triggered every time it is referenced.</p>
<div class="section" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_se07db171a2b64c3fb143727491321a84"><h4 class="sectiontitle">Creating a view</h4><div class="p" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p5748154345117">Run the <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b3388382103">CREATE VIEW</strong> command to create a view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_screen4748144395117"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></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="k">VIEW</span><span class="w"> </span><span class="n">MyView</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">customer</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">150</span><span class="p">;</span>
<h1 class="topictitle1">Creating and Managing GaussDB(DWS) Views</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p1222114510216">Views allow users to save queries. Views are not physically stored on disks. Queries to a view run as subqueries. A database only stores the definition of a view and does not store its data. The data is still stored in the original base table. If data in the base table changes, the data in the view changes accordingly. In this sense, a view is like a window through which users can know their interested data and data changes in the database. A view is triggered every time it is referenced.</p>
<div class="section" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_se07db171a2b64c3fb143727491321a84"><h4 class="sectiontitle">Creating a view</h4><div class="p" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p5748154345117">Run the <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b3388382103">CREATE VIEW</strong> command to create a view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_screen4748144395117"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></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="k">VIEW</span><span class="w"> </span><span class="n">MyView</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">tpcds</span><span class="p">.</span><span class="n">customer</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">c_customer_sk</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">150</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="note" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_note1375044310517"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p177509433510">The <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b972653521499">OR REPLACE</strong> parameter in this command is optional. It indicates that if the view exists, the new view will replace the existing view.</p>
<div class="note" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_note1375044310517"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p177509433510">The <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b972653521499">OR REPLACE</strong> parameter in this command is optional. It indicates that if the view exists, the new view will replace the existing view.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_section58811612145614"><h4 class="sectiontitle">View Details</h4><ul id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_ul1935918240561"><li id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_ld156225587b74e3b87897058f1c64c01">View the <em id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_i1940751652314">MyView</em> view. Real-time data will be returned.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_s1c95a4d61a4246e692a17dfe51f3090c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">myview</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_section58811612145614"><h4 class="sectiontitle">View Details</h4><ul id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_ul1935918240561"><li id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_ld156225587b74e3b87897058f1c64c01">View the <em id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_i1940751652314">MyView</em> view. Real-time data will be returned.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_s1c95a4d61a4246e692a17dfe51f3090c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">myview</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_l9cb9329987774605ae4dfca6ac7315bb">Run the following command to query the views in the current user:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_s36fb946788504784b5fdef0e59badd89"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">user_views</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_l9cb9329987774605ae4dfca6ac7315bb">Run the following command to query the views in the current user:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_s36fb946788504784b5fdef0e59badd89"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">user_views</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_l11ca417ba0314592b8addcf7aceae216">Run the following command to query all views:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_s95cf13ccf3134aa7a0b79ff2baafd345"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">dba_views</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_l11ca417ba0314592b8addcf7aceae216">Run the following command to query all views:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_s95cf13ccf3134aa7a0b79ff2baafd345"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">dba_views</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd">View details about a specified view.<div class="p" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_af4c6848c60274f1fb2826ab5ac0a1839"><a name="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd"></a><a name="en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd"></a>Run the following command to view details about the dba_users view:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_s169fca93eb264b91b87f0c3e239ed28d"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
</li><li id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd">View details about a specified view.<div class="p" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_af4c6848c60274f1fb2826ab5ac0a1839"><a name="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd"></a><a name="en-us_topic_0000001188323660_l9c0976676c1f42e298a5839b786156cd"></a>Run the following command to view details about the dba_users view:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_s169fca93eb264b91b87f0c3e239ed28d"><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>
@ -38,21 +38,21 @@
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_section45851157145414"><h4 class="sectiontitle">Rebuilding a View</h4><p id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p183837313551">Run the <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b43816219174">ALTER VIEW</strong> command to rebuild a view without entering query statements.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_screen1480125020551"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">VIEW</span><span class="w"> </span><span class="n">myview</span><span class="w"> </span><span class="n">REBUILD</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_section45851157145414"><h4 class="sectiontitle">Rebuilding a View</h4><p id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p183837313551">Run the <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b43816219174">ALTER VIEW</strong> command to rebuild a view without entering query statements.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_screen1480125020551"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">VIEW</span><span class="w"> </span><span class="n">myview</span><span class="w"> </span><span class="n">REBUILD</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_section15139145913534"><h4 class="sectiontitle">Deleting a View</h4><div class="p" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p1118103719543">Run the <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b1020032241919">DROP VIEW</strong> command to delete a view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_screen1211893725413"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">VIEW</span><span class="w"> </span><span class="n">myview</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_section15139145913534"><h4 class="sectiontitle">Deleting a View</h4><div class="p" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p1118103719543">Run the <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b1020032241919">DROP VIEW</strong> command to delete a view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_screen1211893725413"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">VIEW</span><span class="w"> </span><span class="n">myview</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<p id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_p18486161614592">DROP VIEW ... The <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b68310464199">CASCADE</strong> command can be used to delete objects that depend on the view. For example, view A depends on view B. If view B is deleted, view A will also be deleted. Without the CASCADE option, the <strong id="EN-US_TOPIC_0000001510402221__en-us_topic_0000001188323660_b31880972115">DROP VIEW</strong> command will fail.</p>
<p id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_p18486161614592">DROP VIEW ... The <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b68310464199">CASCADE</strong> command can be used to delete objects that depend on the view. For example, view A depends on view B. If view B is deleted, view A will also be deleted. Without the CASCADE option, the <strong id="EN-US_TOPIC_0000001764650996__en-us_topic_0000001188323660_b31880972115">DROP VIEW</strong> command will fail.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Defining Database Objects</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Creating and Managing GaussDB(DWS) Database Objects</a></div>
</div>
</div>

View File

@ -1,10 +1,10 @@
<a name="EN-US_TOPIC_0000001510283769"></a><a name="EN-US_TOPIC_0000001510283769"></a>
<a name="EN-US_TOPIC_0000001764492036"></a><a name="EN-US_TOPIC_0000001764492036"></a>
<h1 class="topictitle1">Creating and Using Sequences</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p111618311243">A sequence is a database object that generates unique integers according to a certain rule and is usually used to generate primary key values.</p>
<div class="p" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p510074455414">You can create a sequence for a column in either of the following methods:<ul id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_ul9475346173310"><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li6850853153315">Set the data type of a column to sequence integer. A sequence will be automatically created by the database for this column.</li><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li15475446203315">Use <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b17633613419">CREATE SEQUENCE</strong> to create a new sequenc. Use the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b1899031717362">nextval('</strong><em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i4253142493620">sequence_name</em><strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b355862015365">')</strong> function to increment the sequence and return a new value. Specify the default value of the column as the sequence value returned by the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b161655119375">nextval('</strong>sequence_name<strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b1536123193710">')</strong> function. In this way, this column can be used as a unique identifier.</li></ul>
<h1 class="topictitle1">Creating and Using GaussDB(DWS) Sequences</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p111618311243">A sequence is a database object that generates unique integers according to a certain rule and is usually used to generate primary key values.</p>
<div class="p" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p510074455414">You can create a sequence for a column in either of the following methods:<ul id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_ul9475346173310"><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li6850853153315">Set the data type of a column to sequence integer. A sequence will be automatically created by the database for this column.</li><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li15475446203315">Use <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b17633613419">CREATE SEQUENCE</strong> to create a new sequenc. Use the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b1899031717362">nextval('</strong><em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i4253142493620">sequence_name</em><strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b355862015365">')</strong> function to increment the sequence and return a new value. Specify the default value of the column as the sequence value returned by the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b161655119375">nextval('</strong>sequence_name<strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b1536123193710">')</strong> function. In this way, this column can be used as a unique identifier.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_sa82c57fda672457ea8c6fa934915ba5c"><h4 class="sectiontitle">Creating a Sequence.</h4><div class="p" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p19100144410545">Method 1: Set the data type of a column to a sequence integer. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_sa01899b22f364d91badd0a3689d3a53e"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<div class="section" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_sa82c57fda672457ea8c6fa934915ba5c"><h4 class="sectiontitle">Creating a Sequence.</h4><div class="p" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p19100144410545">Method 1: Set the data type of a column to a sequence integer. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_sa01899b22f364d91badd0a3689d3a53e"><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>
@ -16,11 +16,11 @@
</pre></div></td></tr></table></div>
</div>
</div>
<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_a6e8080438eb2433ea9ea9606b5e8c92e">Method 2: Create a sequence and set the initial value of the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b17032018804161">nextval</strong>('<em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i12149377144161">sequence_name</em>') function to the default value of a column. You can cache a specific number of sequence values to reduce the requests to the GTM, improving the performance.</p>
<ol id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_ol128283377453"><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li208281037164517">Create a sequence.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_screen1282893754511"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="k">cache</span><span class="w"> </span><span class="mi">100</span><span class="p">;</span>
<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_a6e8080438eb2433ea9ea9606b5e8c92e">Method 2: Create a sequence and set the initial value of the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b17032018804161">nextval</strong>('<em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i12149377144161">sequence_name</em>') function to the default value of a column. You can cache a specific number of sequence values to reduce the requests to the GTM, improving the performance.</p>
<ol id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_ol128283377453"><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li208281037164517">Create a sequence.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_screen1282893754511"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="k">cache</span><span class="w"> </span><span class="mi">100</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li15580165544516">Set the initial value of the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b96682320327">nextval</strong>('<em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i766818314322">sequence_name</em>') function to the default value of a column.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_screen1858075515456"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
</li><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li15580165544516">Set the initial value of the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b96682320327">nextval</strong>('<em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i766818314322">sequence_name</em>') function to the default value of a column.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_screen1858075515456"><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>
@ -32,27 +32,27 @@
</pre></div></td></tr></table></div>
</div>
</li></ol>
<div class="note" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_nebd89c17c96e4d4281ef4594972b179b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_a62e8fcef7cee4ddcba95bdfd41e2ad43">Methods 1 and 2 are similar except that method 2 specifies cache for the sequence. A sequence using cache has holes (non-consecutive values, for example, 1, 4, 5) and cannot keep the order of the values. After a sequence is deleted, its sub-sequences will be deleted automatically. A sequence shared by multiple columns is not forbidden in a database, but you are not advised to do that.</p>
<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_a712093feed8c415bb59590d3b9dffc0f">Currently, the preceding two methods cannot be used for existing tables.</p>
<div class="note" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_nebd89c17c96e4d4281ef4594972b179b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_a62e8fcef7cee4ddcba95bdfd41e2ad43">Methods 1 and 2 are similar except that method 2 specifies cache for the sequence. A sequence using cache has holes (non-consecutive values, for example, 1, 4, 5) and cannot keep the order of the values. After a sequence is deleted, its sub-sequences will be deleted automatically. A sequence shared by multiple columns is not forbidden in a database, but you are not advised to do that.</p>
<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_a712093feed8c415bb59590d3b9dffc0f">Currently, the preceding two methods cannot be used for existing tables.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_section273144710268"><h4 class="sectiontitle">Modifying a Sequence</h4><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p17243185212263">The <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b1161884813418">ALTER SEQUENCE</strong> statement changes the attributes of an existing sequence, including the owner, owning column, and maximum value.</p>
<ul id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_ul1281573592820"><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li2815173516286">Associate the sequence with a column.<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p7259193612381"><a name="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li2815173516286"></a><a name="en-us_topic_0000001233883175_li2815173516286"></a>The sequence will be deleted when you delete the column or the table where the column resides.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_saea6cfa21d814de4a659bdd5df63e056"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="n">OWNED</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">T2</span><span class="p">.</span><span class="n">id</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_section273144710268"><h4 class="sectiontitle">Modifying a Sequence</h4><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p17243185212263">The <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b1161884813418">ALTER SEQUENCE</strong> statement changes the attributes of an existing sequence, including the owner, owning column, and maximum value.</p>
<ul id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_ul1281573592820"><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li2815173516286">Associate the sequence with a column.<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p7259193612381"><a name="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li2815173516286"></a><a name="en-us_topic_0000001233883175_li2815173516286"></a>The sequence will be deleted when you delete the column or the table where the column resides.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_saea6cfa21d814de4a659bdd5df63e056"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="n">OWNED</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">T2</span><span class="p">.</span><span class="n">id</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_li716964462815">Modify the maximum value of <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b20931699594161">serial</strong> to <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b7295424924161">300</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_screen69312213114"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="k">MAXVALUE</span><span class="w"> </span><span class="mi">300</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_li716964462815">Modify the maximum value of <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b20931699594161">serial</strong> to <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b7295424924161">300</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_screen69312213114"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="w"> </span><span class="k">MAXVALUE</span><span class="w"> </span><span class="mi">300</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_section148219245186"><h4 class="sectiontitle">Deleting a Sequence</h4><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_p2142184591812">Run the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b11952930481">DROP SEQUENCE</strong> command to delete a sequence. For example, to delete the sequence named <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b1479516496818">seq1</strong>, run the following command:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_screen1559112539181"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_section148219245186"><h4 class="sectiontitle">Deleting a Sequence</h4><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_p2142184591812">Run the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b11952930481">DROP SEQUENCE</strong> command to delete a sequence. For example, to delete the sequence named <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b1479516496818">seq1</strong>, run the following command:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_screen1559112539181"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="n">SEQUENCE</span><span class="w"> </span><span class="n">seq1</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_s100b6d4658154113becab048fd2be2e2"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_a0f82b560bdf74713b18ce50436723504">Sequence values are generated by the GTM. By default, each request for a sequence value is sent to the GTM. The GTM calculates the result of the current value plus the step and then returns the result. As GTM is a globally unique node, generating default sequence numbers can cause performance issues. For operations that need frequent sequence number generation, such as bulkload data import, this is not recommended. For example, the <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b4982598334161">INSERT FROM SELECT</strong> statement has poor performance in the following scenario:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_s9a3a6763887b4f3d8ced3cb3bbe13fe7"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<div class="section" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_s100b6d4658154113becab048fd2be2e2"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_a0f82b560bdf74713b18ce50436723504">Sequence values are generated by the GTM. By default, each request for a sequence value is sent to the GTM. The GTM calculates the result of the current value plus the step and then returns the result. As GTM is a globally unique node, generating default sequence numbers can cause performance issues. For operations that need frequent sequence number generation, such as bulkload data import, this is not recommended. For example, the <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b4982598334161">INSERT FROM SELECT</strong> statement has poor performance in the following scenario:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_s9a3a6763887b4f3d8ced3cb3bbe13fe7"><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>
@ -67,21 +67,21 @@
<span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">newT1</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">T1</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_aa8ad7b8ae6e04785960cecac9f9f96c8">To improve the performance, run the following statements (assume that data of 10,000 rows will be imported from <em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i2561207904161">T1</em> to <em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i3796884644161">newT1</em>):</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_s8dbe067a7f0e4b47b3012e9afd34e403"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_aa8ad7b8ae6e04785960cecac9f9f96c8">To improve the performance, run the following statements (assume that data of 10,000 rows will be imported from <em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i2561207904161">T1</em> to <em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i3796884644161">newT1</em>):</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_s8dbe067a7f0e4b47b3012e9afd34e403"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">newT1</span><span class="p">(</span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">name</span><span class="p">)</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="n">name</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">T1</span><span class="p">;</span>
<span class="k">SELECT</span><span class="w"> </span><span class="n">SETVAL</span><span class="p">(</span><span class="s1">'newSeq1'</span><span class="p">,</span><span class="mi">10000</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_n1b3ef94778f74cc3a4efd6a73efa3cc9"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_ad47cc27e4a0a4a50b54b0b2cc52a021f">Rollback is not supported by sequence functions, including <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b1438019201391">nextval()</strong> and <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b324432417916">setval()</strong>. The value of the setval function immediately takes effects on nextval in the current session in any cases and takes effects in other sessions only when no cache is specified for them. If cache is specified for a session, it takes effect only after all the cached values have been used. To avoid duplicate values, use setval only when necessary. Do not set it to an existing sequence value or a cached sequence value.</p>
<div class="note" id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_n1b3ef94778f74cc3a4efd6a73efa3cc9"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_ad47cc27e4a0a4a50b54b0b2cc52a021f">Rollback is not supported by sequence functions, including <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b1438019201391">nextval()</strong> and <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b324432417916">setval()</strong>. The value of the setval function immediately takes effect on nextval in the current session in any cases and take effect in other sessions only when no cache is specified for them. If cache is specified for a session, it takes effect only after all the cached values have been used. To avoid duplicate values, use setval only when necessary. Do not set it to an existing sequence value or a cached sequence value.</p>
</div></div>
<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_a63d1fabfa19e48b8a851454b0e0b1ea2">If BulkLoad is used, set sufficient cache for <em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i203932248013">newSeq1</em> and do not set <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b134320561707">Maxvalue</strong> or <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b143615310112">Minvalue</strong>. To improve the performance, database may push down the invocation of <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b139991101526">nextval</strong>('<em id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_i418919151426">sequence_name</em>') to DNs. Currently, the concurrent connection requests that can be processed by the GTM are limited. If there are too many DNs, a large number of concurrent connection requests will be sent to the GTM. In this case, you need to limit the concurrent connection of BulkLoad to save the GTM connection resources. If the target table is a replication table (<strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b366243584161">DISTRIBUTE BY REPLICATION</strong>), pushdown cannot be performed. If the data volume is large, this will be a disaster for the database. In addition, the database space may be exhausted. After the import is complete, do <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b19755615194161">VACUUM FULL</strong>. Therefore, you are not advised to use sequences when BulkLoad is used.</p>
<p id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_ab0129c2c35274c51a5a6fed52b8ad40f">After a sequence is created, a single-row table is maintained on each node to store the sequence definition and value, which is obtained from the last interaction with the GTM rather than updated in real time. The single-row table on a node does not update when other nodes request a new value from the GTM or when the sequence is modified using <strong id="EN-US_TOPIC_0000001510283769__en-us_topic_0000001233883175_b197180393312620">setval</strong>.</p>
<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_a63d1fabfa19e48b8a851454b0e0b1ea2">If BulkLoad is used, set sufficient cache for <em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i203932248013">newSeq1</em> and do not set <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b134320561707">Maxvalue</strong> or <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b143615310112">Minvalue</strong>. To improve the performance, database may push down the invocation of <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b139991101526">nextval</strong>('<em id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_i418919151426">sequence_name</em>') to DNs. Currently, the concurrent connection requests that can be processed by the GTM are limited. If there are too many DNs, a large number of concurrent connection requests will be sent to the GTM. In this case, you need to limit the concurrent connection of BulkLoad to save the GTM connection resources. If the target table is a replication table (<strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b366243584161">DISTRIBUTE BY REPLICATION</strong>), pushdown cannot be performed. If the data volume is large, this will be a disaster for the database. In addition, the database space may be exhausted. After the import is complete, do <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b19755615194161">VACUUM FULL</strong>. Therefore, you are not advised to use sequences when BulkLoad is used.</p>
<p id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_ab0129c2c35274c51a5a6fed52b8ad40f">After a sequence is created, a single-row table is maintained on each node to store the sequence definition and value, which is obtained from the last interaction with the GTM rather than updated in real time. The single-row table on a node does not update when other nodes request a new value from the GTM or when the sequence is modified using <strong id="EN-US_TOPIC_0000001764492036__en-us_topic_0000001233883175_b197180393312620">setval</strong>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Defining Database Objects</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0016.html">Creating and Managing GaussDB(DWS) Database Objects</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,14 @@
<a name="EN-US_TOPIC_0000001510522401"></a><a name="EN-US_TOPIC_0000001510522401"></a>
<a name="EN-US_TOPIC_0000001811609525"></a><a name="EN-US_TOPIC_0000001811609525"></a>
<h1 class="topictitle1">GaussDB(DWS) Database Security Management</h1>
<div id="body1494318882616"><p id="EN-US_TOPIC_0000001510522401__en-us_topic_0059778204_p8060118"></p>
<div id="body1494318882616"><p id="EN-US_TOPIC_0000001811609525__en-us_topic_0059778204_p8060118"></p>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0053.html">Managing Users and Their Permissions</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0053.html">GaussDB(DWS) User and Permissions Management</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0994.html">GaussDB(DWS) Sensitive Data Management</a></strong><br>
</li>

View File

@ -1,18 +1,18 @@
<a name="EN-US_TOPIC_0000001480181366"></a><a name="EN-US_TOPIC_0000001480181366"></a>
<a name="EN-US_TOPIC_0000001764491888"></a><a name="EN-US_TOPIC_0000001764491888"></a>
<h1 class="topictitle1">Managing Users and Their Permissions</h1>
<h1 class="topictitle1">GaussDB(DWS) User and Permissions Management</h1>
<div id="body8662426"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0055.html">Database Users</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0055.html">GaussDB(DWS) Database User Types</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0057.html">User Management</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0057.html">GaussDB(DWS) Database User Management</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0063.html">User-defined Password Policy</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0063.html">Creating a Custom Password Policy for GaussDB(DWS)</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0054.html">Permissions Management</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0054.html">GaussDB(DWS) Database Permissions Management</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0056.html">Separation of Permissions</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0056.html">Separation of Duties in GaussDB(DWS)</a></strong><br>
</li>
</ul>

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
<a name="EN-US_TOPIC_0000001531181593"></a><a name="EN-US_TOPIC_0000001531181593"></a>
<a name="EN-US_TOPIC_0000001811610113"></a><a name="EN-US_TOPIC_0000001811610113"></a>
<h1 class="topictitle1">Database Users</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p254220444810">Without separation of permissions, GaussDB(DWS) supports two types of database accounts: administrator and common user. For details about user types and permissions under separation of permissions, see <a href="dws_04_0056.html#EN-US_TOPIC_0000001480501210">Separation of Permissions</a>.</p>
<ul id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_ul1868561754819"><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li968617177487">The administrator can manage all common users and databases.</li><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li20686201718485">Common users can connect to and access the database, and perform specific database operations and execute SQL statements after being authorized.</li></ul>
<p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p81191305346">Users are authenticated when they log in to the <span id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_text861939956">GaussDB(DWS)</span> database. A user can own databases and database objects (such as tables), and grant permissions of these objects to other users and roles. In addition to system administrators, users with the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b50960243011512">CREATEDB</strong> attribute can create databases and grant permissions to these databases.</p>
<div class="section" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_section6579918144510"><h4 class="sectiontitle">Database User Types</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_table15592195131713" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Database user types</caption><thead align="left"><tr id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_row15931501711"><th align="left" class="cellrowborder" valign="top" width="10%" id="mcps1.3.4.2.2.5.1.1"><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p195942514179">User Type</p>
<h1 class="topictitle1">GaussDB(DWS) Database User Types</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p254220444810">Without separation of permissions, GaussDB(DWS) supports two types of database accounts: administrator and common user. For details about user types and permissions under separation of permissions, see <a href="dws_04_0056.html#EN-US_TOPIC_0000001811610145">Separation of Duties in GaussDB(DWS)</a>.</p>
<ul id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_ul1868561754819"><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li968617177487">The administrator can manage all common users and databases.</li><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li20686201718485">Common users can connect to and access the database, and perform specific database operations and execute SQL statements after being authorized.</li></ul>
<p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p81191305346">Users are authenticated when they log in to the <span id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_text861939956">GaussDB(DWS)</span> database. A user can own databases and database objects (such as tables), and grant permissions of these objects to other users and roles. In addition to system administrators, users with the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b50960243011512">CREATEDB</strong> attribute can create databases and grant permissions to these databases.</p>
<div class="section" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_section6579918144510"><h4 class="sectiontitle">Database User Types</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_table15592195131713" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Database user types</caption><thead align="left"><tr id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_row15931501711"><th align="left" class="cellrowborder" valign="top" width="10%" id="mcps1.3.4.2.2.5.1.1"><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p195942514179">User Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.2"><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p1117103952910">Description</p>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.2"><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p1117103952910">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.3"><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p8594185111719">Allowed Operations</p>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.3"><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p8594185111719">Allowed Operations</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.4"><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p47771456153619">How to Create</p>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.4"><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p47771456153619">How to Create</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_row20594135111713"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p17594115191710">Administrator <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b13783125852518">dbadmin</strong></p>
<tbody><tr id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_row20594135111713"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p17594115191710">Administrator <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b13783125852518">dbadmin</strong></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p269073052517">An administrator, also called a system administrator, is an account with the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b7617351135413">SYSADMIN </strong>attribute.</p>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p269073052517">An administrator, also called a system administrator, is an account with the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b7617351135413">SYSADMIN </strong>attribute.</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p1159535141712">If separation of permissions is not enabled, this account has the highest permission in the system and can perform all operations. The system administrator has the same permissions as the object owner.</p>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p1159535141712">If separation of permissions is not enabled, this account has the highest permission in the system and can perform all operations. The system administrator has the same permissions as the object owner.</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><ul id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_ul131441459202914"><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li166343714309">User <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b115595432618">dbadmin </strong>created during cluster creation on the GaussDB(DWS) management console is a system administrator.</li><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li7145125922912">Use the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b1719124812274">CREATE USER</strong> or <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b17456205018273">ALTER USER</strong> syntax to create an administrator.<pre class="screen" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_screen4761145817259">CREATE USER <em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i276173315223">sysadmin</em> WITH SYSADMIN password '<em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i1996392214229">{Password}</em>';</pre>
<pre class="screen" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_screen13261582272">ALTER USER <em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i984410118232">u1</em> SYSADMIN;</pre>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><ul id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_ul131441459202914"><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li166343714309">User <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b115595432618">dbadmin </strong>created during cluster creation on the GaussDB(DWS) management console is a system administrator.</li><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li7145125922912">Use the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b1719124812274">CREATE USER</strong> or <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b17456205018273">ALTER USER</strong> syntax to create an administrator.<pre class="screen" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_screen4761145817259">CREATE USER <em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i276173315223">sysadmin</em> WITH SYSADMIN password '<em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i1996392214229">{Password}</em>';</pre>
<pre class="screen" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_screen13261582272">ALTER USER <em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i984410118232">u1</em> SYSADMIN;</pre>
</li></ul>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_row195951541715"><td class="cellrowborder" rowspan="2" valign="top" width="10%" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p14595105161717">Common user</p>
<p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p252715354720"></p>
<tr id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_row195951541715"><td class="cellrowborder" rowspan="2" valign="top" width="10%" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p14595105161717">Common user</p>
<p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p252715354720"></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p15951358173">Common user</p>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p15951358173">Common user</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><ul id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_ul89611910203412"><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li79612101346">Use a tool to connect to the database.</li><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li12962161018343">Have the attributes of specific database system operations, such as <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b104293028181852">CREATEDB</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b42385387881852">CREATEROLE</strong>, and <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b50948786081852">SYSADMIN</strong>.</li><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li1296213107340">Access database objects.</li><li id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_li12962141018344">Run SQL statements.</li></ul>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><ul id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_ul89611910203412"><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li79612101346">Use a tool to connect to the database.</li><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li12962161018343">Have the attributes of specific database system operations, such as <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b104293028181852">CREATEDB</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b42385387881852">CREATEROLE</strong>, and <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b50948786081852">SYSADMIN</strong>.</li><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li1296213107340">Access database objects.</li><li id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_li12962141018344">Run SQL statements.</li></ul>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p677765611364">Run the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b20486135515299">CREATE USER</strong> syntax to create a common user.</p>
<pre class="screen" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_screen191761133172618">CREATE USER <em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i53382048174113">u1</em> PASSWORD '<em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i36631725181012">{Password}</em>';</pre>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p677765611364">Run the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b20486135515299">CREATE USER</strong> syntax to create a common user.</p>
<pre class="screen" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_screen191761133172618">CREATE USER <em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i53382048174113">u1</em> PASSWORD '<em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i36631725181012">{Password}</em>';</pre>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_row4526113194710"><td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p0409347152715">Private user</p>
<tr id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_row4526113194710"><td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p0409347152715">Private user</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p291652416506">A user created with the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b23721642311512">INDEPENDENT</strong> attribute in non-separation-of-permissions mode.</p>
<p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p11108114315012">Database administrators can manage (<strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b205609301211512">DROP</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b212561601811512">ALTER</strong>, and <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b191003805911512">TRUNCATE</strong>) objects of private users but cannot access (<strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b32776326711512">INSERT</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b4193836311512">DELETE</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b184949162111512">SELECT</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b150389627111512">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b1423971711512">COPY</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b210071563211512">GRANT</strong>, <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b207253897111512">REVOKE</strong>, and <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b107328697511512">ALTER OWNER</strong>) the objects before being authorized.</p>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p291652416506">A user created with the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b23721642311512">INDEPENDENT</strong> attribute in non-separation-of-permissions mode.</p>
<p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p11108114315012">Database administrators can manage (<strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b205609301211512">DROP</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b212561601811512">ALTER</strong>, and <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b191003805911512">TRUNCATE</strong>) objects of private users but cannot access (<strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b32776326711512">INSERT</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b4193836311512">DELETE</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b184949162111512">SELECT</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b150389627111512">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b1423971711512">COPY</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b210071563211512">GRANT</strong>, <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b207253897111512">REVOKE</strong>, and <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b107328697511512">ALTER OWNER</strong>) the objects before being authorized.</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p147114710272">Use the <strong id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_b738085810321">CREATE USER</strong> syntax to create a private user.</p>
<pre class="screen" id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_screen1953020257272">CREATE USER <em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i470265417105">user_independent </em>WITH INDEPENDENT<em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i2036937171113"> </em>IDENTIFIED BY '<em id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_i270255412103">{Password}'</em>;</pre>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_p147114710272">Use the <strong id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_b738085810321">CREATE USER</strong> syntax to create a private user.</p>
<pre class="screen" id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_screen1953020257272">CREATE USER <em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i470265417105">user_independent </em>WITH INDEPENDENT<em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i2036937171113"> </em>IDENTIFIED BY '<em id="EN-US_TOPIC_0000001811610113__en-us_topic_0000001188323750_i270255412103">{Password}'</em>;</pre>
</td>
</tr>
</tbody>
@ -53,7 +53,7 @@
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0053.html">Managing Users and Their Permissions</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0053.html">GaussDB(DWS) User and Permissions Management</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,51 @@
<a name="EN-US_TOPIC_0000001480021754"></a><a name="EN-US_TOPIC_0000001480021754"></a>
<a name="EN-US_TOPIC_0000001764650916"></a><a name="EN-US_TOPIC_0000001764650916"></a>
<h1 class="topictitle1">User Management</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p1868572342914">You can use <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b177176812178">CREATE USER</strong> and <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b20717186172">ALTER USER</strong> to create and manage database users.</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul18954124143010"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li495444203012">In the non-<a href="dws_04_0056.html#EN-US_TOPIC_0000001480501210">separation-of-permission</a> mode, a <span id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_text10257114155518">GaussDB(DWS)</span> user account can be created and deleted only by a system administrator or a security administrator with the <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b192571420555">CREATEROLE</strong> attribute.</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li99541347309">In separation-of-permission mode, a user account can be created only by a security administrator.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_s5a76876c562240bb9a03705a6487337f"><h4 class="sectiontitle">Creating a User</h4><p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p1573314153610">The <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b962032611406">CREATE USER</strong> statement is used to create a GaussDB (DWS) user. After creating a user, you can use the user to connect to the database.</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_u4bfa4d1112af43318dd434b9cfffcbf0"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li116850349186">Create common user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b3419153524014">u1</strong> and assign the <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b113871438124015">CREATEDB </strong>attribute to the user.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_s892d131194b3404fa2acfc6472700f9f"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="k">CREATEDB</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="s1">'{Password}'</span><span class="p">;</span><span class="w"> </span>
<h1 class="topictitle1">GaussDB(DWS) Database User Management</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p1868572342914">You can use <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b177176812178">CREATE USER</strong> and <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b20717186172">ALTER USER</strong> to create and manage database users.</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul18954124143010"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li495444203012">In the non-<a href="dws_04_0056.html#EN-US_TOPIC_0000001811610145">separation-of-permission</a> mode, a <span id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_text10257114155518">GaussDB(DWS)</span> user account can be created and deleted only by a system administrator or a security administrator with the <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b192571420555">CREATEROLE</strong> attribute.</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li99541347309">In separation-of-permission mode, a user account can be created only by a security administrator.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_s5a76876c562240bb9a03705a6487337f"><h4 class="sectiontitle">Creating a User</h4><p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p1573314153610">The <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b962032611406">CREATE USER</strong> statement is used to create a GaussDB (DWS) user. After creating a user, you can use the user to connect to the database.</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_u4bfa4d1112af43318dd434b9cfffcbf0"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li116850349186">Create common user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b3419153524014">u1</strong> and assign the <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b113871438124015">CREATEDB </strong>attribute to the user.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_s892d131194b3404fa2acfc6472700f9f"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="k">CREATEDB</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="s1">'{Password}'</span><span class="p">;</span><span class="w"> </span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_lccbf77bee88541569c5e40005095843d">To create the system administrator <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b4538194264020">mydbadmin</strong>, you need to specify the <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b095615443403">SYSADMIN </strong>parameter.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_screen325453331915"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">mydbadmin</span><span class="w"> </span><span class="n">sysadmin</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="s1">'{Password}'</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_lccbf77bee88541569c5e40005095843d">To create the system administrator <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b4538194264020">mydbadmin</strong>, you need to specify the <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b095615443403">SYSADMIN </strong>parameter.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_screen325453331915"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">mydbadmin</span><span class="w"> </span><span class="n">sysadmin</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="s1">'{Password}'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li497513519333">View the created user in the <a href="dws_04_0791.html">PG_USER</a> view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_screen35510488336"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_user</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li497513519333">View the created user in the <a href="dws_04_0791.html">PG_USER</a> view.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_screen35510488336"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_user</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li198021759132313">To view user attributes, query the system catalog <a href="dws_04_0574.html">PG_AUTHID</a>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_screen1480295916239"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_authid</span><span class="p">;</span><span class="w"> </span>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li198021759132313">To view user attributes, query the system catalog <a href="dws_04_0574.html">PG_AUTHID</a>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_screen1480295916239"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_authid</span><span class="p">;</span><span class="w"> </span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_section177791258171313"><h4 class="sectiontitle">Altering User Attributes</h4><p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p02921820161416">The <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b17869132174116">ALTER USER</strong> statement is used to alter user attributes, such as changing user passwords or permissions.</p>
<p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p19125111219143">Example:</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul8921195210312"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li292145233116">Rename user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b161931737104020">u1</strong> to <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b93511839104011">u2</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_en-us_topic_0000001082926733_s1aa0fa851c7f45c9aac01f563e469336"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">u2</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_section177791258171313"><h4 class="sectiontitle">Altering User Attributes</h4><p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p02921820161416">The <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b17869132174116">ALTER USER</strong> statement is used to alter user attributes, such as changing user passwords or permissions.</p>
<p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p19125111219143">Example:</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul8921195210312"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li292145233116">Rename user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b161931737104020">u1</strong> to <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b93511839104011">u2</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_en-us_topic_0000001082926733_s1aa0fa851c7f45c9aac01f563e469336"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">u2</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li39221752183118">Grant the <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b655711156422">CREATEROLE</strong> permission to user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b0818131814425">u1</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_screen2649718142220"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">CREATEROLE</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li39221752183118">Grant the <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b655711156422">CREATEROLE</strong> permission to user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b0818131814425">u1</strong>:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_screen2649718142220"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">CREATEROLE</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li238439133819">For details about how to change the user password, see <a href="dws_04_0063.html#EN-US_TOPIC_0000001531101121__en-us_topic_0000001188482292_section1897910435417">Setting and Changing a Password</a>.</li></ul>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li238439133819">For details about how to change the user password, see <a href="dws_04_0063.html#EN-US_TOPIC_0000001811491169__en-us_topic_0000001188482292_section1897910435417">Setting and Changing a Password</a>.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_section5530258152512"><h4 class="sectiontitle">Locking a User</h4><p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p583454519420">The <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b156216105177">ACCOUNT LOCK</strong> | <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b434581371710">ACCOUNT UNLOCK</strong> parameter in the statement is used to lock or unlock a user. A locked user cannot log in to the system. If an account is stolen or illegally accessed, the administrator can manually lock the account. After the account is secured, the administrator can manually unlock the account.</p>
<p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_a965c39fa6c1b485d9531984163b5df7b">Example:</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul56140553218"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li4615175133217">To lock user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b515120719181">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_sd7a7a6ffd93848ec82772e85e1152046"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">ACCOUNT</span><span class="w"> </span><span class="k">LOCK</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_section5530258152512"><h4 class="sectiontitle">Locking a User</h4><p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p583454519420">The <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b156216105177">ACCOUNT LOCK</strong> | <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b434581371710">ACCOUNT UNLOCK</strong> parameter in the statement is used to lock or unlock a user. A locked user cannot log in to the system. If an account is stolen or illegally accessed, the administrator can manually lock the account. After the account is secured, the administrator can manually unlock the account.</p>
<p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_a965c39fa6c1b485d9531984163b5df7b">Example:</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul56140553218"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li4615175133217">To lock user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b515120719181">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_sd7a7a6ffd93848ec82772e85e1152046"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">ACCOUNT</span><span class="w"> </span><span class="k">LOCK</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li62371119328">To unlock user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b293139141812">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_sfbbbae6fbe514ae7865f2696ee6b9e4c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">ACCOUNT</span><span class="w"> </span><span class="n">UNLOCK</span><span class="p">;</span>
</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li62371119328">To unlock user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b293139141812">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_sfbbbae6fbe514ae7865f2696ee6b9e4c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="w"> </span><span class="n">ACCOUNT</span><span class="w"> </span><span class="n">UNLOCK</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_section1365185119379"><h4 class="sectiontitle">Deleting a User</h4><p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p114873574371">The <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b1520929122217">DROP USER</strong> statement is used to delete one or more GaussDB(DWS) users. An administrator can delete an account that is no longer used. Deleted users cannot be restored.</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul41936112209"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li171932192015">If multiple users are deleted at the same time, separate them with commas (,).</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li11193101142015">After a user is deleted successfully, all the permissions of the user are also deleted.</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li1299164410401">When an account to be deleted is in the active state, it is deleted after the session is disconnected.</li><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li6974145124118">When <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b663378102316">CASCADE </strong>is specified in the <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b1193303212315">DROP USER</strong> statement, objects such as tables that depend on the user will be deleted. That is, the objects whose owner is the user are deleted, and the authorizations of other objects to the user are also deleted.</li></ul>
<p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p1545712420105">Example:</p>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul19914101516326"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li129141815183214">-- Delete user <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b209671513122518">u1</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_screen12472141917136"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_section1365185119379"><h4 class="sectiontitle">Deleting a User</h4><p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p114873574371">The <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b1520929122217">DROP USER</strong> statement is used to delete one or more GaussDB(DWS) users. An administrator can delete an account that is no longer used. Deleted users cannot be restored.</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul41936112209"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li171932192015">If multiple users are deleted at the same time, separate them with commas (,).</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li11193101142015">After a user is deleted successfully, all the permissions of the user are also deleted.</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li1299164410401">When an account to be deleted is in the active state, it is deleted after the session is disconnected.</li><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li6974145124118">When <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b663378102316">CASCADE </strong>is specified in the <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b1193303212315">DROP USER</strong> statement, objects such as tables that depend on the user will be deleted. That is, the objects whose owner is the user are deleted, and the authorizations of other objects to the user are also deleted.</li></ul>
<p id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_p1545712420105">Example:</p>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul19914101516326"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li129141815183214">-- Delete user <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b209671513122518">u1</strong>.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_screen12472141917136"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u1</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
<ul id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_ul13205121973219"><li id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_li2205101943217">Delete account <strong id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_b321421822517">u2</strong> in a cascading manner.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_saf2296eb7a554757b09ed7c4f05c4816"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u2</span><span class="w"> </span><span class="k">CASCADE</span><span class="p">;</span>
<ul id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_ul13205121973219"><li id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_li2205101943217">Delete account <strong id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_b321421822517">u2</strong> in a cascading manner.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764650916__en-us_topic_0000001233563239_saf2296eb7a554757b09ed7c4f05c4816"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">u2</span><span class="w"> </span><span class="k">CASCADE</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
@ -53,7 +53,7 @@
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0053.html">Managing Users and Their Permissions</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0053.html">GaussDB(DWS) User and Permissions Management</a></div>
</div>
</div>

View File

@ -1,11 +1,11 @@
<a name="EN-US_TOPIC_0000001510402509"></a><a name="EN-US_TOPIC_0000001510402509"></a>
<a name="EN-US_TOPIC_0000001764491184"></a><a name="EN-US_TOPIC_0000001764491184"></a>
<h1 class="topictitle1">GaussDB(DWS) Row-Level Access Control</h1>
<div id="body1560407392207"><p id="EN-US_TOPIC_0000001510402509__p1873119554919">The row-level access control feature enables database access control to be accurate to each row of data tables. In this way, the same SQL query may return different results for different users.</p>
<p id="EN-US_TOPIC_0000001510402509__p7731353497">You can create a row-level access control policy for a data table. The policy defines an expression that takes effect only for specific database users and SQL operations. When a database user accesses the data table, if a SQL statement meets the specified row-level access control policies of the data table, the expressions that meet the specified condition will be combined by using <strong id="EN-US_TOPIC_0000001510402509__b1515912910316">AND</strong> or <strong id="EN-US_TOPIC_0000001510402509__b18655812935">OR</strong> based on the attribute type (<strong id="EN-US_TOPIC_0000001510402509__b0452172816312">PERMISSIVE</strong> | <strong id="EN-US_TOPIC_0000001510402509__b1581013314319">RESTRICTIVE</strong>) and applied to the execution plan in the query optimization phase.</p>
<p id="EN-US_TOPIC_0000001510402509__p17317514916">Row-level access control is used to control the visibility of row-level data in tables. By predefining filters for data tables, the expressions that meet the specified condition can be applied to execution plans in the query optimization phase, which will affect the final execution result. Currently, the SQL statements that can be affected include <strong id="EN-US_TOPIC_0000001510402509__b191811411553">SELECT</strong>, <strong id="EN-US_TOPIC_0000001510402509__b859234313517">UPDATE</strong>, and <strong id="EN-US_TOPIC_0000001510402509__b159005441157">DELETE</strong>.</p>
<p id="EN-US_TOPIC_0000001510402509__p1796912257556">Scenario 1: A table summarizes the data of different users. Users can view only their own data.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510402509__screen62701712114315"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<div id="body1560407392207"><p id="EN-US_TOPIC_0000001764491184__p1873119554919">The row-level access control feature enables database access control to be accurate to each row of data tables. In this way, the same SQL query may return different results for different users.</p>
<p id="EN-US_TOPIC_0000001764491184__p7731353497">You can create a row-level access control policy for a data table. The policy defines an expression that takes effect only for specific database users and SQL operations. When a database user accesses the data table, if a SQL statement meets the specified row-level access control policies of the data table, the expressions that meet the specified condition will be combined by using <strong id="EN-US_TOPIC_0000001764491184__b1515912910316">AND</strong> or <strong id="EN-US_TOPIC_0000001764491184__b18655812935">OR</strong> based on the attribute type (<strong id="EN-US_TOPIC_0000001764491184__b0452172816312">PERMISSIVE</strong> | <strong id="EN-US_TOPIC_0000001764491184__b1581013314319">RESTRICTIVE</strong>) and applied to the execution plan in the query optimization phase.</p>
<p id="EN-US_TOPIC_0000001764491184__p17317514916">Row-level access control is used to control the visibility of row-level data in tables. By predefining filters for data tables, the expressions that meet the specified condition can be applied to execution plans in the query optimization phase, which will affect the final execution result. Currently, the SQL statements that can be affected include <strong id="EN-US_TOPIC_0000001764491184__b191811411553">SELECT</strong>, <strong id="EN-US_TOPIC_0000001764491184__b859234313517">UPDATE</strong>, and <strong id="EN-US_TOPIC_0000001764491184__b159005441157">DELETE</strong>.</p>
<p id="EN-US_TOPIC_0000001764491184__p1796912257556">Scenario 1: A table summarizes the data of different users. Users can view only their own data.</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001764491184__screen62701712114315"><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>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
<a name="EN-US_TOPIC_0000001717256744"></a><a name="EN-US_TOPIC_0000001717256744"></a>
<a name="EN-US_TOPIC_0000001764491636"></a><a name="EN-US_TOPIC_0000001764491636"></a>
<h1 class="topictitle1">Overview</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_p7807105913718">MRS is a big data cluster running based on the open-source Hadoop ecosystem. It provides the industry's latest cutting-edge storage and analytical capabilities of massive volumes of data, satisfying your data storage and processing requirements. For details, see the <span id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph2740729133515"><i><cite id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0135554668_cite245375118115">MapReduce Service User Guide</cite></i><em id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_i13654203215310"></em><em id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_i188061438139"></em></span>.</p>
<p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_p56178650111411">You can use Hive/Spark (analysis cluster of MRS) to store massive volumes of service data. Hive/Spark data files are stored on HDFS. On <span id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph1692512422530">GaussDB(DWS)</span>, you can connect a <span id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph111997429518">GaussDB(DWS)</span> cluster to an MRS cluster, read data from HDFS files, and write the data to <span id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph33147185110">GaussDB(DWS)</span> when the clusters are on the same network.</p>
<div class="notice" id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_note1775105323310"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_p177511536337">Ensure that MRS can communicate with DWS:</p>
<p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_p122834109344">Scenario 1: If MRS and DWS are in the same region and VPC, they can communicate with each other by default.</p>
<p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_p13939142613348">Scenario 2: If MRS and GaussDB(DWS) are in the same region but in different VPCs, you need to create a VPC peering connection. For details, see "VPC Peering Connection Overview" in <em id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_i0526163863219">Virtual Private Cloud User Guide</em>.</p>
<p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_p594017456346">Scenario 3: If MRS and GaussDB(DWS) are not in the same region, you need to use Cloud Connect (CC) to create network connections. For details, see the user guide of the corresponding service.</p>
<p id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_p11875339174014">Scenario 4: If MRS is deployed on-premises, you need to use Direct Connect (DC) or Virtual Private Network (VPN) to connect the network. For details, see the User Guide of the corresponding service.</p>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_p7807105913718">MRS is a big data cluster running based on the open-source Hadoop ecosystem. It provides the industry's latest cutting-edge storage and analytical capabilities of massive volumes of data, satisfying your data storage and processing requirements. For details, see the <span id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph2740729133515"><i><cite id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0135554668_cite245375118115">MapReduce Service User Guide</cite></i><em id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_i13654203215310"></em><em id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_i188061438139"></em></span>.</p>
<p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_p56178650111411">You can use Hive/Spark (analysis cluster of MRS) to store massive volumes of service data. Hive/Spark data files are stored on HDFS. On <span id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph1692512422530">GaussDB(DWS)</span>, you can connect a <span id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph111997429518">GaussDB(DWS)</span> cluster to an MRS cluster, read data from HDFS files, and write the data to <span id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_ph33147185110">GaussDB(DWS)</span> when the clusters are on the same network.</p>
<div class="notice" id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_note1775105323310"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_p177511536337">Ensure that MRS can communicate with DWS:</p>
<p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_p122834109344">Scenario 1: If MRS and DWS are in the same region and VPC, they can communicate with each other by default.</p>
<p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_p13939142613348">Scenario 2: If MRS and GaussDB(DWS) are in the same region but in different VPCs, you need to create a VPC peering connection. For details, see "VPC Peering Connection Overview" in <em id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_i0526163863219">Virtual Private Cloud User Guide</em>.</p>
<p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_p594017456346">Scenario 3: If MRS and GaussDB(DWS) are not in the same region, you need to use Cloud Connect (CC) to create network connections. For details, see the user guide of the corresponding service.</p>
<p id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_p11875339174014">Scenario 4: If MRS is deployed on-premises, you need to use Direct Connect (DC) or Virtual Private Network (VPN) to connect the network. For details, see the User Guide of the corresponding service.</p>
</div></div>
<div class="section" id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_section1298319298101"><h4 class="sectiontitle">Importing Data from MRS to a GaussDB(DWS) Cluster</h4><ol id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_ol1725018516137"><li id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li524814581319"><a href="dws_04_0212.html#EN-US_TOPIC_0000001717097320">Preparing Data in an MRS Cluster</a></li><li id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li424812561318">(Optional) <a href="dws_04_0213.html#EN-US_TOPIC_0000001764817381">Manually Creating a Foreign Server</a></li><li id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li1324910521314"><a href="dws_04_0214.html#EN-US_TOPIC_0000001764896609">Creating a Foreign Table</a></li><li id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li6249258138"><a href="dws_04_0215.html#EN-US_TOPIC_0000001717256748">Importing Data</a></li><li id="EN-US_TOPIC_0000001717256744__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li42491154139"><a href="dws_04_0216.html#EN-US_TOPIC_0000001717097324">Deleting Resources</a></li></ol>
<div class="section" id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_section1298319298101"><h4 class="sectiontitle">Importing Data from MRS to a GaussDB(DWS) Cluster</h4><ol id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_ol1725018516137"><li id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li524814581319"><a href="dws_04_0212.html#EN-US_TOPIC_0000001764492076">Preparing Data in an MRS Cluster</a></li><li id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li424812561318">(Optional) <a href="dws_04_0213.html">Manually Creating a Foreign Server</a></li><li id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li1324910521314"><a href="dws_04_0214.html">Creating a Foreign Table</a></li><li id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li6249258138"><a href="dws_04_0215.html#EN-US_TOPIC_0000001811610137">Importing Data</a></li><li id="EN-US_TOPIC_0000001764491636__en-us_topic_0000001233563291_en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li42491154139"><a href="dws_04_0216.html#EN-US_TOPIC_0000001811610425">Deleting Resources</a></li></ol>
</div>
</div>
<div>

View File

@ -1,22 +1,22 @@
<a name="EN-US_TOPIC_0000001460722840"></a><a name="EN-US_TOPIC_0000001460722840"></a>
<a name="EN-US_TOPIC_0000001764491388"></a><a name="EN-US_TOPIC_0000001764491388"></a>
<h1 class="topictitle1">GaussDB(DWS) Development and Design Proposal</h1>
<h1 class="topictitle1">GaussDB(DWS) Development Design Proposal</h1>
<div id="body1528161858339"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0075.html">Overview</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0076.html">GaussDB(DWS) Object Naming Conventions</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0103.html">GaussDB(DWS) Connection Management Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0104.html">GaussDB(DWS) Object Design Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0083.html">GaussDB(DWS) JDBC Configuration Rules</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0105.html">GaussDB(DWS) SQL Statement Development Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0084.html">GaussDB(DWS) SQL Writing Rules</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0031.html">GaussDB(DWS) Foreign Table Function Development Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0971.html">Rules for Using Custom GaussDB(DWS) External Functions (pgSQL/Java)</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0106.html">GaussDB(DWS) Stored Procedure Development Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0972.html">Rules for Using GaussDB(DWS) PL/pgSQL</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0107.html">Detailed Design Rules for GaussDB(DWS) Objects</a></strong><br>
</li>
</ul>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,16 @@
<a name="EN-US_TOPIC_0000001510522249"></a><a name="EN-US_TOPIC_0000001510522249"></a>
<a name="EN-US_TOPIC_0000001764650452"></a><a name="EN-US_TOPIC_0000001764650452"></a>
<h1 class="topictitle1">GaussDB(DWS) Object Naming Conventions</h1>
<div id="body1528161858339"><p id="EN-US_TOPIC_0000001510522249__p1832121193017">The name of a database object must contain 1 to 63 characters, start with a letter or underscore (_), and can contain letters, digits, underscores (_), and dollar signs ($).</p>
<ul id="EN-US_TOPIC_0000001510522249__ul1732014239567"><li id="EN-US_TOPIC_0000001510522249__li183207238569">[Proposal] Do not use reserved or non-reserved keywords to name database objects.<div class="note" id="EN-US_TOPIC_0000001510522249__note133201623175616"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001510522249__p173201323105613">You can run <strong id="EN-US_TOPIC_0000001510522249__b141222115510">SELECT * FROM pg_get_keywords()</strong> to query <span id="EN-US_TOPIC_0000001510522249__text441214245514">GaussDB(DWS)</span> keywords or view the keywords in section "Keywords" in <em id="EN-US_TOPIC_0000001510522249__i124127275515">SQL Syntax Reference</em>.</p>
<h1 class="topictitle1">GaussDB(DWS) Database Object Naming Rules</h1>
<div id="body1528161858339"><p id="EN-US_TOPIC_0000001764650452__p1832121193017">The name of a database object must contain 1 to 63 characters, start with a letter or underscore (_), and can contain letters, digits, underscores (_), and dollar signs ($).</p>
<ul id="EN-US_TOPIC_0000001764650452__ul1732014239567"><li id="EN-US_TOPIC_0000001764650452__li183207238569">[Proposal] Do not use reserved or non-reserved keywords to name database objects.<div class="note" id="EN-US_TOPIC_0000001764650452__note133201623175616"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001764650452__p173201323105613">You can run <strong id="EN-US_TOPIC_0000001764650452__b1860113443210">SELECT * FROM pg_get_keywords()</strong> to query <span id="EN-US_TOPIC_0000001764650452__text1722747791">GaussDB(DWS)</span> keywords or view the keywords in section "Keywords" in <em id="EN-US_TOPIC_0000001764650452__i2601143453219">SQL Syntax Reference</em>.</p>
</div></div>
</li><li id="EN-US_TOPIC_0000001510522249__li1724252616567">[Proposal] Do not use strings enclosed in double quotation marks to define database object names. In GaussDB(DWS), double quotation marks are used to specify that the enclosed database object names are case sensitive. Case sensitivity of database object names makes problem location difficult.</li><li id="EN-US_TOPIC_0000001510522249__li15563344563">[Proposal] Use the same naming format for database objects.<ul id="EN-US_TOPIC_0000001510522249__ul75615347563"><li id="EN-US_TOPIC_0000001510522249__li05603416563">In a system undergoing incremental development or service migration, you are advised to comply with its historical naming conventions.</li><li id="EN-US_TOPIC_0000001510522249__li9561734205613">A database object name consists of letters, digits, and underscores (_); and cannot start with a digit. You are advised to use multiple words separated with hyphens (-).</li><li id="EN-US_TOPIC_0000001510522249__li1556123455615">You are advised to use intelligible names and common acronyms or abbreviations for database objects. Acronyms or abbreviations that are generally understood are recommended. For example, you can use English words indicating actual business terms. The naming format should be consistent within a cluster.</li><li id="EN-US_TOPIC_0000001510522249__li1442681418122">A variable name must be descriptive and meaningful. It must have a prefix indicating its type.</li></ul>
</li><li id="EN-US_TOPIC_0000001510522249__li22041237145610">[Proposal] The name of a table object should indicate its main characteristics, for example, whether it is an ordinary, temporary, or unlogged table.<ul id="EN-US_TOPIC_0000001510522249__ul7204337175616"><li id="EN-US_TOPIC_0000001510522249__li1320483745615">An ordinary table name should indicate the business relevant to a data set.</li><li id="EN-US_TOPIC_0000001510522249__li3204123718567">Temporary tables are named in the format of <strong id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_b842352706173450">tmp_</strong><em id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_i842352697173448">Suffix</em>.</li><li id="EN-US_TOPIC_0000001510522249__li132041337105615">Unlogged tables are named in the format of <strong id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_b84235270617351">ul_</strong><em id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_i84235269717357">Suffix</em>.</li><li id="EN-US_TOPIC_0000001510522249__li19204137195614">Foreign tables are named in the format of <strong id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_b842352706143019">f_</strong><em id="EN-US_TOPIC_0000001510522249__en-us_topic_0097059046_i842352697143034">Suffix</em>.</li></ul>
</li><li id="EN-US_TOPIC_0000001764650452__li1724252616567">[Proposal] Do not use strings enclosed in double quotation marks to define database object names. In GaussDB(DWS), double quotation marks are used to specify that the enclosed database object names are case sensitive. Case sensitivity of database object names makes problem location difficult.</li><li id="EN-US_TOPIC_0000001764650452__li15563344563">[Proposal] Use the same naming format for database objects.<ul id="EN-US_TOPIC_0000001764650452__ul75615347563"><li id="EN-US_TOPIC_0000001764650452__li05603416563">In a system undergoing incremental development or service migration, you are advised to comply with its historical naming conventions.</li><li id="EN-US_TOPIC_0000001764650452__li9561734205613">A database object name consists of letters, digits, and underscores (_); and cannot start with a digit. You are advised to use multiple words separated with hyphens (-).</li><li id="EN-US_TOPIC_0000001764650452__li1556123455615">You are advised to use intelligible names and common acronyms or abbreviations for database objects. Acronyms or abbreviations that are generally understood are recommended. For example, you can use English words indicating actual business terms. The naming format should be consistent within a cluster.</li><li id="EN-US_TOPIC_0000001764650452__li1442681418122">A variable name must be descriptive and meaningful. It must have a prefix indicating its type.</li></ul>
</li><li id="EN-US_TOPIC_0000001764650452__li22041237145610">[Proposal] The name of a table object should indicate its main characteristics, for example, whether it is an ordinary, temporary, or unlogged table.<ul id="EN-US_TOPIC_0000001764650452__ul7204337175616"><li id="EN-US_TOPIC_0000001764650452__li1320483745615">An ordinary table name should indicate the business relevant to a data set.</li><li id="EN-US_TOPIC_0000001764650452__li3204123718567">Temporary tables are named in the format of <strong id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_b842352706173450">tmp_</strong><em id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_i842352697173448">Suffix</em>.</li><li id="EN-US_TOPIC_0000001764650452__li132041337105615">Unlogged tables are named in the format of <strong id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_b84235270617351">ul_</strong><em id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_i84235269717357">Suffix</em>.</li><li id="EN-US_TOPIC_0000001764650452__li19204137195614">Foreign tables are named in the format of <strong id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_b842352706143019">f_</strong><em id="EN-US_TOPIC_0000001764650452__en-us_topic_0097059046_i842352697143034">Suffix</em>.</li></ul>
</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0107.html">Detailed Design Rules for GaussDB(DWS) Objects</a></div>
</div>
</div>

View File

@ -1,6 +1,6 @@
<a name="EN-US_TOPIC_0000001510402361"></a><a name="EN-US_TOPIC_0000001510402361"></a>
<a name="EN-US_TOPIC_0000001764650632"></a><a name="EN-US_TOPIC_0000001764650632"></a>
<h1 class="topictitle1">GaussDB(DWS) Database Object Design</h1>
<h1 class="topictitle1">GaussDB(DWS) Database Object Design Rules</h1>
<div id="body1528161858339"></div>
<div>
<ul class="ullinks">
@ -8,7 +8,7 @@
</li>
<li class="ulchildlink"><strong><a href="dws_04_0079.html">GaussDB(DWS) Table Design Rules</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0080.html">GaussDB(DWS) Field Design Rules</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0080.html">GaussDB(DWS) Column Design Rules</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0081.html">GaussDB(DWS) Constraint Design Rules</a></strong><br>
</li>
@ -17,7 +17,7 @@
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0107.html">Detailed Design Rules for GaussDB(DWS) Objects</a></div>
</div>
</div>

View File

@ -1,16 +1,16 @@
<a name="EN-US_TOPIC_0000001510162773"></a><a name="EN-US_TOPIC_0000001510162773"></a>
<a name="EN-US_TOPIC_0000001811609557"></a><a name="EN-US_TOPIC_0000001811609557"></a>
<h1 class="topictitle1">GaussDB(DWS) Database and Schema Design Rules</h1>
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001510162773__a163526b0670d42fa992ba7033a636dc1">In <span id="EN-US_TOPIC_0000001510162773__text1265888159">GaussDB(DWS)</span>, services can be isolated by databases and schemas. Databases share little resources and cannot directly access each other. Connections to and permissions on them are also isolated. Schemas share more resources than databases do. User permissions on schemas and subordinate objects can be controlled using the <strong id="EN-US_TOPIC_0000001510162773__b15854101415557">GRANT</strong> and <strong id="EN-US_TOPIC_0000001510162773__b1185571495510">REVOKE</strong> syntax.</p>
<ul id="EN-US_TOPIC_0000001510162773__ul14407749155613"><li id="EN-US_TOPIC_0000001510162773__li17407249185610">You are advised to use schemas to isolate services for convenience and resource sharing.</li><li id="EN-US_TOPIC_0000001510162773__li57147515561">It is recommended that system administrators create schemas and databases and then assign required permissions to users.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001510162773__sb41154e9d50a48e6ada14ffd10d2b591"><h4 class="sectiontitle">Database Design Suggestions</h4><ul id="EN-US_TOPIC_0000001510162773__ul1241013276555"><li id="EN-US_TOPIC_0000001510162773__li47531831165518">Create databases as required. Do not use the default <strong id="EN-US_TOPIC_0000001510162773__b149702415296"><span id="EN-US_TOPIC_0000001510162773__text17442175020432">gaussdb</span></strong> database of a cluster.</li><li id="EN-US_TOPIC_0000001510162773__li7201934125511">Create a maximum of three user-defined databases in a cluster.</li><li id="EN-US_TOPIC_0000001510162773__li17746153765510">To make your database encoding compatible with most characters, you are advised to use the UTF-8 encoding when creating a database.</li><li id="EN-US_TOPIC_0000001510162773__li1931294213555">Exercise caution when you set <strong id="EN-US_TOPIC_0000001510162773__b84235270619237">ENCODING</strong> and <strong id="EN-US_TOPIC_0000001510162773__b84235270619239">DBCOMPATIBILITY</strong> configuration items during database creation. In <span id="EN-US_TOPIC_0000001510162773__text1069744734">GaussDB(DWS)</span>, <strong id="EN-US_TOPIC_0000001510162773__b842352706113254">DBCOMPATIBILITY</strong> can be set to <strong id="EN-US_TOPIC_0000001510162773__b842352706114537">TD</strong>, <strong id="EN-US_TOPIC_0000001510162773__b842352706114542">Oracle</strong>, or <strong id="EN-US_TOPIC_0000001510162773__b1733613542491">MySQL</strong> to be compatible with Teradata, Oracle, or MySQL syntax, respectively. Syntax behavior may vary with the three modes. For details, see <a href="dws_04_0042.html">Syntax Compatibility Differences Among Oracle, Teradata, and MySQL</a>.</li><li id="EN-US_TOPIC_0000001510162773__li164101627125511">By default, a database owner has all permissions for all objects in the database, including the deletion permission. Exercise caution when using the deletion permission.</li></ul>
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001811609557__a163526b0670d42fa992ba7033a636dc1">In <span id="EN-US_TOPIC_0000001811609557__text1265888159">GaussDB(DWS)</span>, services can be isolated by databases and schemas. Databases share little resources and cannot directly access each other. Connections to and permissions on them are also isolated. Schemas share more resources than databases do. User permissions on schemas and subordinate objects can be controlled using the <strong id="EN-US_TOPIC_0000001811609557__b84235270694635">GRANT</strong> and <strong id="EN-US_TOPIC_0000001811609557__b84235270694632">REVOKE</strong> syntax.</p>
<ul id="EN-US_TOPIC_0000001811609557__ul14407749155613"><li id="EN-US_TOPIC_0000001811609557__li17407249185610">You are advised to use schemas to isolate services for convenience and resource sharing.</li><li id="EN-US_TOPIC_0000001811609557__li57147515561">It is recommended that system administrators create schemas and databases and then assign required permissions to users.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001811609557__sb41154e9d50a48e6ada14ffd10d2b591"><h4 class="sectiontitle">Database Design Suggestions</h4><ul id="EN-US_TOPIC_0000001811609557__ul1241013276555"><li id="EN-US_TOPIC_0000001811609557__li47531831165518">Create databases as required. Do not use the default <strong id="EN-US_TOPIC_0000001811609557__b149702415296"><span id="EN-US_TOPIC_0000001811609557__text17442175020432">gaussdb</span></strong> database of a cluster.</li><li id="EN-US_TOPIC_0000001811609557__li7201934125511">Create a maximum of three user-defined databases in a cluster.</li><li id="EN-US_TOPIC_0000001811609557__li17746153765510">To make your database encoding compatible with most characters, you are advised to use the UTF-8 encoding when creating a database.</li><li id="EN-US_TOPIC_0000001811609557__li1931294213555">Exercise caution when you set <strong id="EN-US_TOPIC_0000001811609557__b84235270619237">ENCODING</strong> and <strong id="EN-US_TOPIC_0000001811609557__b84235270619239">DBCOMPATIBILITY</strong> configuration items during database creation. In <span id="EN-US_TOPIC_0000001811609557__text1069744734">GaussDB(DWS)</span>, <strong id="EN-US_TOPIC_0000001811609557__b842352706113254">DBCOMPATIBILITY</strong> can be set to <strong id="EN-US_TOPIC_0000001811609557__b842352706114537">TD</strong>, <strong id="EN-US_TOPIC_0000001811609557__b842352706114542">Oracle</strong>, or <strong id="EN-US_TOPIC_0000001811609557__b1733613542491">MySQL</strong> to be compatible with Teradata, Oracle, or MySQL syntax, respectively. Syntax behavior may vary with the three modes. For details, see <a href="dws_04_0042.html">Syntax Compatibility Differences Among Oracle, Teradata, and MySQL</a>.</li><li id="EN-US_TOPIC_0000001811609557__li164101627125511">By default, a database owner has all permissions for all objects in the database, including the deletion permission. Exercise caution when using the deletion permission.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162773__s51d3bc0fb11b4dccbfd9db3d49343942"><h4 class="sectiontitle">Schema Design Suggestions</h4><ul id="EN-US_TOPIC_0000001510162773__ul14634748125512"><li id="EN-US_TOPIC_0000001510162773__li846585175513">To let a user access an object in a schema, grant the <strong id="EN-US_TOPIC_0000001510162773__b16307749125110">usage</strong> permission and the permissions for the object to the user, unless the user has the <strong id="EN-US_TOPIC_0000001510162773__b7235165515515">sysadmin</strong> permission or is the schema owner.</li><li id="EN-US_TOPIC_0000001510162773__li46701354105515">To let a user create an object in the schema, grant the <strong id="EN-US_TOPIC_0000001510162773__b9676101745511">CREATE</strong> permission for the schema to the user.</li><li id="EN-US_TOPIC_0000001510162773__li17634124817557">By default, a schema owner has all permissions for all objects in the schema, including the deletion permission. Exercise caution when using the deletion permission.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001811609557__s51d3bc0fb11b4dccbfd9db3d49343942"><h4 class="sectiontitle">Schema Design Suggestions</h4><ul id="EN-US_TOPIC_0000001811609557__ul14634748125512"><li id="EN-US_TOPIC_0000001811609557__li846585175513">To let a user access an object in a schema, grant the <strong id="EN-US_TOPIC_0000001811609557__b16307749125110">usage</strong> permission and the permissions for the object to the user, unless the user has the <strong id="EN-US_TOPIC_0000001811609557__b7235165515515">sysadmin</strong> permission or is the schema owner.</li><li id="EN-US_TOPIC_0000001811609557__li46701354105515">To let a user create an object in the schema, grant the <strong id="EN-US_TOPIC_0000001811609557__b9700145918515">CREATE</strong> permission for the schema to the user.</li><li id="EN-US_TOPIC_0000001811609557__li17634124817557">By default, a schema owner has all permissions for all objects in the schema, including the deletion permission. Exercise caution when using the deletion permission.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design Rules</a></div>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
<a name="EN-US_TOPIC_0000001510162537"></a><a name="EN-US_TOPIC_0000001510162537"></a>
<a name="EN-US_TOPIC_0000001764650656"></a><a name="EN-US_TOPIC_0000001764650656"></a>
<h1 class="topictitle1">GaussDB(DWS) Constraint Design Rules</h1>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001510162537__section555838816718"><h4 class="sectiontitle">DEFAULT and NULL Constraints</h4><ul id="EN-US_TOPIC_0000001510162537__ul1188131610581"><li id="EN-US_TOPIC_0000001510162537__li1188616165818">[Proposal] If all the column values can be obtained from services, you are not advised to use the <strong id="EN-US_TOPIC_0000001510162537__b469211910561">DEFAULT</strong> constraint, because doing so will generate unexpected results during data loading.</li><li id="EN-US_TOPIC_0000001510162537__li124803200584">[Proposal] Add <strong id="EN-US_TOPIC_0000001510162537__b842352706163730">NOT NULL</strong> constraints to columns that never have NULL values. The optimizer automatically optimizes the columns in certain scenarios.</li><li id="EN-US_TOPIC_0000001510162537__li11798102210586">[Proposal] Explicitly name all constraints excluding <strong id="EN-US_TOPIC_0000001510162537__b842352706163934">NOT NULL</strong> and <strong id="EN-US_TOPIC_0000001510162537__b842352706163937">DEFAULT</strong>.</li></ul>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001764650656__section555838816718"><h4 class="sectiontitle">DEFAULT and NULL Constraints</h4><ul id="EN-US_TOPIC_0000001764650656__ul1188131610581"><li id="EN-US_TOPIC_0000001764650656__li1188616165818">[Proposal] If all the column values can be obtained from services, you are not advised to use the <strong id="EN-US_TOPIC_0000001764650656__b842352706163544">DEFAULT</strong> constraint, because doing so will generate unexpected results during data loading.</li><li id="EN-US_TOPIC_0000001764650656__li124803200584">[Proposal] Add <strong id="EN-US_TOPIC_0000001764650656__b842352706163730">NOT NULL</strong> constraints to columns that never have NULL values. The optimizer automatically optimizes the columns in certain scenarios.</li><li id="EN-US_TOPIC_0000001764650656__li11798102210586">[Proposal] Explicitly name all constraints excluding <strong id="EN-US_TOPIC_0000001764650656__b842352706163934">NOT NULL</strong> and <strong id="EN-US_TOPIC_0000001764650656__b842352706163937">DEFAULT</strong>.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162537__section2578598416718"><h4 class="sectiontitle">Partial Cluster Key</h4><p id="EN-US_TOPIC_0000001510162537__p46071979">A partial cluster key (PCK) is a local clustering technology used for column-store tables. After creating a PCK, you can quickly filter and scan fact tables using min or max sparse indexes in <span id="EN-US_TOPIC_0000001510162537__text1158130347">GaussDB(DWS)</span>. Comply with the following rules to create a PCK:</p>
<ul id="EN-US_TOPIC_0000001510162537__ul8800142614588"><li id="EN-US_TOPIC_0000001510162537__li480092635814">[Notice] Only one PCK can be created in a table. A PCK can contain multiple columns, preferably no more than two columns.</li><li id="EN-US_TOPIC_0000001510162537__li1378132910586">[Proposal] Create a PCK on simple expression filter conditions in a query. Such filter conditions are usually in the form of <strong id="EN-US_TOPIC_0000001510162537__b84235270617039">col op const</strong>, where <strong id="EN-US_TOPIC_0000001510162537__b84235270617137">col</strong> specifies a column name, <strong id="EN-US_TOPIC_0000001510162537__b84235270617143">op</strong> specifies an operator (such as =, &gt;, &gt;=, &lt;=, and &lt;), and <strong id="EN-US_TOPIC_0000001510162537__b8423527061721">const</strong> specifies a constant.</li><li id="EN-US_TOPIC_0000001510162537__li1131316325583">[Proposal] If the preceding conditions are met, create a PCK on the column having the least distinct values.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001764650656__section2578598416718"><h4 class="sectiontitle">Partial Cluster Key</h4><p id="EN-US_TOPIC_0000001764650656__p46071979">A partial cluster key (PCK) is a local clustering technology used for column-store tables. After creating a PCK, you can quickly filter and scan fact tables using min or max sparse indexes in <span id="EN-US_TOPIC_0000001764650656__text1158130347">GaussDB(DWS)</span>. Comply with the following rules to create a PCK:</p>
<ul id="EN-US_TOPIC_0000001764650656__ul8800142614588"><li id="EN-US_TOPIC_0000001764650656__li480092635814">[Notice] Only one PCK can be created in a table. A PCK can contain multiple columns, preferably no more than two columns.</li><li id="EN-US_TOPIC_0000001764650656__li1378132910586">[Proposal] Create a PCK on simple expression filter conditions in a query. Such filter conditions are usually in the form of <strong id="EN-US_TOPIC_0000001764650656__b84235270617039">col op const</strong>, where <strong id="EN-US_TOPIC_0000001764650656__b84235270617137">col</strong> specifies a column name, <strong id="EN-US_TOPIC_0000001764650656__b84235270617143">op</strong> specifies an operator (such as =, &gt;, &gt;=, &lt;=, and &lt;), and <strong id="EN-US_TOPIC_0000001764650656__b8423527061721">const</strong> specifies a constant.</li><li id="EN-US_TOPIC_0000001764650656__li1131316325583">[Proposal] If the preceding conditions are met, create a PCK on the column having the least distinct values.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162537__section958094516718"><h4 class="sectiontitle">Unique Constraint</h4><ul id="EN-US_TOPIC_0000001510162537__ul184984019587"><li id="EN-US_TOPIC_0000001510162537__li17849940165819">[Notice] Both row-store and column-store tables support unique constraints.</li><li id="EN-US_TOPIC_0000001510162537__li15802104395817">[Proposal] The constraint name should indicate that it is a unique constraint, for example, <strong id="EN-US_TOPIC_0000001510162537__b84235270617735">UNI</strong><em id="EN-US_TOPIC_0000001510162537__i84235269717747">Included columns</em>.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001764650656__section958094516718"><h4 class="sectiontitle">Unique Constraint</h4><ul id="EN-US_TOPIC_0000001764650656__ul184984019587"><li id="EN-US_TOPIC_0000001764650656__li17849940165819">[Notice] Both row-store and column-store tables support unique constraints.</li><li id="EN-US_TOPIC_0000001764650656__li15802104395817">[Proposal] The constraint name should indicate that it is a unique constraint, for example, <strong id="EN-US_TOPIC_0000001764650656__b84235270617735">UNI</strong><em id="EN-US_TOPIC_0000001764650656__i84235269717747">Included columns</em>.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162537__section3696271616719"><h4 class="sectiontitle">Primary Key Constraint</h4><ul id="EN-US_TOPIC_0000001510162537__ul139403464585"><li id="EN-US_TOPIC_0000001510162537__li2940646185816">[Notice] Both row-store and column-store tables support the primary key constraint.</li><li id="EN-US_TOPIC_0000001510162537__li3376144911587">[Proposal] The constraint name should indicate that it is a primary key constraint, for example, <strong id="EN-US_TOPIC_0000001510162537__b982443271171149">PK</strong><em id="EN-US_TOPIC_0000001510162537__i2143730926171149">Included columns</em>.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001764650656__section3696271616719"><h4 class="sectiontitle">Primary Key Constraint</h4><ul id="EN-US_TOPIC_0000001764650656__ul139403464585"><li id="EN-US_TOPIC_0000001764650656__li2940646185816">[Notice] Both row-store and column-store tables support the primary key constraint.</li><li id="EN-US_TOPIC_0000001764650656__li3376144911587">[Proposal] The constraint name should indicate that it is a primary key constraint, for example, <strong id="EN-US_TOPIC_0000001764650656__b982443271171149">PK</strong><em id="EN-US_TOPIC_0000001764650656__i2143730926171149">Included columns</em>.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162537__section45602286161148"><h4 class="sectiontitle">Check Constraint</h4><ul id="EN-US_TOPIC_0000001510162537__ul9583552165819"><li id="EN-US_TOPIC_0000001510162537__li135837525587">[Notice] Check constraints can be used in row-store tables but not in column-store tables.</li><li id="EN-US_TOPIC_0000001510162537__li3792165419589">[Proposal] The constraint name should indicate that it is a check constraint, for example, <strong id="EN-US_TOPIC_0000001510162537__b277246241">CK</strong><em id="EN-US_TOPIC_0000001510162537__i983161284">Included columns</em>.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001764650656__section45602286161148"><h4 class="sectiontitle">Check Constraint</h4><ul id="EN-US_TOPIC_0000001764650656__ul9583552165819"><li id="EN-US_TOPIC_0000001764650656__li135837525587">[Notice] Check constraints can be used in row-store tables but not in column-store tables.</li><li id="EN-US_TOPIC_0000001764650656__li3792165419589">[Proposal] The constraint name should indicate that it is a check constraint, for example, <strong id="EN-US_TOPIC_0000001764650656__b772162282">CK</strong><em id="EN-US_TOPIC_0000001764650656__i414912536">Included columns</em>.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design Rules</a></div>
</div>
</div>

View File

@ -1,14 +1,14 @@
<a name="EN-US_TOPIC_0000001510162533"></a><a name="EN-US_TOPIC_0000001510162533"></a>
<a name="EN-US_TOPIC_0000001811609569"></a><a name="EN-US_TOPIC_0000001811609569"></a>
<h1 class="topictitle1">Design Rules for GaussDB(DWS) Views and Associated Tables</h1>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001510162533__section4431103710524"><h4 class="sectiontitle">View Design</h4><ul id="EN-US_TOPIC_0000001510162533__ul15374258175816"><li id="EN-US_TOPIC_0000001510162533__li18374258155814">[Proposal] Do not nest views unless they have strong dependency on each other.</li><li id="EN-US_TOPIC_0000001510162533__li95301035916">[Proposal] Try to avoid sort operations in a view definition.</li></ul>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001811609569__section4431103710524"><h4 class="sectiontitle">View Design</h4><ul id="EN-US_TOPIC_0000001811609569__ul15374258175816"><li id="EN-US_TOPIC_0000001811609569__li18374258155814">[Proposal] Do not nest views unless they have strong dependency on each other.</li><li id="EN-US_TOPIC_0000001811609569__li95301035916">[Proposal] Try to avoid sort operations in a view definition.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162533__section6265550010713"><h4 class="sectiontitle">Joined Table Design</h4><ul id="EN-US_TOPIC_0000001510162533__ul1798817211596"><li id="EN-US_TOPIC_0000001510162533__li15988523595">[Proposal] Minimize joined columns across tables.</li><li id="EN-US_TOPIC_0000001510162533__li82861353592">[Proposal] Joined columns should use the same data type.</li><li id="EN-US_TOPIC_0000001510162533__li96527718596">[Proposal] The names of associated fields should show the associations. For example, they can use the same name.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001811609569__section6265550010713"><h4 class="sectiontitle">Joined Table Design</h4><ul id="EN-US_TOPIC_0000001811609569__ul1798817211596"><li id="EN-US_TOPIC_0000001811609569__li15988523595">[Proposal] Minimize joined columns across tables.</li><li id="EN-US_TOPIC_0000001811609569__li82861353592">[Proposal] Joined columns should use the same data type.</li><li id="EN-US_TOPIC_0000001811609569__li96527718596">[Proposal] The names of associated fields should show the associations. For example, they can use the same name.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design Rules</a></div>
</div>
</div>

View File

@ -1,8 +1,8 @@
<a name="EN-US_TOPIC_0000001510402413"></a><a name="EN-US_TOPIC_0000001510402413"></a>
<a name="EN-US_TOPIC_0000001811609669"></a><a name="EN-US_TOPIC_0000001811609669"></a>
<h1 class="topictitle1">GaussDB(DWS) JDBC Configuration Rules</h1>
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001510402413__p83201518124912">Currently, third-party tools are connected to <span id="EN-US_TOPIC_0000001510402413__text1627912712414">GaussDB(DWS)</span> trough JDBC. This section describes the precautions for configuring the tools.</p>
<div class="section" id="EN-US_TOPIC_0000001510402413__section51233666102514"><h4 class="sectiontitle">Connection Parameters</h4><ul id="EN-US_TOPIC_0000001510402413__ul4235888102912"><li id="EN-US_TOPIC_0000001510402413__li33742908102912">[Notice] When a third-party tool connects to <span id="EN-US_TOPIC_0000001510402413__text267386391">GaussDB(DWS)</span> through JDBC, JDBC sends a connection request to <span id="EN-US_TOPIC_0000001510402413__text1267787076">GaussDB(DWS)</span>. By default, the following parameters are added. For details, see the implementation of the ConnectionFactoryImpl JDBC code.<pre class="screen" id="EN-US_TOPIC_0000001510402413__screen51783857102912">params = {
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001811609669__p83201518124912">Currently, third-party tools are connected to <span id="EN-US_TOPIC_0000001811609669__text120969138">GaussDB(DWS)</span> trough JDBC. This section describes the precautions for configuring the tools.</p>
<div class="section" id="EN-US_TOPIC_0000001811609669__section51233666102514"><h4 class="sectiontitle">Connection Parameters</h4><ul id="EN-US_TOPIC_0000001811609669__ul4235888102912"><li id="EN-US_TOPIC_0000001811609669__li33742908102912">[Notice] When a third-party tool connects to <span id="EN-US_TOPIC_0000001811609669__text267386391">GaussDB(DWS)</span> through JDBC, JDBC sends a connection request to <span id="EN-US_TOPIC_0000001811609669__text1267787076">GaussDB(DWS)</span>. By default, the following parameters are added. For details, see the implementation of the ConnectionFactoryImpl JDBC code.<pre class="screen" id="EN-US_TOPIC_0000001811609669__screen51783857102912">params = {
{ "user", user },
{ "database", database },
{ "client_encoding", "UTF8" },
@ -10,27 +10,27 @@
{ "extra_float_digits", "2" },
{ "TimeZone", createPostgresTimeZone() },
};</pre>
<p id="EN-US_TOPIC_0000001510402413__p15181893103553">These parameters may cause the JDBC and gsql clients to display inconsistent data, for example, date data display mode, floating point precision representation, and timezone.</p>
<p id="EN-US_TOPIC_0000001510402413__p63401535102912">If the result is not as expected, you are advised to explicitly set these parameters in the Java connection setting.</p>
</li><li id="EN-US_TOPIC_0000001510402413__li22840275102912">[Proposal] When connecting to the database through JDBC, ensure that the following two time zones are the same:<ul id="EN-US_TOPIC_0000001510402413__ul62190131102912"><li id="EN-US_TOPIC_0000001510402413__li35250721102912">Time zone of the host where the JDBC client is located</li><li id="EN-US_TOPIC_0000001510402413__li16356185655617">Time zone of the host where the <span id="EN-US_TOPIC_0000001510402413__text675913043">GaussDB(DWS)</span> server is located</li></ul>
<p id="EN-US_TOPIC_0000001811609669__p15181893103553">These parameters may cause the JDBC and gsql clients to display inconsistent data, for example, date data display mode, floating point precision representation, and timezone.</p>
<p id="EN-US_TOPIC_0000001811609669__p63401535102912">If the result is not as expected, you are advised to explicitly set these parameters in the Java connection setting.</p>
</li><li id="EN-US_TOPIC_0000001811609669__li22840275102912">[Proposal] When connecting to the database through JDBC, ensure that the following two time zones are the same:<ul id="EN-US_TOPIC_0000001811609669__ul62190131102912"><li id="EN-US_TOPIC_0000001811609669__li35250721102912">Time zone of the host where the JDBC client is located</li><li id="EN-US_TOPIC_0000001811609669__li16356185655617">Time zone of the host where the <span id="EN-US_TOPIC_0000001811609669__text675913043">GaussDB(DWS)</span> server is located</li></ul>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402413__section2864318010275"><h4 class="sectiontitle">fetchsize</h4><p id="EN-US_TOPIC_0000001510402413__p1208899">[Notice] To use <strong id="EN-US_TOPIC_0000001510402413__b21951949173115">fetchsize</strong> in applications, disable the <strong id="EN-US_TOPIC_0000001510402413__b842352706145926">autocommit</strong> switch. Enabling the <strong id="EN-US_TOPIC_0000001510402413__b131221632165613">autocommit</strong> switch makes the <strong id="EN-US_TOPIC_0000001510402413__b61223328562">fetchsize</strong> configuration invalid.</p>
<div class="section" id="EN-US_TOPIC_0000001811609669__section2864318010275"><h4 class="sectiontitle">fetchsize</h4><p id="EN-US_TOPIC_0000001811609669__p1208899">[Notice] To use <strong id="EN-US_TOPIC_0000001811609669__b21951949173115">fetchsize</strong> in applications, disable the <strong id="EN-US_TOPIC_0000001811609669__b842352706145926">autocommit</strong> switch. Enabling the <strong id="EN-US_TOPIC_0000001811609669__b84235270615044">autocommit</strong> switch makes the <strong id="EN-US_TOPIC_0000001811609669__b84235270615111">fetchsize</strong> configuration invalid.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402413__section1636443510276"><h4 class="sectiontitle">autocommit</h4><p id="EN-US_TOPIC_0000001510402413__p40373845104858">[Proposal] It is recommended that you enable the <strong id="EN-US_TOPIC_0000001510402413__b842352706142820">autocommit</strong> switch in the code for connecting to <span id="EN-US_TOPIC_0000001510402413__text265447366">GaussDB(DWS)</span> by the JDBC. If <strong id="EN-US_TOPIC_0000001510402413__b842352706143016">autocommit</strong> needs to be disabled to improve performance or for other purposes, applications need to ensure their transactions are committed. For example, explicitly commit translations after specifying service SQL statements. Particularly, ensure that all transactions are committed before the client exits.</p>
<div class="section" id="EN-US_TOPIC_0000001811609669__section1636443510276"><h4 class="sectiontitle">autocommit</h4><p id="EN-US_TOPIC_0000001811609669__p40373845104858">[Proposal] It is recommended that you enable the <strong id="EN-US_TOPIC_0000001811609669__b842352706142820">autocommit</strong> switch in the code for connecting to <span id="EN-US_TOPIC_0000001811609669__text265447366">GaussDB(DWS)</span> by the JDBC. If <strong id="EN-US_TOPIC_0000001811609669__b842352706143016">autocommit</strong> needs to be disabled to improve performance or for other purposes, applications need to ensure their transactions are committed. For example, explicitly commit translations after specifying service SQL statements. Particularly, ensure that all transactions are committed before the client exits.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402413__section1577694110277"><h4 class="sectiontitle">Connection Releasing</h4><p id="EN-US_TOPIC_0000001510402413__p144341064916">[Proposal] You are advised to use connection pools to limit the number of connections from applications. Do not connect to a database every time you run an SQL statement.</p>
<p id="EN-US_TOPIC_0000001510402413__p23100085">[Proposal] After an application completes its tasks, disconnect its connection to <span id="EN-US_TOPIC_0000001510402413__text94760255">GaussDB(DWS)</span> to release occupied resources. You are advised to set the session timeout interval in the task.</p>
<p id="EN-US_TOPIC_0000001510402413__p1964373612402">[Proposal] Reset the session environment before releasing connections to the JDBC connection tool. Otherwise, historical session information may cause object conflicts.</p>
<ul id="EN-US_TOPIC_0000001510402413__ul319815399488"><li id="EN-US_TOPIC_0000001510402413__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001510402413__b29451737105610">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001510402413__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001811609669__section1577694110277"><h4 class="sectiontitle">Connection Releasing</h4><p id="EN-US_TOPIC_0000001811609669__p144341064916">[Proposal] You are advised to use connection pools to limit the number of connections from applications. Do not connect to a database every time you run an SQL statement.</p>
<p id="EN-US_TOPIC_0000001811609669__p23100085">[Proposal] After an application completes its tasks, disconnect its connection to <span id="EN-US_TOPIC_0000001811609669__text94760255">GaussDB(DWS)</span> to release occupied resources. You are advised to set the session timeout interval in the task.</p>
<p id="EN-US_TOPIC_0000001811609669__p1964373612402">[Proposal] Reset the session environment before releasing connections to the JDBC connection tool. Otherwise, historical session information may cause object conflicts.</p>
<ul id="EN-US_TOPIC_0000001811609669__ul319815399488"><li id="EN-US_TOPIC_0000001811609669__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001811609669__b155527413207">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001811609669__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510402413__section1624965810277"><h4 class="sectiontitle">CopyManager</h4><p id="EN-US_TOPIC_0000001510402413__p1841431102854">[Proposal] In the scenario where the ETL tool is not used and real-time data import is required, it is recommended that you use the CopyManager interface driven by the <span id="EN-US_TOPIC_0000001510402413__text1842924135611">GaussDB(DWS)</span> JDBC to import data in batches during application development.</p>
<p id="EN-US_TOPIC_0000001510402413__p17571351132311">For details about how to use CopyManager, see <a href="dws_04_0116.html">CopyManager</a>.</p>
<div class="section" id="EN-US_TOPIC_0000001811609669__section1624965810277"><h4 class="sectiontitle">CopyManager</h4><p id="EN-US_TOPIC_0000001811609669__p1841431102854">[Proposal] In the scenario where the ETL tool is not used and real-time data import is required, it is recommended that you use the CopyManager interface driven by the <span id="EN-US_TOPIC_0000001811609669__text12103183452013">GaussDB(DWS)</span> JDBC to import data in batches during application development.</p>
<p id="EN-US_TOPIC_0000001811609669__p17571351132311">For how to use CopyManager, see <a href="dws_04_0102.html#EN-US_TOPIC_0000002080099797__en-us_topic_0000001188642156_section63487150165">CopyManager</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0107.html">Detailed Design Rules for GaussDB(DWS) Objects</a></div>
</div>
</div>

View File

@ -1,35 +1,35 @@
<a name="EN-US_TOPIC_0000001510283305"></a><a name="EN-US_TOPIC_0000001510283305"></a>
<a name="EN-US_TOPIC_0000001811490821"></a><a name="EN-US_TOPIC_0000001811490821"></a>
<h1 class="topictitle1">GaussDB(DWS) SQL Writing Rules</h1>
<div id="body1528161858339"><div class="section" id="EN-US_TOPIC_0000001510283305__section60205875143313"><h4 class="sectiontitle">DDL</h4><ul id="EN-US_TOPIC_0000001510283305__ul1972862419595"><li id="EN-US_TOPIC_0000001510283305__li1072832415918">[Proposal] In <span id="EN-US_TOPIC_0000001510283305__text526581581">GaussDB(DWS)</span>, you are advised to execute DDL operations, such as creating table or making comments, separately from batch processing jobs to avoid performance deterioration caused by many concurrent transactions.</li><li id="EN-US_TOPIC_0000001510283305__li5212735919">[Proposal] Execute data truncation after unlogged tables are used because <span id="EN-US_TOPIC_0000001510283305__text281995683">GaussDB(DWS)</span> cannot ensure the security of unlogged tables in abnormal scenarios.</li><li id="EN-US_TOPIC_0000001510283305__li1719012919599">[Proposal] Suggestions on the storage mode of temporary and unlogged tables are the same as those on base tables. Create temporary tables in the same storage mode as the base tables to avoid high computing costs caused by hybrid row and column correlation.</li><li id="EN-US_TOPIC_0000001510283305__li1661583105916">[Proposal] The total length of an index column cannot exceed 50 bytes. Otherwise, the index size will increase greatly, resulting in large storage cost and low index performance.</li><li id="EN-US_TOPIC_0000001510283305__li17294434115910">[Proposal] Do not delete objects using <strong id="EN-US_TOPIC_0000001510283305__b175334270593533">DROP...CASCADE</strong>, unless the dependency between objects is specified. Otherwise, the objects may be deleted by mistake.</li></ul>
<div id="body1528161858339"><div class="section" id="EN-US_TOPIC_0000001811490821__section60205875143313"><h4 class="sectiontitle">DDL</h4><ul id="EN-US_TOPIC_0000001811490821__ul1972862419595"><li id="EN-US_TOPIC_0000001811490821__li1072832415918">[Proposal] In <span id="EN-US_TOPIC_0000001811490821__text526581581">GaussDB(DWS)</span>, you are advised to execute DDL operations, such as creating table or making comments, separately from batch processing jobs to avoid performance deterioration caused by many concurrent transactions.</li><li id="EN-US_TOPIC_0000001811490821__li5212735919">[Proposal] Execute data truncation after unlogged tables are used because <span id="EN-US_TOPIC_0000001811490821__text281995683">GaussDB(DWS)</span> cannot ensure the security of unlogged tables in abnormal scenarios.</li><li id="EN-US_TOPIC_0000001811490821__li1719012919599">[Proposal] Suggestions on the storage mode of temporary and unlogged tables are the same as those on base tables. Create temporary tables in the same storage mode as the base tables to avoid high computing costs caused by hybrid row and column correlation.</li><li id="EN-US_TOPIC_0000001811490821__li1661583105916">[Proposal] The total length of an index column cannot exceed 50 bytes. Otherwise, the index size will increase greatly, resulting in large storage cost and low index performance.</li><li id="EN-US_TOPIC_0000001811490821__li17294434115910">[Proposal] Do not delete objects using <strong id="EN-US_TOPIC_0000001811490821__b175334270593533">DROP...CASCADE</strong>, unless the dependency between objects is specified. Otherwise, the objects may be deleted by mistake.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section45234071153513"><h4 class="sectiontitle">Data Loading and Uninstalling</h4><ul id="EN-US_TOPIC_0000001510283305__ul866153885912"><li id="EN-US_TOPIC_0000001510283305__li1466143811599">[Proposal] Provide the inserted column list in the insert statement. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen206623818595"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">task</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="n">id</span><span class="p">,</span><span class="k">comment</span><span class="p">)</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="p">(</span><span class="s1">'task1'</span><span class="p">,</span><span class="s1">'100'</span><span class="p">,</span><span class="s1">'100th task'</span><span class="p">);</span>
<div class="section" id="EN-US_TOPIC_0000001811490821__section45234071153513"><h4 class="sectiontitle">Data Loading and Uninstalling</h4><ul id="EN-US_TOPIC_0000001811490821__ul866153885912"><li id="EN-US_TOPIC_0000001811490821__li1466143811599">[Proposal] Provide the inserted column list in the insert statement. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen206623818595"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">task</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="n">id</span><span class="p">,</span><span class="k">comment</span><span class="p">)</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="p">(</span><span class="s1">'task1'</span><span class="p">,</span><span class="s1">'100'</span><span class="p">,</span><span class="s1">'100th task'</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li1018434110596">[Proposal] After data is imported to the database in batches or the data increment reaches the threshold, you are advised to analyze tables to prevent the execution plan from being degraded due to inaccurate statistics.</li><li id="EN-US_TOPIC_0000001510283305__li18713443105913">[Proposal] To clear all data in a table, you are advised to use <strong id="EN-US_TOPIC_0000001510283305__b1688884693638">TRUNCATE TABLE</strong> instead of <strong id="EN-US_TOPIC_0000001510283305__b200528289993638">DELETE TABLE</strong>. <strong id="EN-US_TOPIC_0000001510283305__b60032975893717">DELETE TABLE</strong> is not efficient and cannot release disk space occupied by the deleted data.</li></ul>
</li><li id="EN-US_TOPIC_0000001811490821__li1018434110596">[Proposal] After data is imported to the database in batches or the data increment reaches the threshold, you are advised to analyze tables to prevent the execution plan from being degraded due to inaccurate statistics.</li><li id="EN-US_TOPIC_0000001811490821__li18713443105913">[Proposal] To clear all data in a table, you are advised to use <strong id="EN-US_TOPIC_0000001811490821__b1688884693638">TRUNCATE TABLE</strong> instead of <strong id="EN-US_TOPIC_0000001811490821__b200528289993638">DELETE TABLE</strong>. <strong id="EN-US_TOPIC_0000001811490821__b60032975893717">DELETE TABLE</strong> is not efficient and cannot release disk space occupied by the deleted data.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section28537273145311"><h4 class="sectiontitle">Type conversion</h4><ul id="EN-US_TOPIC_0000001510283305__ul11745246115918"><li id="EN-US_TOPIC_0000001510283305__li27451746135914">[Proposal] Perform type coercion to convert data types. If you perform implicit conversion, the result may differ from expected.</li><li id="EN-US_TOPIC_0000001510283305__li3440349125917">[Proposal] During data query, explicitly specify the data type for constants, and do not attempt to perform any implicit data type conversion.</li><li id="EN-US_TOPIC_0000001510283305__li1731052145918">[Notice] In Oracle compatibility mode, null strings will be automatically converted to NULL during data import. If a null string needs to be reserved, you need to create a database that is compatible with Teradata.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001811490821__section28537273145311"><h4 class="sectiontitle">Type conversion</h4><ul id="EN-US_TOPIC_0000001811490821__ul11745246115918"><li id="EN-US_TOPIC_0000001811490821__li27451746135914">[Proposal] Perform type coercion to convert data types. If you perform implicit conversion, the result may differ from expected.</li><li id="EN-US_TOPIC_0000001811490821__li3440349125917">[Proposal] During data query, explicitly specify the data type for constants, and do not attempt to perform any implicit data type conversion.</li><li id="EN-US_TOPIC_0000001811490821__li1731052145918">[Notice] In Oracle compatibility mode, null strings will be automatically converted to NULL during data import. If a null string needs to be reserved, you need to create a database that is compatible with Teradata.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section48841047154511"><h4 class="sectiontitle">Query Operation</h4><ul id="EN-US_TOPIC_0000001510283305__ul31156185916"><li id="EN-US_TOPIC_0000001510283305__li1311156185914">[Proposal] Do not return a large number of result sets to a client except the ETL program. If a large result set is returned, consider modifying your service design.</li><li id="EN-US_TOPIC_0000001510283305__li8373115875917">[Proposal] Perform DDL and DML operations encapsulated in transactions. Operations like table truncation, update, deletion, and dropping, cannot be rolled back once committed. You are advised to encapsulate such operations in transactions so that you can roll back the operations if necessary.</li><li id="EN-US_TOPIC_0000001510283305__li13858707018">[Proposal] During query compilation, you are advised to list all columns to be queried and avoid using <strong id="EN-US_TOPIC_0000001510283305__b842352706162352">*</strong>. Doing so reduces output lines, improves query performance, and avoids the impact of adding or deleting columns on front-end service compatibility.</li><li id="EN-US_TOPIC_0000001510283305__li18254841303">[Proposal] During table object access, add the schema prefix to the table object to avoid accessing an unexpected table due to schema switchover.</li><li id="EN-US_TOPIC_0000001510283305__li36071160012">[Proposal] The cost of joining more than three tables or views, especially full joins, is difficult to be estimated. You are advised to use the <strong id="EN-US_TOPIC_0000001510283305__b842352706114736">WITH TABLE AS</strong> statement to create interim tables to improve the readability of SQL statements.</li><li id="EN-US_TOPIC_0000001510283305__li17291295012">[Proposal] Do not use Cartesian products or full joins. Cartesian products and full joins will result in a sharp expansion of result sets and poor performance.</li><li id="EN-US_TOPIC_0000001510283305__li142772131306">[Notice] Only <strong id="EN-US_TOPIC_0000001510283305__b842352706115240">IS NULL</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706115243">IS NOT NULL</strong> can be used to determine NULL value comparison results. If any other method is used, NULL is returned. For example, <strong id="EN-US_TOPIC_0000001510283305__b1727151044012">NULL</strong> instead of expected Boolean values is returned for <strong id="EN-US_TOPIC_0000001510283305__b842352706115627">NULL&lt;&gt;NULL</strong>, <strong id="EN-US_TOPIC_0000001510283305__b842352706115631">NULL=NULL</strong>, and <strong id="EN-US_TOPIC_0000001510283305__b842352706115635">NULL&lt;&gt;1</strong>.</li><li id="EN-US_TOPIC_0000001510283305__li16640101611013">[Notice] Do not use count(col) instead of count(*) to count the total number of records in a table. count(*) counts the NULL value (actual rows) while count (col) does not.</li><li id="EN-US_TOPIC_0000001510283305__li94211913016">[Notice] While executing count(col), the number of NULL record rows is counted as 0. While executing sum(col), NULL is returned if all records are NULL. If not all the records are NULL, the number of NULL record rows is counted as 0.</li><li id="EN-US_TOPIC_0000001510283305__li96616211405">[Notice] To count multiple columns using count(), column names must be enclosed with parentheses. For example, count ((col1, col2, col3)). Note: When multiple columns are used to count the number of NULL record rows, a row is counted even if all the selected columns are NULL. The result is the same as that when count(*) is executed.</li><li id="EN-US_TOPIC_0000001510283305__li159382516013">[Notice] Null records are not counted when count(distinct col) is used to calculate the number of non-null columns that are not repeated.</li><li id="EN-US_TOPIC_0000001510283305__li174733286016">[Notice] If all statistical columns are NULL when count(distinct (col1,col2,...)) is used to count the number of unique values in multiple columns, Null records are also counted, and the records are considered the same.</li><li id="EN-US_TOPIC_0000001510283305__li875853413494">[Notice] When constants are used to filter data, the system searches for functions used for calculating these two data types based on the data types of the constants and matched columns. If no function is found, the system converts the data type implicitly. Then, the system searches for a function used for calculating the converted data type.<pre class="screen" id="EN-US_TOPIC_0000001510283305__screen1269491605712">SELECT * FROM test WHERE timestamp_col = 20000101;</pre>
<p id="EN-US_TOPIC_0000001510283305__p3801145495418">In the preceding example, if <strong id="EN-US_TOPIC_0000001510283305__b4478175201020">timestamp_col</strong> is the timestamp type, the system first searches for the function that supports the "equal" operation of the timestamp and int types (constant numbers are considered as the int type). If no such function is found, the <strong id="EN-US_TOPIC_0000001510283305__b1528517173164">timestamp_col</strong> data and constant numbers are implicitly converted into the text type for calculation.</p>
</li><li id="EN-US_TOPIC_0000001510283305__li54741939206">[Proposal] Do not use scalar subquery statements. A scalar subquery appears in the output list of a <strong id="EN-US_TOPIC_0000001510283305__b84235270615556">SELECT</strong> statement. In the following example, the part enclosed in parentheses is a scalar subquery statement:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen047418392014"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">films</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">f</span><span class="p">.</span><span class="n">did</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">.</span><span class="n">id</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">staffs_p1</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
<div class="section" id="EN-US_TOPIC_0000001811490821__section48841047154511"><h4 class="sectiontitle">Query Operation</h4><ul id="EN-US_TOPIC_0000001811490821__ul31156185916"><li id="EN-US_TOPIC_0000001811490821__li1311156185914">[Proposal] Do not return a large number of result sets to a client except the ETL program. If a large result set is returned, consider modifying your service design.</li><li id="EN-US_TOPIC_0000001811490821__li8373115875917">[Proposal] Perform DDL and DML operations encapsulated in transactions. Operations like table truncation, update, deletion, and dropping, cannot be rolled back once committed. You are advised to encapsulate such operations in transactions so that you can roll back the operations if necessary.</li><li id="EN-US_TOPIC_0000001811490821__li13858707018">[Proposal] During query compilation, you are advised to list all columns to be queried and avoid using <strong id="EN-US_TOPIC_0000001811490821__b842352706162352">*</strong>. Doing so reduces output lines, improves query performance, and avoids the impact of adding or deleting columns on front-end service compatibility.</li><li id="EN-US_TOPIC_0000001811490821__li18254841303">[Proposal] During table object access, add the schema prefix to the table object to avoid accessing an unexpected table due to schema switchover.</li><li id="EN-US_TOPIC_0000001811490821__li36071160012">[Proposal] The cost of joining more than eight tables or views, especially full joins, is difficult to be estimated. You are advised to use the <strong id="EN-US_TOPIC_0000001811490821__b842352706114736">WITH TABLE AS</strong> statement or other methods to create interim tables to improve the readability of SQL statements.</li><li id="EN-US_TOPIC_0000001811490821__li17291295012">[Proposal] Do not use Cartesian products or full joins. Cartesian products and full joins will result in a sharp expansion of result sets and poor performance.</li><li id="EN-US_TOPIC_0000001811490821__li142772131306">[Notice] Only <strong id="EN-US_TOPIC_0000001811490821__b842352706115240">IS NULL</strong> and <strong id="EN-US_TOPIC_0000001811490821__b842352706115243">IS NOT NULL</strong> can be used to determine NULL value comparison results. If any other method is used, NULL is returned. For example, <strong id="EN-US_TOPIC_0000001811490821__b1727151044012">NULL</strong> instead of expected Boolean values is returned for <strong id="EN-US_TOPIC_0000001811490821__b842352706115627">NULL&lt;&gt;NULL</strong>, <strong id="EN-US_TOPIC_0000001811490821__b842352706115631">NULL=NULL</strong>, and <strong id="EN-US_TOPIC_0000001811490821__b842352706115635">NULL&lt;&gt;1</strong>.</li><li id="EN-US_TOPIC_0000001811490821__li16640101611013">[Notice] Do not use count(col) instead of count(*) to count the total number of records in a table. count(*) counts the NULL value (actual rows) while count (col) does not.</li><li id="EN-US_TOPIC_0000001811490821__li94211913016">[Notice] While executing count(col), the number of NULL record rows is counted as 0. While executing sum(col), NULL is returned if all records are NULL. If not all the records are NULL, the number of NULL record rows is counted as 0.</li><li id="EN-US_TOPIC_0000001811490821__li96616211405">[Notice] To count multiple columns using count(), column names must be enclosed with parentheses. For example, count ((col1, col2, col3)). Note: When multiple columns are used to count the number of NULL record rows, a row is counted even if all the selected columns are NULL. The result is the same as that when count(*) is executed.</li><li id="EN-US_TOPIC_0000001811490821__li159382516013">[Notice] Null records are not counted when count(distinct col) is used to calculate the number of non-null columns that are not repeated.</li><li id="EN-US_TOPIC_0000001811490821__li174733286016">[Notice] If all statistical columns are NULL when count(distinct (col1,col2,...)) is used to count the number of unique values in multiple columns, Null records are also counted, and the records are considered the same.</li><li id="EN-US_TOPIC_0000001811490821__li875853413494">[Notice] When constants are used to filter data, the system searches for functions used for calculating these two data types based on the data types of the constants and matched columns. If no function is found, the system converts the data type implicitly. Then, the system searches for a function used for calculating the converted data type.<pre class="screen" id="EN-US_TOPIC_0000001811490821__screen1269491605712">SELECT * FROM test WHERE timestamp_col = 20000101;</pre>
<p id="EN-US_TOPIC_0000001811490821__p3801145495418">In the preceding example, if <strong id="EN-US_TOPIC_0000001811490821__b4478175201020">timestamp_col</strong> is the timestamp type, the system first searches for the function that supports the "equal" operation of the timestamp and int types (constant numbers are considered as the int type). If no such function is found, the <strong id="EN-US_TOPIC_0000001811490821__b1528517173164">timestamp_col</strong> data and constant numbers are implicitly converted into the text type for calculation.</p>
</li><li id="EN-US_TOPIC_0000001811490821__li54741939206">[Proposal] Do not use scalar subquery statements. A scalar subquery appears in the output list of a <strong id="EN-US_TOPIC_0000001811490821__b84235270615556">SELECT</strong> statement. In the following example, the part enclosed in parentheses is a scalar subquery statement:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen047418392014"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">films</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">f</span><span class="p">.</span><span class="n">did</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">.</span><span class="n">id</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">staffs_p1</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p65339406113426">Scalar subqueries often result in query performance deterioration. During application development, scalar subqueries need to be converted into equivalent table associations based on the service logic.</p>
</li><li id="EN-US_TOPIC_0000001510283305__li6104647302">[Proposal] In <strong id="EN-US_TOPIC_0000001510283305__b842352706172811">WHERE</strong> clauses, the filtering conditions should be sorted. The condition that few records are selected for reading (the number of filtered records is small) is listed at the beginning.</li><li id="EN-US_TOPIC_0000001510283305__li20777449808">[Proposal] Filtering conditions in <strong id="EN-US_TOPIC_0000001510283305__b842352706172821">WHERE</strong> clauses should comply with unilateral rules. That is, when the column name is placed on one side of a comparison operator, the optimizer automatically performs pruning optimization in some scenarios. Filtering conditions in a <strong id="EN-US_TOPIC_0000001510283305__b124629312895126">WHERE</strong> clause will be displayed in <strong id="EN-US_TOPIC_0000001510283305__b139129845295126">col op expression</strong> format, where <strong id="EN-US_TOPIC_0000001510283305__b119823048695126">col</strong> indicates a table column, <strong id="EN-US_TOPIC_0000001510283305__b1037389995126">op</strong> indicates a comparison operator, such as = and &gt;, and <strong id="EN-US_TOPIC_0000001510283305__b89754445695126">expression</strong> indicates an expression that does not contain a column name. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen677711491903"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
<p id="EN-US_TOPIC_0000001811490821__p65339406113426">Scalar subqueries often result in query performance deterioration. During application development, scalar subqueries need to be converted into equivalent table associations based on the service logic.</p>
</li><li id="EN-US_TOPIC_0000001811490821__li6104647302">[Proposal] In <strong id="EN-US_TOPIC_0000001811490821__b842352706172811">WHERE</strong> clauses, the filtering conditions should be sorted. The condition that few records are selected for reading (the number of filtered records is small) is listed at the beginning.</li><li id="EN-US_TOPIC_0000001811490821__li20777449808">[Proposal] Filtering conditions in <strong id="EN-US_TOPIC_0000001811490821__b842352706172821">WHERE</strong> clauses should comply with unilateral rules. That is, when the column name is placed on one side of a comparison operator, the optimizer automatically performs pruning optimization in some scenarios. Filtering conditions in a <strong id="EN-US_TOPIC_0000001811490821__b124629312895126">WHERE</strong> clause will be displayed in <strong id="EN-US_TOPIC_0000001811490821__b139129845295126">col op expression</strong> format, where <strong id="EN-US_TOPIC_0000001811490821__b119823048695126">col</strong> indicates a table column, <strong id="EN-US_TOPIC_0000001811490821__b1037389995126">op</strong> indicates a comparison operator, such as = and &gt;, and <strong id="EN-US_TOPIC_0000001811490821__b89754445695126">expression</strong> indicates an expression that does not contain a column name. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen677711491903"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p26912854112759">The modification is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen40889095112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
<p id="EN-US_TOPIC_0000001811490821__p26912854112759">The modification is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen40889095112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li18346183117">[Proposal] Do not perform unnecessary sorting operations. Sorting requires a large amount of memory and CPU. If service logic permits, <strong id="EN-US_TOPIC_0000001510283305__b842352706164621">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706164624">LIMIT</strong> can be combined to reduce resource overhead. By default, data in <span id="EN-US_TOPIC_0000001510283305__text30313868">GaussDB(DWS)</span> is sorted by ASC &amp; NULL LAST.</li><li id="EN-US_TOPIC_0000001510283305__li1294114512111">[Proposal] When the <strong id="EN-US_TOPIC_0000001510283305__b842352706164757">ORDER BY</strong> clause is used for sorting, specify sorting modes (ASC or DESC), and use NULL FIRST or NULL LAST for NULL record sorting.</li><li id="EN-US_TOPIC_0000001510283305__li5371188317">[proposal] Do not rely on only the <strong id="EN-US_TOPIC_0000001510283305__b842352706165145">LIMIT</strong> clause to return the result set displayed in a specific sequence. Combine <strong id="EN-US_TOPIC_0000001510283305__b842352706165346">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706165350">LIMIT</strong> clauses for some specific result sets and use offset to skip specific results if necessary.</li><li id="EN-US_TOPIC_0000001510283305__li861011115">[Proposal] If the service logic is accurate, you are advised to use <strong id="EN-US_TOPIC_0000001510283305__b84235270617118">UNION ALL</strong> instead of <strong id="EN-US_TOPIC_0000001510283305__b84235270617121">UNION</strong>.</li><li id="EN-US_TOPIC_0000001510283305__li957714131716">[Proposal] If a filtering condition contains only an <strong id="EN-US_TOPIC_0000001510283305__b84235270617126">OR</strong> expression, convert the <strong id="EN-US_TOPIC_0000001510283305__b84235270617135">OR </strong>expression to <strong id="EN-US_TOPIC_0000001510283305__b84235270617131">UNION ALL</strong> to improve performance. SQL statements that use <strong id="EN-US_TOPIC_0000001510283305__b84235270617155">OR</strong> expressions cannot be optimized, resulting in slow execution. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen1757791320111"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
</li><li id="EN-US_TOPIC_0000001811490821__li18346183117">[Proposal] Do not perform unnecessary sorting operations. Sorting requires a large amount of memory and CPU. If service logic permits, <strong id="EN-US_TOPIC_0000001811490821__b842352706164621">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001811490821__b842352706164624">LIMIT</strong> can be combined to reduce resource overhead. By default, data in <span id="EN-US_TOPIC_0000001811490821__text30313868">GaussDB(DWS)</span> is sorted by ASC &amp; NULL LAST.</li><li id="EN-US_TOPIC_0000001811490821__li1294114512111">[Proposal] When the <strong id="EN-US_TOPIC_0000001811490821__b842352706164757">ORDER BY</strong> clause is used for sorting, specify sorting modes (ASC or DESC), and use NULL FIRST or NULL LAST for NULL record sorting.</li><li id="EN-US_TOPIC_0000001811490821__li5371188317">[proposal] Do not rely on only the <strong id="EN-US_TOPIC_0000001811490821__b842352706165145">LIMIT</strong> clause to return the result set displayed in a specific sequence. Combine <strong id="EN-US_TOPIC_0000001811490821__b842352706165346">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001811490821__b842352706165350">LIMIT</strong> clauses for some specific result sets and use offset to skip specific results if necessary.</li><li id="EN-US_TOPIC_0000001811490821__li861011115">[Proposal] If the service logic is accurate, you are advised to use <strong id="EN-US_TOPIC_0000001811490821__b84235270617118">UNION ALL</strong> instead of <strong id="EN-US_TOPIC_0000001811490821__b84235270617121">UNION</strong>.</li><li id="EN-US_TOPIC_0000001811490821__li957714131716">[Proposal] If a filtering condition contains only an <strong id="EN-US_TOPIC_0000001811490821__b84235270617126">OR</strong> expression, convert the <strong id="EN-US_TOPIC_0000001811490821__b84235270617135">OR </strong>expression to <strong id="EN-US_TOPIC_0000001811490821__b84235270617131">UNION ALL</strong> to improve performance. SQL statements that use <strong id="EN-US_TOPIC_0000001811490821__b84235270617155">OR</strong> expressions cannot be optimized, resulting in slow execution. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen1757791320111"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">scdc</span><span class="p">.</span><span class="n">pub_menu</span><span class="w"> </span>
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">300</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">301</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">302</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">302</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p9824563112759">Convert the statement to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen36954014112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<p id="EN-US_TOPIC_0000001811490821__p9824563112759">Convert the statement to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen36954014112759"><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>
@ -46,21 +46,21 @@
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">302</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li88758236119">[Proposal] If an <strong id="EN-US_TOPIC_0000001510283305__b14611738104614">in(val1, val2, va...)</strong> expression contains a large number of columns, you are advised to replace it with the <strong id="EN-US_TOPIC_0000001510283305__b1061153813465">in (values (va1), (val2),(val3...)</strong> statement. The optimizer will automatically convert the <strong id="EN-US_TOPIC_0000001510283305__b1458111681316">IN</strong> constraint into a non-correlated subquery to improve the query performance.</li><li id="EN-US_TOPIC_0000001510283305__li1837032616114">[Proposal] Replace <strong id="EN-US_TOPIC_0000001510283305__b842352706174314">(not) in</strong> with <strong id="EN-US_TOPIC_0000001510283305__b842352706174319">(not) exist</strong> when associated columns do not contain <strong id="EN-US_TOPIC_0000001510283305__b176681586284">NULL</strong> values. For example, in the following query statement, if the T1.C1 column does not contain any NULL value, add the NOT NULL constraint to the T1.C1 column, and then rewrite the statements.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen133702262115"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">IN</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T2</span><span class="p">);</span>
</li><li id="EN-US_TOPIC_0000001811490821__li88758236119">[Proposal] If an <strong id="EN-US_TOPIC_0000001811490821__b14611738104614">in(val1, val2, va...)</strong> expression contains a large number of columns, you are advised to replace it with the <strong id="EN-US_TOPIC_0000001811490821__b1061153813465">in (values (va1), (val2),(val3...)</strong> statement. The optimizer will automatically convert the <strong id="EN-US_TOPIC_0000001811490821__b1458111681316">IN</strong> constraint into a non-correlated subquery to improve the query performance.</li><li id="EN-US_TOPIC_0000001811490821__li1837032616114">[Proposal] Replace <strong id="EN-US_TOPIC_0000001811490821__b842352706174314">(not) in</strong> with <strong id="EN-US_TOPIC_0000001811490821__b842352706174319">(not) exist</strong> when associated columns do not contain <strong id="EN-US_TOPIC_0000001811490821__b176681586284">NULL</strong> values. For example, in the following query statement, if the T1.C1 column does not contain any NULL value, add the NOT NULL constraint to the T1.C1 column, and then rewrite the statements.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen133702262115"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">IN</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T2</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p58071969112759">Rewrite the statement as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen52885675112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="p">,</span><span class="n">T2</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="o">=</span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="p">);</span>
<p id="EN-US_TOPIC_0000001811490821__p58071969112759">Rewrite the statement as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001811490821__screen52885675112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T1</span><span class="p">,</span><span class="n">T2</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="o">=</span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001510283305__note30088550112759"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001510283305__ul33169334112759"><li id="EN-US_TOPIC_0000001510283305__li6209029112759">If the value of the T1.C1 column will possibly be NULL, the preceding rewriting cannot be performed.</li><li id="EN-US_TOPIC_0000001510283305__li55881264112759">If T1.C1 is the output of a subquery, check whether the output is NOT NULL based on the service logic.</li></ul>
<div class="note" id="EN-US_TOPIC_0000001811490821__note30088550112759"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001811490821__ul33169334112759"><li id="EN-US_TOPIC_0000001811490821__li6209029112759">If the value of the T1.C1 column will possibly be NULL, the preceding rewriting cannot be performed.</li><li id="EN-US_TOPIC_0000001811490821__li55881264112759">If T1.C1 is the output of a subquery, check whether the output is NOT NULL based on the service logic.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001510283305__li145891038416">[Proposal] Use cursors instead of the <strong id="EN-US_TOPIC_0000001510283305__b842352706171649">LIMIT OFFSET</strong> syntax to perform pagination queries to avoid resource overheads caused by multiple executions. A cursor must be used in a transaction, and you must disable it and commit transaction once the query is finished.</li></ul>
</li><li id="EN-US_TOPIC_0000001811490821__li145891038416">[Proposal] Use cursors instead of the <strong id="EN-US_TOPIC_0000001811490821__b842352706171649">LIMIT OFFSET</strong> syntax to perform pagination queries to avoid resource overheads caused by multiple executions. A cursor must be used in a transaction, and you must disable it and commit transaction once the query is finished.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0107.html">Detailed Design Rules for GaussDB(DWS) Objects</a></div>
</div>
</div>

View File

@ -1,12 +1,10 @@
<a name="EN-US_TOPIC_0000001510283385"></a><a name="EN-US_TOPIC_0000001510283385"></a>
<a name="EN-US_TOPIC_0000001764491332"></a><a name="EN-US_TOPIC_0000001764491332"></a>
<h1 class="topictitle1">Using JDBC or ODBC for GaussDB(DWS) Secondary Development</h1>
<div id="body1494318355094"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0086.html">Development Specifications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0087.html">Downloading Drivers</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0086.html">Prerequisites</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0088.html">JDBC-Based Development</a></strong><br>
</li>

View File

@ -1,9 +1,11 @@
<a name="EN-US_TOPIC_0000001460882696"></a><a name="EN-US_TOPIC_0000001460882696"></a>
<a name="EN-US_TOPIC_0000001764491284"></a><a name="EN-US_TOPIC_0000001764491284"></a>
<h1 class="topictitle1">Development Specifications</h1>
<div id="body1524796389552"><p id="EN-US_TOPIC_0000001460882696__p168620462426">If the connection pool mechanism is used during application development, comply with the following specifications:</p>
<ul id="EN-US_TOPIC_0000001460882696__ul319815399488"><li id="EN-US_TOPIC_0000001460882696__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001460882696__b84235270618227">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001460882696__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul>
<p id="EN-US_TOPIC_0000001460882696__p1686746104213">If you do not do so, the status of connections in the connection pool will remain, which affects subsequent operations using the connection pool.</p>
<h1 class="topictitle1">Prerequisites</h1>
<div id="body1524796389552"><p id="EN-US_TOPIC_0000001764491284__p168620462426">If the connection pool mechanism is used during application development, comply with the following specifications:</p>
<ul id="EN-US_TOPIC_0000001764491284__ul319815399488"><li id="EN-US_TOPIC_0000001764491284__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001764491284__b84235270618227">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001764491284__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul>
<p id="EN-US_TOPIC_0000001764491284__p1686746104213">If you do not do so, the status of connections in the connection pool will remain, which affects subsequent operations using the connection pool.</p>
<div class="section" id="EN-US_TOPIC_0000001764491284__section1525135874516"><h4 class="sectiontitle">Downloading Drivers</h4><p id="EN-US_TOPIC_0000001764491284__en-us_topic_0000001099130898_p4451066501">For details, see "Downloading the JDBC or ODBC Driver" in the <em id="EN-US_TOPIC_0000001764491284__i16452457151814">Data Warehouse Service (DWS) User Guide</em>.</p>
</div>
</div>
<div>
<div class="familylinks">

View File

@ -1,11 +0,0 @@
<a name="EN-US_TOPIC_0000001460722600"></a><a name="EN-US_TOPIC_0000001460722600"></a>
<h1 class="topictitle1">Downloading Drivers</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001460722600__en-us_topic_0000001099130898_p4451066501">For details, see section "Downloading the JDBC or ODBC Driver" in the <em id="EN-US_TOPIC_0000001460722600__i0667146155217">Data Warehouse Service User Guide</em>.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0085.html">Using JDBC or ODBC for GaussDB(DWS) Secondary Development</a></div>
</div>
</div>

View File

@ -1,13 +1,12 @@
<a name="EN-US_TOPIC_0000001460882148"></a><a name="EN-US_TOPIC_0000001460882148"></a>
<a name="EN-US_TOPIC_0000001811490945"></a><a name="EN-US_TOPIC_0000001811490945"></a>
<h1 class="topictitle1">JDBC-Based Development</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001460882148__aa806003196d444e4910e8aeb1d0e7753">Java Database Connectivity (JDBC) is a Java API for executing SQL statements, providing a unified access interface for different relational databases, based on which applications process data. <span id="EN-US_TOPIC_0000001460882148__text868486363">GaussDB(DWS)</span> supports JDBC 4.0 and requires JDK 1.6 or later for code compiling. It does not support JDBC-ODBC Bridge.</p>
</div>
<div id="body8662426"></div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0090.html">JDBC Package and Driver Class</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0089.html">JDBC Development Process</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0091.html">Development Process</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0090.html">JDBC Package and Driver Class</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0092.html">Loading a Driver</a></strong><br>
</li>
@ -17,19 +16,11 @@
</li>
<li class="ulchildlink"><strong><a href="dws_04_0096.html">Processing Data in a Result Set</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0097.html">Closing the Connection</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0098.html">Common JDBC Development Examples</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0098.html">Example: Common Operations</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_10001.html">Processing RoaringBitmap Result Sets and Importing It to GaussDB (DWS)</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0099.html">Example: Retrying SQL Queries for Applications</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0100.html">Example: Importing and Exporting Data Through Local Files</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0101.html">Example: Migrating Data from MySQL to GaussDB(DWS)</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_10001.html">Example: Processing the RoaringBitmap Result Set on Application Then Importing It to GaussDB(DWS)</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0102.html">JDBC Interface Reference</a></strong><br>
<li class="ulchildlink"><strong><a href="dws_04_0102.html">JDBC Interfaces</a></strong><br>
</li>
</ul>

View File

@ -0,0 +1,47 @@
<a name="EN-US_TOPIC_0000001811610389"></a><a name="EN-US_TOPIC_0000001811610389"></a>
<h1 class="topictitle1">JDBC Development Process</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001811610389__p545167125412">Java Database Connectivity (JDBC) is a Java API for executing SQL statements. It provides a unified access interface for multiple relational databases, enabling applications to work with data based on it. <span id="EN-US_TOPIC_0000001811610389__text1882152292010">GaussDB(DWS)</span> supports JDBC 4.0 and requires JDK 1.6 or later for code compiling. It does not support JDBC-ODBC Bridge. The following figure shows the JDBC application development process.</p>
<div class="fignone" id="EN-US_TOPIC_0000001811610389__feb66a934167849b38e150168fc75ccc7"><span class="figcap"><b>Figure 1 </b>JDBC-based application development process</span><br><span><img id="EN-US_TOPIC_0000001811610389__i93b7b54d75924255aa7a107b98b71aec" src="figure/en-us_image_0000002044100078.png"></span></div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001811610389__table1659815133269" frame="border" border="1" rules="all"><caption><b>Table 1 </b>JDBC development process</caption><thead align="left"><tr id="EN-US_TOPIC_0000001811610389__row559915132261"><th align="left" class="cellrowborder" valign="top" width="19.55%" id="mcps1.3.3.2.3.1.1"><p id="EN-US_TOPIC_0000001811610389__p95992013182616"><strong id="EN-US_TOPIC_0000001811610389__b13284144519206">Procedure</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="80.45%" id="mcps1.3.3.2.3.1.2"><p id="EN-US_TOPIC_0000001811610389__p2599131311261"><strong id="EN-US_TOPIC_0000001811610389__b1734994816204">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001811610389__row9599161311267"><td class="cellrowborder" valign="top" width="19.55%" headers="mcps1.3.3.2.3.1.1 "><p id="EN-US_TOPIC_0000001811610389__p759961312263">Load the driver.</p>
</td>
<td class="cellrowborder" valign="top" width="80.45%" headers="mcps1.3.3.2.3.1.2 "><p id="EN-US_TOPIC_0000001811610389__p25991138265">Download the JDBC driver and edit and load it in the program.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001811610389__row115991113122613"><td class="cellrowborder" valign="top" width="19.55%" headers="mcps1.3.3.2.3.1.1 "><p id="EN-US_TOPIC_0000001811610389__p1724122064118">Connect to a database.</p>
</td>
<td class="cellrowborder" valign="top" width="80.45%" headers="mcps1.3.3.2.3.1.2 "><p id="EN-US_TOPIC_0000001811610389__p185991813112620">Connect to the database through the JDBC driver.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001811610389__row659919137269"><td class="cellrowborder" valign="top" width="19.55%" headers="mcps1.3.3.2.3.1.1 "><p id="EN-US_TOPIC_0000001811610389__p859911320269">Execute SQL statements.</p>
</td>
<td class="cellrowborder" valign="top" width="80.45%" headers="mcps1.3.3.2.3.1.2 "><p id="EN-US_TOPIC_0000001811610389__p16599413112618">Applications operate database data by executing SQL statements.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001811610389__row759919134261"><td class="cellrowborder" valign="top" width="19.55%" headers="mcps1.3.3.2.3.1.1 "><p id="EN-US_TOPIC_0000001811610389__p1159911352612">Process the result set.</p>
</td>
<td class="cellrowborder" valign="top" width="80.45%" headers="mcps1.3.3.2.3.1.2 "><p id="EN-US_TOPIC_0000001811610389__p7599131352611">Different types of result sets have different application scenarios. Applications need to select the appropriate result set type as needed.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001811610389__row9599161311264"><td class="cellrowborder" valign="top" width="19.55%" headers="mcps1.3.3.2.3.1.1 "><p id="EN-US_TOPIC_0000001811610389__p559991312264">Close the connection.</p>
</td>
<td class="cellrowborder" valign="top" width="80.45%" headers="mcps1.3.3.2.3.1.2 "><p id="EN-US_TOPIC_0000001811610389__p20599913192614">Make sure to close the database connection after completing the required data operations.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0088.html">JDBC-Based Development</a></div>
</div>
</div>

View File

@ -1,13 +1,13 @@
<a name="EN-US_TOPIC_0000001510162777"></a><a name="EN-US_TOPIC_0000001510162777"></a>
<a name="EN-US_TOPIC_0000001811490569"></a><a name="EN-US_TOPIC_0000001811490569"></a>
<h1 class="topictitle1">JDBC Package and Driver Class</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001510162777__sbfa536a4d98e47b384c69d8cb91db388"><h4 class="sectiontitle">JDBC Package</h4><p id="EN-US_TOPIC_0000001510162777__p468121268"></p>
<p id="EN-US_TOPIC_0000001510162777__p278421418394"><span id="EN-US_TOPIC_0000001510162777__ph2258164483416">Download the <strong id="EN-US_TOPIC_0000001510162777__b1155013945018">dws_8.x.x_jdbc_driver.zip</strong> package from the console.</span></p>
<p id="EN-US_TOPIC_0000001510162777__en-us_topic_0000001099130898_p4451066501">For details, see "Downloading the JDBC or ODBC Driver" in the <em id="EN-US_TOPIC_0000001510162777__i180161971193226">Data Warehouse Service (DWS) User Guide</em>.</p>
<p id="EN-US_TOPIC_0000001510162777__p18962111516415">JDBC driver JAR package obtained from decompression:</p>
<p id="EN-US_TOPIC_0000001510162777__p51891491255"><strong id="EN-US_TOPIC_0000001510162777__b1584512420462">gsjdbc4.jar</strong>: Driver package compatible with PostgreSQL. The class name and class structure in the driver are the same as those in the PostgreSQL driver. All the applications running on PostgreSQL can be smoothly transferred to the current system.</p>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001811490569__sbfa536a4d98e47b384c69d8cb91db388"><h4 class="sectiontitle">JDBC Package</h4><p id="EN-US_TOPIC_0000001811490569__p12130172644620"></p>
<p id="EN-US_TOPIC_0000001811490569__p278421418394"><span id="EN-US_TOPIC_0000001811490569__ph2258164483416">Download the <strong id="EN-US_TOPIC_0000001811490569__b82301916162317">dws_8.x.x_jdbc_driver.zip</strong> software package from the console.</span></p>
<p id="EN-US_TOPIC_0000001811490569__en-us_topic_0000001099130898_p4451066501">For details, see "Downloading the JDBC or ODBC Driver" in the <em id="EN-US_TOPIC_0000001811490569__i107161147132313">Data Warehouse Service (DWS) User Guide</em>.</p>
<p id="EN-US_TOPIC_0000001811490569__p18962111516415">JDBC driver JAR package obtained from decompression:</p>
<p id="EN-US_TOPIC_0000001811490569__p51891491255"><strong id="EN-US_TOPIC_0000001811490569__b1584512420462">gsjdbc4.jar</strong>: Driver package compatible with PostgreSQL. The class name and class structure in the driver are the same as those in the PostgreSQL driver. All the applications running on PostgreSQL can be smoothly transferred to the current system.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001510162777__section19422124845610"><h4 class="sectiontitle">Driver Class</h4><p id="EN-US_TOPIC_0000001510162777__p242244825616">Before creating a database connection, you need to load the database driver class <strong id="EN-US_TOPIC_0000001510162777__b930465610479">org.postgresql.Driver</strong> (decompressed from <strong id="EN-US_TOPIC_0000001510162777__b9304155694717">gsjdbc4.jar</strong>).</p>
<div class="section" id="EN-US_TOPIC_0000001811490569__section19422124845610"><h4 class="sectiontitle">Driver Class</h4><p id="EN-US_TOPIC_0000001811490569__p242244825616">Before creating a database connection, you need to load the database driver class <strong id="EN-US_TOPIC_0000001811490569__b930465610479">org.postgresql.Driver</strong> (decompressed from <strong id="EN-US_TOPIC_0000001811490569__b9304155694717">gsjdbc4.jar</strong>).</p>
</div>
</div>
<div>

View File

@ -1,18 +0,0 @@
<a name="EN-US_TOPIC_0000001510163037"></a><a name="EN-US_TOPIC_0000001510163037"></a>
<h1 class="topictitle1">Development Process</h1>
<div id="body8662426"><div class="fignone" id="EN-US_TOPIC_0000001510163037__fcafbde07cfaa494ab49f20ae5bd84b7a"><span class="figcap"><b>Figure 1 </b>JDBC-based application development process</span><br><span><img id="EN-US_TOPIC_0000001510163037__i6a73e7281bc64638b280d20b489a02a6" src="figure/en-us_image_0000001460882996.png" height="489.77250000000004" width="114.7125" title="Click to enlarge" class="imgResize"></span></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0088.html">JDBC-Based Development</a></div>
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>

View File

@ -1,9 +1,9 @@
<a name="EN-US_TOPIC_0000001460882300"></a><a name="EN-US_TOPIC_0000001460882300"></a>
<a name="EN-US_TOPIC_0000001764650244"></a><a name="EN-US_TOPIC_0000001764650244"></a>
<h1 class="topictitle1">Loading a Driver</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001460882300__aad761dbdae3142a18755e96188b06794">Load the database driver before creating a database connection.</p>
<p id="EN-US_TOPIC_0000001460882300__ac499bb5780dd4eaeb2580d1011438f6b">You can load the driver in the following ways:</p>
<ul id="EN-US_TOPIC_0000001460882300__ubd790d2e5a5c43c192c02a1c1c2a9b71"><li id="EN-US_TOPIC_0000001460882300__l96db4ecf7bd9477cb3a0d3f76cf2a095">Implicitly loading the driver before creating a connection in the code: <strong id="EN-US_TOPIC_0000001460882300__b17355821013">Class.forName ("org.postgresql.Driver")</strong></li><li id="EN-US_TOPIC_0000001460882300__l1dd4ec6c9812458db1b7207604b27579">Transferring a parameter during the JVM startup: <strong id="EN-US_TOPIC_0000001460882300__b616316121518">java -Djdbc.drivers=org.postgresql.Driver jdbctest</strong></li></ul>
<div id="body8662426"><p id="EN-US_TOPIC_0000001764650244__aad761dbdae3142a18755e96188b06794">Load the database driver before creating a database connection.</p>
<p id="EN-US_TOPIC_0000001764650244__ac499bb5780dd4eaeb2580d1011438f6b">You can load the driver in the following ways:</p>
<ul id="EN-US_TOPIC_0000001764650244__ubd790d2e5a5c43c192c02a1c1c2a9b71"><li id="EN-US_TOPIC_0000001764650244__l96db4ecf7bd9477cb3a0d3f76cf2a095">Implicitly loading the driver before creating a connection in the code: <strong id="EN-US_TOPIC_0000001764650244__b17355821013">Class.forName ("org.postgresql.Driver")</strong></li><li id="EN-US_TOPIC_0000001764650244__l1dd4ec6c9812458db1b7207604b27579">Transferring a parameter during the JVM startup: <strong id="EN-US_TOPIC_0000001764650244__b616316121518">java -Djdbc.drivers=org.postgresql.Driver jdbctest</strong></li></ul>
</div>
<div>
<div class="familylinks">

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More