DWS DEV 20240716 version

Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
This commit is contained in:
Lu, Huayi 2024-11-02 09:07:47 +00:00 committed by zuul
parent 6aa966a79a
commit ef0ada5a59
1245 changed files with 64784 additions and 58992 deletions

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_0000001233761831"></a><a name="EN-US_TOPIC_0000001233761831"></a> <a name="EN-US_TOPIC_0000001764817397"></a><a name="EN-US_TOPIC_0000001764817397"></a>
<h1 class="topictitle1">Using DSC to Migrate SQL Scripts</h1> <h1 class="topictitle1">Using DSC to Migrate SQL Scripts</h1>
<div id="body8662426"><p id="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> <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_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> <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_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_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_ol868111584130"><li id="EN-US_TOPIC_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_li14681658161317"><span>Log in to the GaussDB(DWS) management console.</span></li><li id="EN-US_TOPIC_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1068220583130"><span>In the navigation tree on the left, click <span class="uicontrol" id="EN-US_TOPIC_0000001233761831__en-us_topic_0000001081821879_uicontrol1842851817810"><b>Connection Management</b></span>.</span></li><li id="EN-US_TOPIC_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_li1682145812134"><span>In the <span class="wintitle" id="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_0000001233761831__en-us_topic_0000001081821879_uicontrol1949551917818"><b>here</b></span> to download the DSC migration tool.</span><p><p id="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_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_0000001233761831__en-us_topic_0000001081821879_parmname1082042564"><b>Basic Information</b></span> tab to view the cluster version.</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_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_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_image1146921172210" src="figure/en-us_image_0000001188642272.png"></span></div> <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_0000001233761831__en-us_topic_0000001082831067_en-us_topic_0000001081821879_p15720203711118"></p> <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_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_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><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>
</p></li></ol> </p></li></ol>
</div> </div>
<div class="section" id="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_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_0000001233761831__i1968013441492">Data Warehouse Service Tool Guide</em>.</p> <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> </div>
</div> </div>
<div> <div>
@ -18,3 +18,10 @@
</div> </div>
</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,20 +0,0 @@
<a name="EN-US_TOPIC_0000001188642214"></a><a name="EN-US_TOPIC_0000001188642214"></a>
<h1 class="topictitle1">Target Readers</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188642214__en-us_topic_0088617413_p76943719112">This document is intended for database designers, application developers, and database administrators, and provides information required for designing, building, querying and maintaining data warehouses.</p>
<p id="EN-US_TOPIC_0000001188642214__en-us_topic_0088617413_p475043342615">As a database administrator or application developer, you need to be familiar with:</p>
<ul id="EN-US_TOPIC_0000001188642214__u7691c55cfe0541c89809a8115af66949"><li id="EN-US_TOPIC_0000001188642214__lc1b601053a1a458a8612e7051824dead">Knowledge about OSs, which is the basis for everything.</li><li id="EN-US_TOPIC_0000001188642214__l7397b98425d14b22b4a478ef883c0366">SQL syntax, which is the necessary skill for database operation.</li></ul>
<div class="section" id="EN-US_TOPIC_0000001188642214__sfd0735c1ae3146aea494112583a06f13"><h4 class="sectiontitle">Statement</h4><p id="EN-US_TOPIC_0000001188642214__a7fa7fab65b2145be9e9625ff874a16dc">When writing documents, the writers of <span id="EN-US_TOPIC_0000001188642214__text33426438492">GaussDB(DWS)</span> try their best to provide guidance from the perspective of commercial use, application scenarios, and task completion. Even so, references to PostgreSQL content may still exist in the document. For this type of content, the following PostgreSQL Copyright is applicable:</p>
<p id="EN-US_TOPIC_0000001188642214__af05ef527ea2e4d9ea88935c4f4dec964">Postgres-XC is Copyright &copy; 1996-2013 by the PostgreSQL Global Development Group.</p>
<p id="EN-US_TOPIC_0000001188642214__a18917fc228ec43ba8cfceb4e3751dff7">PostgreSQL is Copyright &copy; 1996-2013 by the PostgreSQL Global Development Group.</p>
<p id="EN-US_TOPIC_0000001188642214__en-us_topic_0088617413_p145955232323">Postgres95 is Copyright &copy; 1994-5 by the Regents of the University of California.</p>
<p id="EN-US_TOPIC_0000001188642214__a59df8aed2b0f4dbe9817856ee8c1288b">IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
<p id="EN-US_TOPIC_0000001188642214__en-us_topic_0088617413_p145951236322">THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS-IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0001.html">Welcome</a></div>
</div>
</div>

View File

@ -1,57 +0,0 @@
<a name="EN-US_TOPIC_0000001188163728"></a><a name="EN-US_TOPIC_0000001188163728"></a>
<h1 class="topictitle1">Reading Guide</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p119421276243">If you are a new GaussDB(DWS) user, you are advised to read the following contents first:</p>
<ul id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_ul139423717245"><li id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_li3156143819234">Sections describing the features, functions, and application scenarios of GaussDB(DWS).</li><li id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_li1094219718241">"Getting Started": guides you through creating a data warehouse cluster, creating a database table, uploading data, and testing queries.</li></ul>
<p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p0345056487">If you intend to or are migrating applications from other data warehouses to GaussDB(DWS), you might want to know how GaussDB(DWS) differs from them.</p>
<p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p10942107112415">You can find useful information from the following table for GaussDB(DWS) database application development.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_table16151205121211" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row17549145161217"><th align="left" class="cellrowborder" valign="top" width="24%" id="mcps1.3.5.1.3.1.1"><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p20549185117125"><strong id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_b842352706192044">If you want to...</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="76%" id="mcps1.3.5.1.3.1.2"><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p65491751101210"><strong id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_b842352706192052">Query Suggestions</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row7549205111219"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p12549151201213">Quickly get started with GaussDB(DWS).</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p105091621112310">Deploy a cluster, connect to the database, and perform some queries by following the instructions provided in <span id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_ph1737544541218">"Getting Started" in the <em id="EN-US_TOPIC_0000001188163728__i17228514154417">Data Warehouse Service (DWS) User Guide</em></span>.</p>
<p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p85501351171216">When you are ready to construct a database, load data to tables and compile the query content to operate the data in the data warehouse. Then, you can return to the <em id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_i9533458173417">Data Warehouse Service Database Developer Guide</em>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row3550165121211"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p175501351191218">Understand the internal architecture of a GaussDB(DWS) data warehouse.</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p555155113127"><span id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_ph45461726010">To know more about GaussDB(DWS), go to the GaussDB(DWS) home page.</span></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row1255315113125"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p1755310518126">Learn how to design tables to achieve the excellent performance.</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p13654111934611"><a href="dws_04_0074.html">Development and Design Proposal</a> introduces the design specifications that should be complied with during the development of database applications. Modeling compliant with these specifications fits the distributed processing architecture of GaussDB(DWS) and provides efficient SQL code.</p>
<p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p1455345117122">To facilitate service execution through optimization, you can refer to <a href="dws_04_0400.html">Performance Tuning</a>. Successful performance optimization depends more on database administrators' experience and judgment than on instructions and explanation. However, <a href="dws_04_0400.html">Performance Tuning</a> still tries to systematically illustrate the performance optimization methods for application development personnel and new GaussDB(DWS) database administrators.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row175551251161211"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p6555115111217">Load data.</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p20378116113412"><a href="dws_04_0179.html">Importing Data</a> describes how to import data to GaussDB(DWS).</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row355910512126"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p955914513126">Manage users, groups, and database security.</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p8559105118127"><a href="dws_04_0043.html">Database Security Management</a> covers database security topics.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_row45594511129"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.3.5.1.3.1.1 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p18559145110127">Monitor and optimize system performance.</p>
</td>
<td class="cellrowborder" valign="top" width="76%" headers="mcps1.3.5.1.3.1.2 "><p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p256014516125"><a href="dws_04_0559.html">System Catalogs and System Views</a> describes the system catalogs where you can query the database status and monitor the query content and process.</p>
<p id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_p155601551151210">You can learn how to check the system running status and monitoring metrics on the GaussDB(DWS) console by referring to <span id="EN-US_TOPIC_0000001188163728__en-us_topic_0000001083105849_ph1969811553139">"Monitoring Clusters" in the <em id="EN-US_TOPIC_0000001188163728__i1824418325215">Data Warehouse Service (DWS) User Guide</em>.</span></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0001.html">Welcome</a></div>
</div>
</div>

View File

@ -1,13 +0,0 @@
<a name="EN-US_TOPIC_0000001188323610"></a><a name="EN-US_TOPIC_0000001188323610"></a>
<h1 class="topictitle1">Prerequisites</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188323610__en-us_topic_0000001098651172_en-us_topic_0100008559_p13124746151715">Complete the following tasks before you perform operations described in this document:</p>
<ul id="EN-US_TOPIC_0000001188323610__en-us_topic_0000001098651172_en-us_topic_0100008559_ul1012464615174"><li id="EN-US_TOPIC_0000001188323610__en-us_topic_0000001098651172_li12527112919326">Create a GaussDB(DWS) cluster.</li><li id="EN-US_TOPIC_0000001188323610__en-us_topic_0000001098651172_en-us_topic_0100008559_li15124124631711">Install an SQL client.</li><li id="EN-US_TOPIC_0000001188323610__en-us_topic_0000001098651172_en-us_topic_0100008559_li17124164618170">Connect the SQL client to the default database of the cluster.</li></ul>
<p id="EN-US_TOPIC_0000001188323610__p1613844418349">For details about how to perform the preceding tasks, see <span id="EN-US_TOPIC_0000001188323610__ph158502045123416">"Getting Started" in the <em id="EN-US_TOPIC_0000001188323610__i860511508525">Data Warehouse Service (DWS) User Guide</em></span>.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0001.html">Welcome</a></div>
</div>
</div>

View File

@ -1,16 +0,0 @@
<a name="EN-US_TOPIC_0000001233563145"></a><a name="EN-US_TOPIC_0000001233563145"></a>
<h1 class="topictitle1">System Overview</h1>
<div id="body1494317364745"><p id="EN-US_TOPIC_0000001233563145__en-us_topic_0059777588_p8060118"></p>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0011.html">Highly Reliable Transaction Processing</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0012.html">High Query Performance</a></strong><br>
</li>
<li class="ulchildlink"><strong><a href="dws_04_0015.html">Related Concepts</a></strong><br>
</li>
</ul>
</div>

View File

@ -1,16 +0,0 @@
<a name="EN-US_TOPIC_0000001233681645"></a><a name="EN-US_TOPIC_0000001233681645"></a>
<h1 class="topictitle1">Highly Reliable Transaction Processing</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_en-us_topic_0059777480_p18508125215341">GaussDB(DWS) manages cluster transactions, the basis of HA and failovers. This ensures speedy fault recovery, guarantees the Atomicity, Consistency, Isolation, Durability (ACID) properties for transactions and after a recovery, and enables concurrent control.</p>
<p id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_p5441259201918"><strong id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_b199541448264">Fault Rectification</strong></p>
<p id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_p4937102391917">GaussDB(DWS) provides an HA mechanism to reduce the service interruption time when a cluster is faulty. It protects key user programs to continuously provide external services, minimizing the impact of hardware, software, and human faults on services and ensuring service continuity.</p>
<ul id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_ul440554114403"><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li12175320103418">Hardware HA: Disk RAID, switch stacking, NIC bond, and uninterruptible power supply (UPS)</li><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li6315165625313">Software HA: HA mechanism used for instances in the GaussDB(DWS) cluster, such as CNs, GTMs, and DNs)</li></ul>
<p id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_p184255367819"><strong id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_b3425193617810">Transaction Management</strong></p>
<ul id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_ul134255361888"><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li64258366818">Transaction blocks are supported. You can run <strong id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_b16161854103419">start transaction</strong> to make the startup of a transaction block explicit.</li><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li94251636187">Single-statement transactions are supported. If you do not explicitly start a transaction, a single statement is processed as a transaction.</li><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li64257362813">Distributed transaction management and global transaction information management are supported. This includes gxid, snapshot, timestamp management, distributed transaction status management, and gxid overflow processing.</li><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li94250366810">Distributed transactions have ACID properties.</li><li id="EN-US_TOPIC_0000001233681645__en-us_topic_0000001098971038_li104253361985">Deadlocks are prevented in the distributed system. A transaction will be unlocked immediately after a deadlock (if any).</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0007.html">System Overview</a></div>
</div>
</div>

View File

@ -1,20 +0,0 @@
<a name="EN-US_TOPIC_0000001233883341"></a><a name="EN-US_TOPIC_0000001233883341"></a>
<h1 class="topictitle1">High Query Performance</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_p17990103921210">The following <span id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_ph1692512422530">GaussDB(DWS)</span> features help achieve high query performance.</p>
<div class="section" id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_section15932442508"><h4 class="sectiontitle">Fully Parallel Query</h4><p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_p5165941205614">GaussDB(DWS) is an MPP system with the shared-nothing architecture. It consists of multiple independent logical nodes that do not share system resources, such as the CPU, memory, and storage units. In such a system architecture, service data is separately stored on numerous nodes. Data analysis tasks are executed in parallel on the nodes where data is stored. The massively parallel data processing significantly improves response speed.</p>
<p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_p14997175420585">In addition, GaussDB(DWS) improves data query performance by executing operators in parallel, executing commands in registers in parallel, and using LLVM to dynamically compile the logical conditions of redundancy prune.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_section88161057145419"><h4 class="sectiontitle">Hybrid Row-Column Storage</h4><p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_en-us_topic_0059777898_a30aa33ed6061451c8ed22c26bbe46d34"><span id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_ph196814173531">GaussDB(DWS)</span> supports both the row and column storage models. You can choose a row- or column-store table as needed.</p>
<p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_en-us_topic_0059777898_a60c95b61dafb4694913a80d682e31916">The hybrid row-column storage engine achieves higher data compression ratio (column storage), index performance (column storage), and point update and point query (row storage) performance.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_section12425115163819"><h4 class="sectiontitle">Data Compression in Column Storage</h4><p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_en-us_topic_0085033179_p1050313019230">You can compress old, inactive data to free up space, reducing procurement and O&amp;M costs.</p>
<p id="EN-US_TOPIC_0000001233883341__en-us_topic_0000001145651105_en-us_topic_0085033179_p9503123015234">In GaussDB(DWS), data can be compressed using the Delta Value Encoding, Dictionary, RLE, LZ4, and ZLIB algorithms. The system automatically selects a compression algorithm based on data characteristics. The average compression ratio is 7:1. Compressed data can be directly accessed and is transparent to services, greatly reducing the preparation time before accessing historical data.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0007.html">System Overview</a></div>
</div>
</div>

View File

@ -1,22 +0,0 @@
<a name="EN-US_TOPIC_0000001233563241"></a><a name="EN-US_TOPIC_0000001233563241"></a>
<h1 class="topictitle1">Related Concepts</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001233563241__s8eeb92bbb2c9474abec3131c2a3de9be"><h4 class="sectiontitle">Database</h4><p id="EN-US_TOPIC_0000001233563241__a0d56a1d8a499429ab5d27ebc7f8e169b">A database manages data objects and is isolated from other databases. While creating an object, you can specify a tablespace for it. If you do not specify it, the object will be saved to the <strong id="EN-US_TOPIC_0000001233563241__b842352706142447">PG_DEFAULT</strong> space by default. Objects managed by a database can be distributed to multiple tablespaces.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563241__en-us_topic_0093464731_en-us_topic_0059779238_s174b82ec22a94e478b49737f0bced1ac"><h4 class="sectiontitle">Instance</h4><p id="EN-US_TOPIC_0000001233563241__en-us_topic_0093464731_en-us_topic_0059779238_ad9aa75e070294dada1bb1426c733ac00">In <span id="EN-US_TOPIC_0000001233563241__ph165411332142716">GaussDB(DWS)</span>, instances are a group of database processes running in the memory. An instance can manage one or more databases that form a cluster. A cluster is an area in the storage disk. This area is initialized during installation and composed of a directory. The directory, called data directory, stores all data and is created by <strong id="EN-US_TOPIC_0000001233563241__b20745131862814">initdb</strong>. Theoretically, one server can start multiple instances on different ports, but <span id="EN-US_TOPIC_0000001233563241__ph159118115292">GaussDB(DWS)</span> manages only one instance at a time. The start and stop of an instance rely on the specific data directory. For compatibility purposes, the concept of instance name may be introduced.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563241__sd02a43df183c4a5ebb95eb554ab910a9"><h4 class="sectiontitle">Tablespaces</h4><p id="EN-US_TOPIC_0000001233563241__a906223c1bcdb4005a529ff2b5401002d">In <span id="EN-US_TOPIC_0000001233563241__text1998133972">GaussDB(DWS)</span>, a tablespace is a directory storing physical files of the databases the tablespace contains. Multiple tablespaces can coexist. Files are physically isolated using tablespaces and managed by a file system.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563241__s9d3f5dfcecdf4bad99e5f9a2688e21a5"><h4 class="sectiontitle">schema</h4><p id="EN-US_TOPIC_0000001233563241__a2d20c90fc0fe4ac5bc82f0009668ab60"><span id="EN-US_TOPIC_0000001233563241__text169550254">GaussDB(DWS)</span> schemas logically separate databases. All database objects are created under certain schemas. In <span id="EN-US_TOPIC_0000001233563241__text1332219925">GaussDB(DWS)</span>, schemas and users are loosely bound. When you create a user, a schema with the same name as the user will be created automatically. You can also create a schema or specify another schema.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563241__s6b1917ec12c249d59233c11959b6db79"><h4 class="sectiontitle">User and Role</h4><p id="EN-US_TOPIC_0000001233563241__a400f976a3ed34940b5a45614ea2d4d60"><span id="EN-US_TOPIC_0000001233563241__text1828369993">GaussDB(DWS)</span> uses users and roles to control the access to databases. A role can be a database user or a group of database users, depending on role settings. In <span id="EN-US_TOPIC_0000001233563241__text1349326921">GaussDB(DWS)</span>, the difference between roles and users is that a role does not have the LOGIN permission by default. In <span id="EN-US_TOPIC_0000001233563241__text693192024">GaussDB(DWS)</span>, one user can have only one role, but you can put a user's role under a parent role to grant multiple permissions to the user.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563241__s8302eda03d7b4255af235930410f3559"><h4 class="sectiontitle">Transaction Management</h4><p id="EN-US_TOPIC_0000001233563241__a0f7ae2dbc4e64f178f15d7721221bc08">In <span id="EN-US_TOPIC_0000001233563241__text484000412">GaussDB(DWS)</span>, transactions are managed by multi-version concurrency control (MVCC) and two-phase locking (2PL). It enables smooth data reads and writes. In <span id="EN-US_TOPIC_0000001233563241__text674838628">GaussDB(DWS)</span>, MVCC saves historical version data together with the current tuple version. <span id="EN-US_TOPIC_0000001233563241__text796230309">GaussDB(DWS)</span> uses the VACUUM process instead of rollback segments to routinely delete historical version data. Unless in performance optimization, you do not need to pay attention to the VACUUM process. Transactions are automatically submitted in <span id="EN-US_TOPIC_0000001233563241__text1176679149">GaussDB(DWS)</span>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0007.html">System Overview</a></div>
</div>
</div>

View File

@ -1,7 +1,7 @@
<a name="EN-US_TOPIC_0000001233761859"></a><a name="EN-US_TOPIC_0000001233761859"></a> <a name="EN-US_TOPIC_0000001510163029"></a><a name="EN-US_TOPIC_0000001510163029"></a>
<h1 class="topictitle1">Defining Database Objects</h1> <h1 class="topictitle1">Defining Database Objects</h1>
<div id="body1494317364745"><p id="EN-US_TOPIC_0000001233761859__en-us_topic_0059778336_p8060118"></p> <div id="body8662426"><p id="EN-US_TOPIC_0000001510163029__en-us_topic_0000001233761859_en-us_topic_0059778336_p8060118"></p>
</div> </div>
<div> <div>
<ul class="ullinks"> <ul class="ullinks">

View File

@ -1,45 +1,39 @@
<a name="EN-US_TOPIC_0000001188323600"></a><a name="EN-US_TOPIC_0000001188323600"></a> <a name="EN-US_TOPIC_0000001460562756"></a><a name="EN-US_TOPIC_0000001460562756"></a>
<h1 class="topictitle1">Creating and Managing Databases</h1> <h1 class="topictitle1">Creating and Managing Databases</h1>
<div id="body8662426"><p id="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 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_0000001188323600__section122544389266"><h4 class="sectiontitle">Template and Default Databases</h4><ul id="EN-US_TOPIC_0000001188323600__ul967143111312"><li id="EN-US_TOPIC_0000001188323600__li1467163131318">GaussDB (DWS) provides two template databases <strong id="EN-US_TOPIC_0000001188323600__b162801117153210">template0</strong> and <strong id="EN-US_TOPIC_0000001188323600__b1951392133215">template1</strong> and a default database <span id="EN-US_TOPIC_0000001188323600__text1462184614508">gaussdb</span>.</li><li id="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_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_0000001188323600__b538912818381">template0</strong> to create the database.</li><li id="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_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_0000001188323600__p140117143366">You can run the <strong id="EN-US_TOPIC_0000001188323600__b69417832541155">show server_encoding</strong> command to view the current database encoding.</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>
</div></div> </div></div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323600__section17897114011280"><h4 class="sectiontitle">Creating a Database.</h4><p id="EN-US_TOPIC_0000001188323600__p1668754282810">Run the <strong id="EN-US_TOPIC_0000001188323600__b787319574112">CREATE DATABASE</strong> statement to create a database.</p> <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_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="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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
<div class="note" id="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_0000001188323600__en-us_topic_0000001083024525_en-us_topic_0093152895_en-us_topic_0059779126_u26fc21318fdc40be947784c5bb32d12e"><li id="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_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_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_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_0000001188323600__li62226497411">A maximum of 128 databases can be created in GaussDB(DWS).</li><li id="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_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></div> </div></div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323600__section463533692716"><h4 class="sectiontitle">Viewing Databases</h4><div class="p" id="EN-US_TOPIC_0000001188323600__p1318563110321">To view databases, perform the following steps:<ul id="EN-US_TOPIC_0000001188323600__ul2037492910324"><li id="EN-US_TOPIC_0000001188323600__li1537514296324">Run the <strong id="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_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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188323600__li123751029193212">Querying the database list using the <strong id="EN-US_TOPIC_0000001188323600__b6289120103110">pg_database</strong> system catalog<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323600__section1548916712337"><h4 class="sectiontitle">Modifying a Database</h4><p id="EN-US_TOPIC_0000001188323600__p2010818293414">You can use the <strong id="EN-US_TOPIC_0000001188323600__b66291032302">ALTER DATABASE</strong> statement modify database configuration such as the database owner, name, and default settings.</p> <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_0000001188323600__ul1110892918418"><li id="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_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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188323600__li15111529124112">Rename the database.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323600__section025425719419"><h4 class="sectiontitle">Deleting a Database</h4><p id="EN-US_TOPIC_0000001188323600__p29356392422">You can run <strong id="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="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_0000001188323600__p10381143414217">Run the <strong id="EN-US_TOPIC_0000001188323600__b18151515143112">DROP DATABASE</strong> statement to delete a database:<div class="codecoloring" codetype="Sql" id="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="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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </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

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,28 +1,24 @@
<a name="EN-US_TOPIC_0000001188323660"></a><a name="EN-US_TOPIC_0000001188323660"></a> <a name="EN-US_TOPIC_0000001510402221"></a><a name="EN-US_TOPIC_0000001510402221"></a>
<h1 class="topictitle1">Creating and Managing Views</h1> <h1 class="topictitle1">Creating and Managing Views</h1>
<div id="body8662426"><p id="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 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_0000001188323660__se07db171a2b64c3fb143727491321a84"><h4 class="sectiontitle">Creating a view</h4><div class="p" id="EN-US_TOPIC_0000001188323660__p5748154345117">Run the <strong id="EN-US_TOPIC_0000001188323660__b3388382103">CREATE VIEW</strong> command to create a view.<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
<div class="note" id="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_0000001188323660__p177509433510">The <strong id="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_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></div> </div></div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323660__section58811612145614"><h4 class="sectiontitle">View Details</h4><ul id="EN-US_TOPIC_0000001188323660__ul1935918240561"><li id="EN-US_TOPIC_0000001188323660__ld156225587b74e3b87897058f1c64c01">View the <em id="EN-US_TOPIC_0000001188323660__i1940751652314">MyView</em> view. Real-time data will be returned.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="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_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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188323660__l11ca417ba0314592b8addcf7aceae216">Run the following command to query all views:<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188323660__l9c0976676c1f42e298a5839b786156cd">View details about a specified view.<div class="p" id="EN-US_TOPIC_0000001188323660__af4c6848c60274f1fb2826ab5ac0a1839"><a name="EN-US_TOPIC_0000001188323660__l9c0976676c1f42e298a5839b786156cd"></a><a name="l9c0976676c1f42e298a5839b786156cd"></a>Run the following command to view details about the dba_users view:<div class="codecoloring" codetype="Sql" id="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_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>
<span class="normal">2</span> <span class="normal">2</span>
<span class="normal">3</span> <span class="normal">3</span>
<span class="normal">4</span> <span class="normal">4</span>
@ -38,23 +34,20 @@
<span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="n">PG_AUTHID</span><span class="p">.</span><span class="n">ROLNAME</span><span class="p">::</span><span class="nb">CHARACTER</span><span class="w"> </span><span class="nb">VARYING</span><span class="p">(</span><span class="mi">64</span><span class="p">)</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="n">USERNAME</span> <span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="n">PG_AUTHID</span><span class="p">.</span><span class="n">ROLNAME</span><span class="p">::</span><span class="nb">CHARACTER</span><span class="w"> </span><span class="nb">VARYING</span><span class="p">(</span><span class="mi">64</span><span class="p">)</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="n">USERNAME</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><span class="k">FROM</span><span class="w"> </span><span class="n">PG_AUTHID</span><span class="p">;</span>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323660__section45851157145414"><h4 class="sectiontitle">Rebuilding a View</h4><p id="EN-US_TOPIC_0000001188323660__p183837313551">Run the <strong id="EN-US_TOPIC_0000001188323660__b43816219174">ALTER VIEW</strong> command to rebuild a view without entering query statements.</p> <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_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="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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188323660__section15139145913534"><h4 class="sectiontitle">Deleting a View</h4><div class="p" id="EN-US_TOPIC_0000001188323660__p1118103719543">Run the <strong id="EN-US_TOPIC_0000001188323660__b1020032241919">DROP VIEW</strong> command to delete a view.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
<p id="EN-US_TOPIC_0000001188323660__p18486161614592">DROP VIEW ... The <strong id="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_0000001188323660__b31880972115">DROP VIEW</strong> command will fail.</p> <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>
</div> </div>
</div> </div>
<div> <div>

View File

@ -1,10 +1,10 @@
<a name="EN-US_TOPIC_0000001233883175"></a><a name="EN-US_TOPIC_0000001233883175"></a> <a name="EN-US_TOPIC_0000001510283769"></a><a name="EN-US_TOPIC_0000001510283769"></a>
<h1 class="topictitle1">Creating and Using Sequences</h1> <h1 class="topictitle1">Creating and Using Sequences</h1>
<div id="body1498525234177"><p id="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 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_0000001233883175__p510074455414">You can create a sequence for a column in either of the following methods:<ul id="EN-US_TOPIC_0000001233883175__ul9475346173310"><li id="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_0000001233883175__li15475446203315">Use <strong id="EN-US_TOPIC_0000001233883175__b17633613419">CREATE SEQUENCE</strong> to create a new sequenc. Use the <strong id="EN-US_TOPIC_0000001233883175__b1899031717362">nextval('</strong><em id="EN-US_TOPIC_0000001233883175__i4253142493620">sequence_name</em><strong id="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_0000001233883175__b161655119375">nextval('</strong>sequence_name<strong id="EN-US_TOPIC_0000001233883175__b1536123193710">')</strong> function. In this way, this column can be used as a unique identifier.</li></ul> <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>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233883175__sa82c57fda672457ea8c6fa934915ba5c"><h4 class="sectiontitle">Creating a Sequence.</h4><div class="p" id="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_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_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>
<span class="normal">2</span> <span class="normal">2</span>
<span class="normal">3</span> <span class="normal">3</span>
<span class="normal">4</span> <span class="normal">4</span>
@ -14,15 +14,13 @@
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span> <span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span>
<span class="p">);</span> <span class="p">);</span>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
<p id="EN-US_TOPIC_0000001233883175__a6e8080438eb2433ea9ea9606b5e8c92e">Method 2: Create a sequence and set the initial value of the <strong id="EN-US_TOPIC_0000001233883175__b17032018804161">nextval</strong>('<em id="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> <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_0000001233883175__ol128283377453"><li id="EN-US_TOPIC_0000001233883175__li208281037164517">Create a sequence.<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233883175__li15580165544516">Set the initial value of the <strong id="EN-US_TOPIC_0000001233883175__b96682320327">nextval</strong>('<em id="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_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_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>
<span class="normal">2</span> <span class="normal">2</span>
<span class="normal">3</span> <span class="normal">3</span>
<span class="normal">4</span> <span class="normal">4</span>
@ -32,33 +30,29 @@
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span> <span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">text</span>
<span class="p">);</span> <span class="p">);</span>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ol> </li></ol>
<div class="note" id="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_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> <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_0000001233883175__a712093feed8c415bb59590d3b9dffc0f">Currently, the preceding two methods cannot be used for existing tables.</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></div> </div></div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233883175__section273144710268"><h4 class="sectiontitle">Modifying a Sequence</h4><p id="EN-US_TOPIC_0000001233883175__p17243185212263">The <strong id="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> <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_0000001233883175__ul1281573592820"><li id="EN-US_TOPIC_0000001233883175__li2815173516286">Associate the sequence with a column.<p id="EN-US_TOPIC_0000001233883175__p7259193612381"><a name="EN-US_TOPIC_0000001233883175__li2815173516286"></a><a name="li2815173516286"></a>The sequence will be deleted when you delete the column or the table where the column resides.</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_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="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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233883175__li716964462815">Modify the maximum value of <strong id="EN-US_TOPIC_0000001233883175__b20931699594161">serial</strong> to <strong id="EN-US_TOPIC_0000001233883175__b7295424924161">300</strong>.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233883175__section148219245186"><h4 class="sectiontitle">Deleting a Sequence</h4><p id="EN-US_TOPIC_0000001233883175__p2142184591812">Run the <strong id="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_0000001233883175__b1479516496818">seq1</strong>, run the following command:</p> <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_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="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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233883175__s100b6d4658154113becab048fd2be2e2"><h4 class="sectiontitle">Precautions</h4><p id="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_0000001233883175__b4982598334161">INSERT FROM SELECT</strong> statement has poor performance in the following scenario:</p> <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_0000001233883175__s9a3a6763887b4f3d8ced3cb3bbe13fe7"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span> <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>
<span class="normal">2</span> <span class="normal">2</span>
<span class="normal">3</span> <span class="normal">3</span>
<span class="normal">4</span> <span class="normal">4</span>
@ -72,19 +66,17 @@
<span class="w"> </span><span class="p">);</span> <span class="w"> </span><span class="p">);</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">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> <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> </pre></div></td></tr></table></div>
</div> </div>
<p id="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_0000001233883175__i2561207904161">T1</em> to <em id="EN-US_TOPIC_0000001233883175__i3796884644161">newT1</em>):</p> <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_0000001233883175__s8dbe067a7f0e4b47b3012e9afd34e403"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span> <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>
<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="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> <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> </pre></div></td></tr></table></div>
</div> </div>
<div class="note" id="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_0000001233883175__ad47cc27e4a0a4a50b54b0b2cc52a021f">Rollback is not supported by sequence functions, including <strong id="EN-US_TOPIC_0000001233883175__b1438019201391">nextval()</strong> and <strong id="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_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></div> </div></div>
<p id="EN-US_TOPIC_0000001233883175__a63d1fabfa19e48b8a851454b0e0b1ea2">If BulkLoad is used, set sufficient cache for <em id="EN-US_TOPIC_0000001233883175__i203932248013">newSeq1</em> and do not set <strong id="EN-US_TOPIC_0000001233883175__b134320561707">Maxvalue</strong> or <strong id="EN-US_TOPIC_0000001233883175__b143615310112">Minvalue</strong>. To improve the performance, database may push down the invocation of <strong id="EN-US_TOPIC_0000001233883175__b139991101526">nextval</strong>('<em id="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_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_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_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_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_0000001233883175__b197180393312620">setval</strong>.</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>
</div> </div>
</div> </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,13 +1,16 @@
<a name="EN-US_TOPIC_0000001233883333"></a><a name="EN-US_TOPIC_0000001233883333"></a> <a name="EN-US_TOPIC_0000001510522401"></a><a name="EN-US_TOPIC_0000001510522401"></a>
<h1 class="topictitle1">Database Security Management</h1>
<div id="body1494318882616"><p id="EN-US_TOPIC_0000001233883333__en-us_topic_0059778204_p8060118"></p> <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> </div>
<div> <div>
<ul class="ullinks"> <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">Managing Users and Their Permissions</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0994.html">Sensitive Data Management</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0994.html">GaussDB(DWS) Sensitive Data Management</a></strong><br>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -1,4 +1,4 @@
<a name="EN-US_TOPIC_0000001233681671"></a><a name="EN-US_TOPIC_0000001233681671"></a> <a name="EN-US_TOPIC_0000001480181366"></a><a name="EN-US_TOPIC_0000001480181366"></a>
<h1 class="topictitle1">Managing Users and Their Permissions</h1> <h1 class="topictitle1">Managing Users and Their Permissions</h1>
<div id="body8662426"></div> <div id="body8662426"></div>
@ -17,7 +17,7 @@
</ul> </ul>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0043.html">Database Security Management</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0043.html">GaussDB(DWS) Database Security Management</a></div>
</div> </div>
</div> </div>

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
<a name="EN-US_TOPIC_0000001188323750"></a><a name="EN-US_TOPIC_0000001188323750"></a> <a name="EN-US_TOPIC_0000001531181593"></a><a name="EN-US_TOPIC_0000001531181593"></a>
<h1 class="topictitle1">Database Users</h1> <h1 class="topictitle1">Database Users</h1>
<div id="body8662426"><p id="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">Separation of Permissions</a>.</p> <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_0000001188323750__ul1868561754819"><li id="EN-US_TOPIC_0000001188323750__li968617177487">The administrator can manage all common users and databases.</li><li id="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> <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_0000001188323750__p81191305346">Users are authenticated when they log in to the <span id="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_0000001188323750__b50960243011512">CREATEDB</strong> attribute can create databases and grant permissions to these databases.</p> <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_0000001188323750__section6579918144510"><h4 class="sectiontitle">Database User Types</h4> <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_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_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_0000001188323750__p195942514179">User Type</p> <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>
</th> </th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.2"><p id="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_0000001531181593__en-us_topic_0000001188323750_p1117103952910">Description</p>
</th> </th>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.3"><p id="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_0000001531181593__en-us_topic_0000001188323750_p8594185111719">Allowed Operations</p>
</th> </th>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.2.5.1.4"><p id="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_0000001531181593__en-us_topic_0000001188323750_p47771456153619">How to Create</p>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody><tr id="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_0000001188323750__p17594115191710">Administrator <strong id="EN-US_TOPIC_0000001188323750__b13783125852518">dbadmin</strong></p> <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>
</td> </td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001188323750__p269073052517">An administrator, also called a system administrator, is an account with the <strong id="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_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> </td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><p id="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_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> </td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><ul id="EN-US_TOPIC_0000001188323750__ul131441459202914"><li id="EN-US_TOPIC_0000001188323750__li166343714309">User <strong id="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_0000001188323750__li7145125922912">Use the <strong id="EN-US_TOPIC_0000001188323750__b1719124812274">CREATE USER</strong> or <strong id="EN-US_TOPIC_0000001188323750__b17456205018273">ALTER USER</strong> syntax to create an administrator.<pre class="screen" id="EN-US_TOPIC_0000001188323750__screen4761145817259">CREATE USER <em id="EN-US_TOPIC_0000001188323750__i276173315223">sysadmin</em> WITH SYSADMIN password '<em id="EN-US_TOPIC_0000001188323750__i1996392214229">{Password}</em>';</pre> <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_0000001188323750__screen13261582272">ALTER USER <em id="EN-US_TOPIC_0000001188323750__i984410118232">u1</em> SYSADMIN;</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>
</li></ul> </li></ul>
</td> </td>
</tr> </tr>
<tr id="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_0000001188323750__p14595105161717">Common user</p> <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_0000001188323750__p252715354720"></p> <p id="EN-US_TOPIC_0000001531181593__en-us_topic_0000001188323750_p252715354720"></p>
</td> </td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="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_0000001531181593__en-us_topic_0000001188323750_p15951358173">Common user</p>
</td> </td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.3 "><ul id="EN-US_TOPIC_0000001188323750__ul89611910203412"><li id="EN-US_TOPIC_0000001188323750__li79612101346">Use a tool to connect to the database.</li><li id="EN-US_TOPIC_0000001188323750__li12962161018343">Have the attributes of specific database system operations, such as <strong id="EN-US_TOPIC_0000001188323750__b104293028181852">CREATEDB</strong>, <strong id="EN-US_TOPIC_0000001188323750__b42385387881852">CREATEROLE</strong>, and <strong id="EN-US_TOPIC_0000001188323750__b50948786081852">SYSADMIN</strong>.</li><li id="EN-US_TOPIC_0000001188323750__li1296213107340">Access database objects.</li><li id="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_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> </td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001188323750__p677765611364">Run the <strong id="EN-US_TOPIC_0000001188323750__b20486135515299">CREATE USER</strong> syntax to create a common user.</p> <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_0000001188323750__screen191761133172618">CREATE USER <em id="EN-US_TOPIC_0000001188323750__i53382048174113">u1</em> PASSWORD '<em id="EN-US_TOPIC_0000001188323750__i36631725181012">{Password}</em>';</pre> <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> </td>
</tr> </tr>
<tr id="EN-US_TOPIC_0000001188323750__row4526113194710"><td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001188323750__p0409347152715">Private user</p> <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>
</td> </td>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001188323750__p291652416506">A user created with the <strong id="EN-US_TOPIC_0000001188323750__b23721642311512">INDEPENDENT</strong> attribute in non-separation-of-permissions mode.</p> <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_0000001188323750__p11108114315012">Database administrators can manage (<strong id="EN-US_TOPIC_0000001188323750__b205609301211512">DROP</strong>, <strong id="EN-US_TOPIC_0000001188323750__b212561601811512">ALTER</strong>, and <strong id="EN-US_TOPIC_0000001188323750__b191003805911512">TRUNCATE</strong>) objects of private users but cannot access (<strong id="EN-US_TOPIC_0000001188323750__b32776326711512">INSERT</strong>, <strong id="EN-US_TOPIC_0000001188323750__b4193836311512">DELETE</strong>, <strong id="EN-US_TOPIC_0000001188323750__b184949162111512">SELECT</strong>, <strong id="EN-US_TOPIC_0000001188323750__b150389627111512">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001188323750__b1423971711512">COPY</strong>, <strong id="EN-US_TOPIC_0000001188323750__b210071563211512">GRANT</strong>, <strong id="EN-US_TOPIC_0000001188323750__b207253897111512">REVOKE</strong>, and <strong id="EN-US_TOPIC_0000001188323750__b107328697511512">ALTER OWNER</strong>) the objects before being authorized.</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> </td>
<td class="cellrowborder" valign="top" headers="mcps1.3.4.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001188323750__p147114710272">Use the <strong id="EN-US_TOPIC_0000001188323750__b738085810321">CREATE USER</strong> syntax to create a private user.</p> <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_0000001188323750__screen1953020257272">CREATE USER <em id="EN-US_TOPIC_0000001188323750__i470265417105">user_independent </em>WITH INDEPENDENT<em id="EN-US_TOPIC_0000001188323750__i2036937171113"> </em>IDENTIFIED BY '<em id="EN-US_TOPIC_0000001188323750__i270255412103">{Password}'</em>;</pre> <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> </td>
</tr> </tr>
</tbody> </tbody>

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,52 @@
<a name="EN-US_TOPIC_0000001233563239"></a><a name="EN-US_TOPIC_0000001233563239"></a> <a name="EN-US_TOPIC_0000001480021754"></a><a name="EN-US_TOPIC_0000001480021754"></a>
<h1 class="topictitle1">User Management</h1> <h1 class="topictitle1">User Management</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233563239__p1868572342914">You can use <strong id="EN-US_TOPIC_0000001233563239__b177176812178">CREATE USER</strong> and <strong id="EN-US_TOPIC_0000001233563239__b20717186172">ALTER USER</strong> to create and manage database users.</p> <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_0000001233563239__ul18954124143010"><li id="EN-US_TOPIC_0000001233563239__li495444203012">In the non-<a href="dws_04_0056.html">separation-of-permission</a> mode, a <span id="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_0000001233563239__b192571420555">CREATEROLE</strong> attribute.</li><li id="EN-US_TOPIC_0000001233563239__li99541347309">In separation-of-permission mode, a user account can be created only by a security administrator.</li></ul> <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_0000001233563239__s5a76876c562240bb9a03705a6487337f"><h4 class="sectiontitle">Creating a User</h4><p id="EN-US_TOPIC_0000001233563239__p1573314153610">The <strong id="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> <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_0000001233563239__u4bfa4d1112af43318dd434b9cfffcbf0"><li id="EN-US_TOPIC_0000001233563239__li116850349186">Create common user <strong id="EN-US_TOPIC_0000001233563239__b3419153524014">u1</strong> and assign the <strong id="EN-US_TOPIC_0000001233563239__b113871438124015">CREATEDB </strong>attribute to the user.<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233563239__lccbf77bee88541569c5e40005095843d">To create the system administrator <strong id="EN-US_TOPIC_0000001233563239__b4538194264020">mydbadmin</strong>, you need to specify the <strong id="EN-US_TOPIC_0000001233563239__b095615443403">SYSADMIN </strong>parameter.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="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_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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="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_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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233563239__section177791258171313"><h4 class="sectiontitle">Altering User Attributes</h4><p id="EN-US_TOPIC_0000001233563239__p02921820161416">The <strong id="EN-US_TOPIC_0000001233563239__b17869132174116">ALTER USER</strong> statement is used to alter user attributes, such as changing user passwords or permissions.</p> <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_0000001233563239__p19125111219143">Example:</p> <p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p19125111219143">Example:</p>
<ul id="EN-US_TOPIC_0000001233563239__ul8921195210312"><li id="EN-US_TOPIC_0000001233563239__li292145233116">Rename user <strong id="EN-US_TOPIC_0000001233563239__b161931737104020">u1</strong> to <strong id="EN-US_TOPIC_0000001233563239__b93511839104011">u2</strong>.<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233563239__li39221752183118">Grant the <strong id="EN-US_TOPIC_0000001233563239__b655711156422">CREATEROLE</strong> permission to user <strong id="EN-US_TOPIC_0000001233563239__b0818131814425">u1</strong>:<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233563239__li238439133819">For details about how to change the user password, see <a href="dws_04_0063.html#EN-US_TOPIC_0000001188482292__section1897910435417">Setting and Changing a Password</a>.</li></ul> </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>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233563239__section5530258152512"><h4 class="sectiontitle">Locking a User</h4><p id="EN-US_TOPIC_0000001233563239__p583454519420">The <strong id="EN-US_TOPIC_0000001233563239__b156216105177">ACCOUNT LOCK</strong> | <strong id="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> <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_0000001233563239__a965c39fa6c1b485d9531984163b5df7b">Example:</p> <p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_a965c39fa6c1b485d9531984163b5df7b">Example:</p>
<ul id="EN-US_TOPIC_0000001233563239__ul56140553218"><li id="EN-US_TOPIC_0000001233563239__li4615175133217">To lock user <strong id="EN-US_TOPIC_0000001233563239__b515120719181">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001233563239__li62371119328">To unlock user <strong id="EN-US_TOPIC_0000001233563239__b293139141812">u1</strong>, run the following command:<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233563239__section1365185119379"><h4 class="sectiontitle">Deleting a User</h4><p id="EN-US_TOPIC_0000001233563239__p114873574371">The <strong id="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> <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_0000001233563239__ul41936112209"><li id="EN-US_TOPIC_0000001233563239__li171932192015">If multiple users are deleted at the same time, separate them with commas (,).</li><li id="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_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_0000001233563239__li6974145124118">When <strong id="EN-US_TOPIC_0000001233563239__b663378102316">CASCADE </strong>is specified in the <strong id="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> <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_0000001233563239__p1545712420105">Example:</p> <p id="EN-US_TOPIC_0000001480021754__en-us_topic_0000001233563239_p1545712420105">Example:</p>
<ul id="EN-US_TOPIC_0000001233563239__ul19914101516326"><li id="EN-US_TOPIC_0000001233563239__li129141815183214">-- Delete user <strong id="EN-US_TOPIC_0000001233563239__b209671513122518">u1</strong>.<div class="codecoloring" codetype="Sql" id="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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
<ul id="EN-US_TOPIC_0000001233563239__ul13205121973219"><li id="EN-US_TOPIC_0000001233563239__li2205101943217">Delete account <strong id="EN-US_TOPIC_0000001233563239__b321421822517">u2</strong> in a cascading manner.<div class="codecoloring" codetype="Sql" id="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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li></ul> </li></ul>
</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,15 +1,15 @@
<a name="EN-US_TOPIC_0000001233563291"></a><a name="EN-US_TOPIC_0000001233563291"></a> <a name="EN-US_TOPIC_0000001717256744"></a><a name="EN-US_TOPIC_0000001717256744"></a>
<h1 class="topictitle1">Overview</h1> <h1 class="topictitle1">Overview</h1>
<div id="body8662426"><p id="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_0000001233563291__en-us_topic_0000001082926693_ph2740729133515"><i><cite id="EN-US_TOPIC_0000001233563291__en-us_topic_0000001082926693_en-us_topic_0135554668_cite245375118115">MapReduce Service User Guide</cite></i><em id="EN-US_TOPIC_0000001233563291__i13654203215310"></em><em id="EN-US_TOPIC_0000001233563291__i188061438139"></em></span>.</p> <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_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_0000001233563291__en-us_topic_0000001082926693_ph1692512422530">GaussDB(DWS)</span>, you can connect a <span id="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_0000001233563291__en-us_topic_0000001082926693_ph33147185110">GaussDB(DWS)</span> when the clusters are on the same network.</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_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_0000001233563291__p177511536337">Ensure that MRS can communicate with DWS:</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_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_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_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_0000001233563291__i0526163863219">Virtual Private Cloud User Guide</em>.</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_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_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_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> <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></div> </div></div>
<div class="section" id="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_0000001233563291__en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_ol1725018516137"><li id="EN-US_TOPIC_0000001233563291__en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li524814581319"><a href="dws_04_0212.html">Preparing Data in an MRS Cluster</a></li><li id="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_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_0000001233563291__en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li6249258138"><a href="dws_04_0215.html">Importing Data</a></li><li id="EN-US_TOPIC_0000001233563291__en-us_topic_0000001082926693_en-us_topic_0109259514_en-us_topic_0101455468_li42491154139"><a href="dws_04_0216.html">Deleting Resources</a></li></ol> <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> </div>
</div> </div>
<div> <div>

View File

@ -1,22 +1,22 @@
<a name="EN-US_TOPIC_0000001233761903"></a><a name="EN-US_TOPIC_0000001233761903"></a> <a name="EN-US_TOPIC_0000001460722840"></a><a name="EN-US_TOPIC_0000001460722840"></a>
<h1 class="topictitle1">Development and Design Proposal</h1> <h1 class="topictitle1">GaussDB(DWS) Development and Design Proposal</h1>
<div id="body1528161858339"></div> <div id="body1528161858339"></div>
<div> <div>
<ul class="ullinks"> <ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0075.html">Development and Design Proposal</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0075.html">Overview</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0076.html">Database Object Naming Conventions</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0076.html">GaussDB(DWS) Object Naming Conventions</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0077.html">Database Object Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0083.html">JDBC Configuration</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0083.html">GaussDB(DWS) JDBC Configuration Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0084.html">SQL Compilation</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0084.html">GaussDB(DWS) SQL Writing Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0971.html">User-defined External Function Usage (pgSQL/Java)</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0971.html">Rules for Using Custom GaussDB(DWS) External Functions (pgSQL/Java)</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0972.html">PL/pgSQL Usage</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0972.html">Rules for Using GaussDB(DWS) PL/pgSQL</a></strong><br>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -1,13 +1,13 @@
<a name="EN-US_TOPIC_0000001188482086"></a><a name="EN-US_TOPIC_0000001188482086"></a> <a name="EN-US_TOPIC_0000001460882284"></a><a name="EN-US_TOPIC_0000001460882284"></a>
<h1 class="topictitle1">Development and Design Proposal</h1> <h1 class="topictitle1">Overview</h1>
<div id="body1528161858339"><p id="EN-US_TOPIC_0000001188482086__p8060118">This chapter describes the design specifications for database modeling and application development. Modeling compliant with these specifications fits the distributed processing architecture of <span id="EN-US_TOPIC_0000001188482086__text11730754172518">GaussDB(DWS)</span> and provides efficient SQL code.</p> <div id="body1528161858339"><p id="EN-US_TOPIC_0000001460882284__p8060118">This chapter describes the design specifications for database modeling and application development. Modeling compliant with these specifications fits the distributed processing architecture of <span id="EN-US_TOPIC_0000001460882284__text11730754172518">GaussDB(DWS)</span> and provides efficient SQL code.</p>
<p id="EN-US_TOPIC_0000001188482086__p116856421219">The meaning of "Proposal" and "Notice" in this chapter is as follows:</p> <p id="EN-US_TOPIC_0000001460882284__p116856421219">The meaning of "Proposal" and "Notice" in this chapter is as follows:</p>
<ul id="EN-US_TOPIC_0000001188482086__ul1137573119221"><li id="EN-US_TOPIC_0000001188482086__li103752031122219"><strong id="EN-US_TOPIC_0000001188482086__b16921839112211">Proposal</strong>: Design rules. Services compliant with the rules can run efficiently, and those violating the rules may have low performance or logic errors.</li><li id="EN-US_TOPIC_0000001188482086__li154431751122212"><strong id="EN-US_TOPIC_0000001188482086__b14755202118236">Notice</strong>: Details requiring attention during service development. This term identifies SQL behavior that complies with SQL standards but users may have misconceptions about, and default behavior that users may be unaware of in a program.</li></ul> <ul id="EN-US_TOPIC_0000001460882284__ul1137573119221"><li id="EN-US_TOPIC_0000001460882284__li103752031122219"><strong id="EN-US_TOPIC_0000001460882284__b16921839112211">Proposal</strong>: Design rules. Services compliant with the rules can run efficiently, and those violating the rules may have low performance or logic errors.</li><li id="EN-US_TOPIC_0000001460882284__li154431751122212"><strong id="EN-US_TOPIC_0000001460882284__b14755202118236">Notice</strong>: Details requiring attention during service development. This term identifies SQL behavior that complies with SQL standards but users may have misconceptions about, and default behavior that users may be unaware of in a program.</li></ul>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">Development and Design Proposal</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div> </div>
</div> </div>

View File

@ -1,16 +1,16 @@
<a name="EN-US_TOPIC_0000001233883317"></a><a name="EN-US_TOPIC_0000001233883317"></a> <a name="EN-US_TOPIC_0000001510522249"></a><a name="EN-US_TOPIC_0000001510522249"></a>
<h1 class="topictitle1">Database Object Naming Conventions</h1> <h1 class="topictitle1">GaussDB(DWS) Object Naming Conventions</h1>
<div id="body1528161858339"><p id="EN-US_TOPIC_0000001233883317__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 (_), dollar signs ($), and number signs (#).</p> <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_0000001233883317__ul1732014239567"><li id="EN-US_TOPIC_0000001233883317__li183207238569">[Proposal] Do not use reserved or non-reserved keywords to name database objects.<div class="note" id="EN-US_TOPIC_0000001233883317__note133201623175616"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001233883317__p173201323105613">You can run <strong id="EN-US_TOPIC_0000001233883317__b3106953151114">SELECT * FROM pg_get_keywords()</strong> to query GaussDB(DWS) keywords or view the keywords in section "Keywords" in <em id="EN-US_TOPIC_0000001233883317__i618071031215">SQL Syntax Reference</em>.</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>
</div></div> </div></div>
</li><li id="EN-US_TOPIC_0000001233883317__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_0000001233883317__li15563344563">[Proposal] Use the same naming format for database objects.<ul id="EN-US_TOPIC_0000001233883317__ul75615347563"><li id="EN-US_TOPIC_0000001233883317__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_0000001233883317__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_0000001233883317__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_0000001233883317__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__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_0000001233883317__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_0000001233883317__ul7204337175616"><li id="EN-US_TOPIC_0000001233883317__li1320483745615">An ordinary table name should indicate the business relevant to a data set.</li><li id="EN-US_TOPIC_0000001233883317__li3204123718567">Temporary tables are named in the format of <strong id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_b842352706173450">tmp_</strong><em id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_i842352697173448">Suffix</em>.</li><li id="EN-US_TOPIC_0000001233883317__li132041337105615">Unlogged tables are named in the format of <strong id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_b84235270617351">ul_</strong><em id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_i84235269717357">Suffix</em>.</li><li id="EN-US_TOPIC_0000001233883317__li19204137195614">Foreign tables are named in the format of <strong id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_b842352706143019">f_</strong><em id="EN-US_TOPIC_0000001233883317__en-us_topic_0097059046_i842352697143034">Suffix</em>.</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></ul> </li></ul>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">Development and Design Proposal</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div> </div>
</div> </div>

View File

@ -1,23 +1,23 @@
<a name="EN-US_TOPIC_0000001188323740"></a><a name="EN-US_TOPIC_0000001188323740"></a> <a name="EN-US_TOPIC_0000001510402361"></a><a name="EN-US_TOPIC_0000001510402361"></a>
<h1 class="topictitle1">Database Object Design</h1> <h1 class="topictitle1">GaussDB(DWS) Database Object Design</h1>
<div id="body1528161858339"></div> <div id="body1528161858339"></div>
<div> <div>
<ul class="ullinks"> <ul class="ullinks">
<li class="ulchildlink"><strong><a href="dws_04_0078.html">Database and Schema Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0078.html">GaussDB(DWS) Database and Schema Design Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0079.html">Table Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0079.html">GaussDB(DWS) Table Design Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0080.html">Column Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0080.html">GaussDB(DWS) Field Design Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0081.html">Constraint Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0081.html">GaussDB(DWS) Constraint Design Rules</a></strong><br>
</li> </li>
<li class="ulchildlink"><strong><a href="dws_04_0082.html">View and Joined Table Design</a></strong><br> <li class="ulchildlink"><strong><a href="dws_04_0082.html">Design Rules for GaussDB(DWS) Views and Associated Tables</a></strong><br>
</li> </li>
</ul> </ul>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">Development and Design Proposal</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div> </div>
</div> </div>

View File

@ -1,16 +1,16 @@
<a name="EN-US_TOPIC_0000001188482124"></a><a name="EN-US_TOPIC_0000001188482124"></a> <a name="EN-US_TOPIC_0000001510162773"></a><a name="EN-US_TOPIC_0000001510162773"></a>
<h1 class="topictitle1">Database and Schema Design</h1> <h1 class="topictitle1">GaussDB(DWS) Database and Schema Design Rules</h1>
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001188482124__a163526b0670d42fa992ba7033a636dc1">In <span id="EN-US_TOPIC_0000001188482124__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_0000001188482124__b84235270694635">GRANT</strong> and <strong id="EN-US_TOPIC_0000001188482124__b84235270694632">REVOKE</strong> syntax.</p> <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_0000001188482124__ul14407749155613"><li id="EN-US_TOPIC_0000001188482124__li17407249185610">You are advised to use schemas to isolate services for convenience and resource sharing.</li><li id="EN-US_TOPIC_0000001188482124__li57147515561">It is recommended that system administrators create schemas and databases and then assign required permissions to users.</li></ul> <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_0000001188482124__sb41154e9d50a48e6ada14ffd10d2b591"><h4 class="sectiontitle">Database Design Suggestions</h4><ul id="EN-US_TOPIC_0000001188482124__ul1241013276555"><li id="EN-US_TOPIC_0000001188482124__li47531831165518">Create databases as required. Do not use the default <strong id="EN-US_TOPIC_0000001188482124__b149702415296"><span id="EN-US_TOPIC_0000001188482124__text17442175020432">gaussdb</span></strong> database of a cluster.</li><li id="EN-US_TOPIC_0000001188482124__li7201934125511">Create a maximum of three user-defined databases in a cluster.</li><li id="EN-US_TOPIC_0000001188482124__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_0000001188482124__li1931294213555">Exercise caution when you set <strong id="EN-US_TOPIC_0000001188482124__b84235270619237">ENCODING</strong> and <strong id="EN-US_TOPIC_0000001188482124__b84235270619239">DBCOMPATIBILITY</strong> configuration items during database creation. In <span id="EN-US_TOPIC_0000001188482124__text1069744734">GaussDB(DWS)</span>, <strong id="EN-US_TOPIC_0000001188482124__b842352706113254">DBCOMPATIBILITY</strong> can be set to <strong id="EN-US_TOPIC_0000001188482124__b842352706114537">TD</strong>, <strong id="EN-US_TOPIC_0000001188482124__b842352706114542">Oracle</strong>, or <strong id="EN-US_TOPIC_0000001188482124__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_0000001188482124__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 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> </div>
<div class="section" id="EN-US_TOPIC_0000001188482124__s51d3bc0fb11b4dccbfd9db3d49343942"><h4 class="sectiontitle">Schema Design Suggestions</h4><ul id="EN-US_TOPIC_0000001188482124__ul14634748125512"><li id="EN-US_TOPIC_0000001188482124__li846585175513">To let a user access an object in a schema, grant the <strong id="EN-US_TOPIC_0000001188482124__b16307749125110">usage</strong> permission and the permissions for the object to the user, unless the user has the <strong id="EN-US_TOPIC_0000001188482124__b7235165515515">sysadmin</strong> permission or is the schema owner.</li><li id="EN-US_TOPIC_0000001188482124__li46701354105515">To let a user create an object in the schema, grant the <strong id="EN-US_TOPIC_0000001188482124__b9700145918515">CREATE</strong> permission for the schema to the user.</li><li id="EN-US_TOPIC_0000001188482124__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_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> </div>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">Database Object Design</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
</div> </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_0000001233681823"></a><a name="EN-US_TOPIC_0000001233681823"></a> <a name="EN-US_TOPIC_0000001510162537"></a><a name="EN-US_TOPIC_0000001510162537"></a>
<h1 class="topictitle1">Constraint Design</h1> <h1 class="topictitle1">GaussDB(DWS) Constraint Design Rules</h1>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001233681823__section555838816718"><h4 class="sectiontitle">DEFAULT and NULL Constraints</h4><ul id="EN-US_TOPIC_0000001233681823__ul1188131610581"><li id="EN-US_TOPIC_0000001233681823__li1188616165818">[Proposal] If all the column values can be obtained from services, you are not advised to use the <strong id="EN-US_TOPIC_0000001233681823__b842352706163544">DEFAULT</strong> constraint, because doing so will generate unexpected results during data loading.</li><li id="EN-US_TOPIC_0000001233681823__li124803200584">[Proposal] Add <strong id="EN-US_TOPIC_0000001233681823__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_0000001233681823__li11798102210586">[Proposal] Explicitly name all constraints excluding <strong id="EN-US_TOPIC_0000001233681823__b842352706163934">NOT NULL</strong> and <strong id="EN-US_TOPIC_0000001233681823__b842352706163937">DEFAULT</strong>.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233681823__section2578598416718"><h4 class="sectiontitle">Partial Cluster Key</h4><p id="EN-US_TOPIC_0000001233681823__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_0000001233681823__text1158130347">GaussDB(DWS)</span>. Comply with the following rules to create a PCK:</p> <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_0000001233681823__ul8800142614588"><li id="EN-US_TOPIC_0000001233681823__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_0000001233681823__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_0000001233681823__b84235270617039">col op const</strong>, where <strong id="EN-US_TOPIC_0000001233681823__b84235270617137">col</strong> specifies a column name, <strong id="EN-US_TOPIC_0000001233681823__b84235270617143">op</strong> specifies an operator (such as =, &gt;, &gt;=, &lt;=, and &lt;), and <strong id="EN-US_TOPIC_0000001233681823__b8423527061721">const</strong> specifies a constant.</li><li id="EN-US_TOPIC_0000001233681823__li1131316325583">[Proposal] If the preceding conditions are met, create a PCK on the column having the least distinct values.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233681823__section958094516718"><h4 class="sectiontitle">Unique Constraint</h4><ul id="EN-US_TOPIC_0000001233681823__ul184984019587"><li id="EN-US_TOPIC_0000001233681823__li17849940165819">[Notice] Both row-store and column-store tables support unique constraints.</li><li id="EN-US_TOPIC_0000001233681823__li15802104395817">[Proposal] The constraint name should indicate that it is a unique constraint, for example, <strong id="EN-US_TOPIC_0000001233681823__b84235270617735">UNI</strong><em id="EN-US_TOPIC_0000001233681823__i84235269717747">Included columns</em>.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233681823__section3696271616719"><h4 class="sectiontitle">Primary Key Constraint</h4><ul id="EN-US_TOPIC_0000001233681823__ul139403464585"><li id="EN-US_TOPIC_0000001233681823__li2940646185816">[Notice] Both row-store and column-store tables support the primary key constraint.</li><li id="EN-US_TOPIC_0000001233681823__li3376144911587">[Proposal] The constraint name should indicate that it is a primary key constraint, for example, <strong id="EN-US_TOPIC_0000001233681823__b982443271171149">PK</strong><em id="EN-US_TOPIC_0000001233681823__i2143730926171149">Included columns</em>.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233681823__section45602286161148"><h4 class="sectiontitle">Check Constraint</h4><ul id="EN-US_TOPIC_0000001233681823__ul9583552165819"><li id="EN-US_TOPIC_0000001233681823__li135837525587">[Notice] Check constraints can be used in row-store tables but not in column-store tables.</li><li id="EN-US_TOPIC_0000001233681823__li3792165419589">[Proposal] The constraint name should indicate that it is a check constraint, for example, <strong id="EN-US_TOPIC_0000001233681823__b914985737">CK</strong><em id="EN-US_TOPIC_0000001233681823__i1486198355">Included columns</em>.</li></ul> <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> </div>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">Database Object Design</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
</div> </div>
</div> </div>

View File

@ -1,14 +1,14 @@
<a name="EN-US_TOPIC_0000001233681661"></a><a name="EN-US_TOPIC_0000001233681661"></a> <a name="EN-US_TOPIC_0000001510162533"></a><a name="EN-US_TOPIC_0000001510162533"></a>
<h1 class="topictitle1">View and Joined Table Design</h1> <h1 class="topictitle1">Design Rules for GaussDB(DWS) Views and Associated Tables</h1>
<div id="body1528162486098"><div class="section" id="EN-US_TOPIC_0000001233681661__section4431103710524"><h4 class="sectiontitle">View Design</h4><ul id="EN-US_TOPIC_0000001233681661__ul15374258175816"><li id="EN-US_TOPIC_0000001233681661__li18374258155814">[Proposal] Do not nest views unless they have strong dependency on each other.</li><li id="EN-US_TOPIC_0000001233681661__li95301035916">[Proposal] Try to avoid sort operations in a view definition.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233681661__section6265550010713"><h4 class="sectiontitle">Joined Table Design</h4><ul id="EN-US_TOPIC_0000001233681661__ul1798817211596"><li id="EN-US_TOPIC_0000001233681661__li15988523595">[Proposal] Minimize joined columns across tables.</li><li id="EN-US_TOPIC_0000001233681661__li82861353592">[Proposal] Joined columns should use the same data type.</li><li id="EN-US_TOPIC_0000001233681661__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_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> </div>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">Database Object Design</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0077.html">GaussDB(DWS) Database Object Design</a></div>
</div> </div>
</div> </div>

View File

@ -1,8 +1,8 @@
<a name="EN-US_TOPIC_0000001233761889"></a><a name="EN-US_TOPIC_0000001233761889"></a> <a name="EN-US_TOPIC_0000001510402413"></a><a name="EN-US_TOPIC_0000001510402413"></a>
<h1 class="topictitle1">JDBC Configuration</h1> <h1 class="topictitle1">GaussDB(DWS) JDBC Configuration Rules</h1>
<div id="body1528162486098"><p id="EN-US_TOPIC_0000001233761889__p83201518124912">Currently, third-party tools are connected to <span id="EN-US_TOPIC_0000001233761889__text120969138">GaussDB(DWS)</span> trough JDBC. This section describes the precautions for configuring the tools.</p> <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_0000001233761889__section51233666102514"><h4 class="sectiontitle">Connection Parameters</h4><ul id="EN-US_TOPIC_0000001233761889__ul4235888102912"><li id="EN-US_TOPIC_0000001233761889__li33742908102912">[Notice] When a third-party tool connects to <span id="EN-US_TOPIC_0000001233761889__text267386391">GaussDB(DWS)</span> through JDBC, JDBC sends a connection request to <span id="EN-US_TOPIC_0000001233761889__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_0000001233761889__screen51783857102912">params = { <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 = {
{ "user", user }, { "user", user },
{ "database", database }, { "database", database },
{ "client_encoding", "UTF8" }, { "client_encoding", "UTF8" },
@ -10,27 +10,27 @@
{ "extra_float_digits", "2" }, { "extra_float_digits", "2" },
{ "TimeZone", createPostgresTimeZone() }, { "TimeZone", createPostgresTimeZone() },
};</pre> };</pre>
<p id="EN-US_TOPIC_0000001233761889__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__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_0000001233761889__p63401535102912">If the result is not as expected, you are advised to explicitly set these parameters in the Java connection setting.</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_0000001233761889__li22840275102912">[Proposal] When connecting to the database through JDBC, ensure that the following two time zones are the same:<ul id="EN-US_TOPIC_0000001233761889__ul62190131102912"><li id="EN-US_TOPIC_0000001233761889__li35250721102912">Time zone of the host where the JDBC client is located</li><li id="EN-US_TOPIC_0000001233761889__li16356185655617">Time zone of the host where the <span id="EN-US_TOPIC_0000001233761889__text675913043">GaussDB(DWS)</span> server is located</li></ul> </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>
</li></ul> </li></ul>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001233761889__section2864318010275"><h4 class="sectiontitle">fetchsize</h4><p id="EN-US_TOPIC_0000001233761889__p1208899">[Notice] To use <strong id="EN-US_TOPIC_0000001233761889__b21951949173115">fetchsize</strong> in applications, disable the <strong id="EN-US_TOPIC_0000001233761889__b842352706145926">autocommit</strong> switch. Enabling the <strong id="EN-US_TOPIC_0000001233761889__b84235270615044">autocommit</strong> switch makes the <strong id="EN-US_TOPIC_0000001233761889__b84235270615111">fetchsize</strong> configuration invalid.</p> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233761889__section1636443510276"><h4 class="sectiontitle">autocommit</h4><p id="EN-US_TOPIC_0000001233761889__p40373845104858">[Proposal] It is recommended that you enable the <strong id="EN-US_TOPIC_0000001233761889__b842352706142820">autocommit</strong> switch in the code for connecting to <span id="EN-US_TOPIC_0000001233761889__text265447366">GaussDB(DWS)</span> by the JDBC. If <strong id="EN-US_TOPIC_0000001233761889__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_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> </div>
<div class="section" id="EN-US_TOPIC_0000001233761889__section1577694110277"><h4 class="sectiontitle">Connection Releasing</h4><p id="EN-US_TOPIC_0000001233761889__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> <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_0000001233761889__p23100085">[Proposal] After an application completes its tasks, disconnect its connection to <span id="EN-US_TOPIC_0000001233761889__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__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_0000001233761889__p1964373612402">[Proposal] Reset the session environment before releasing connections to the JDBC connection tool. Otherwise, historical session information may cause object conflicts.</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_0000001233761889__ul319815399488"><li id="EN-US_TOPIC_0000001233761889__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001233761889__b155527413207">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001233761889__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233761889__section1624965810277"><h4 class="sectiontitle">CopyManager</h4><p id="EN-US_TOPIC_0000001233761889__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_0000001233761889__text12103183452013">GaussDB(DWS)</span> JDBC to import data in batches during application development.</p> <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_0000001233761889__p17571351132311">For details about how to use CopyManager, see <a href="dws_04_0116.html">CopyManager</a>.</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> </div>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">Development and Design Proposal</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div> </div>
</div> </div>

View File

@ -1,40 +1,35 @@
<a name="EN-US_TOPIC_0000001188642000"></a><a name="EN-US_TOPIC_0000001188642000"></a> <a name="EN-US_TOPIC_0000001510283305"></a><a name="EN-US_TOPIC_0000001510283305"></a>
<h1 class="topictitle1">SQL Compilation</h1> <h1 class="topictitle1">GaussDB(DWS) SQL Writing Rules</h1>
<div id="body1528161858339"><div class="section" id="EN-US_TOPIC_0000001188642000__section60205875143313"><h4 class="sectiontitle">DDL</h4><ul id="EN-US_TOPIC_0000001188642000__ul1972862419595"><li id="EN-US_TOPIC_0000001188642000__li1072832415918">[Proposal] In <span id="EN-US_TOPIC_0000001188642000__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_0000001188642000__li5212735919">[Proposal] Execute data truncation after unlogged tables are used because <span id="EN-US_TOPIC_0000001188642000__text281995683">GaussDB(DWS)</span> cannot ensure the security of unlogged tables in abnormal scenarios.</li><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_0000001188642000__li17294434115910">[Proposal] Do not use <strong id="EN-US_TOPIC_0000001188642000__b8805412184814">DROP... CASCADE</strong> to delete objects unless the dependencies between objects are specified. Otherwise, objects may be deleted by mistake.</li></ul> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001188642000__section45234071153513"><h4 class="sectiontitle">Data Loading and Uninstalling</h4><ul id="EN-US_TOPIC_0000001188642000__ul866153885912"><li id="EN-US_TOPIC_0000001188642000__li1466143811599">[Proposal] Provide the inserted column list in the insert statement. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__li18713443105913">[Proposal] To clear all data in a table, you are advised to use <strong id="EN-US_TOPIC_0000001188642000__b1688884693638">TRUNCATE TABLE</strong> instead of <strong id="EN-US_TOPIC_0000001188642000__b200528289993638">DELETE TABLE</strong>. <strong id="EN-US_TOPIC_0000001188642000__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_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>
</div> </div>
<div class="section" id="EN-US_TOPIC_0000001188642000__section28537273145311"><h4 class="sectiontitle">Type conversion</h4><ul id="EN-US_TOPIC_0000001188642000__ul11745246115918"><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_0000001188642000__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_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> </div>
<div class="section" id="EN-US_TOPIC_0000001188642000__section48841047154511"><h4 class="sectiontitle">Query Operation</h4><ul id="EN-US_TOPIC_0000001188642000__ul31156185916"><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_0000001188642000__li13858707018">[Proposal] During query compilation, you are advised to list all columns to be queried and avoid using <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_0000001188642000__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_0000001188642000__b842352706114736">WITH TABLE AS</strong> statement to create interim tables to improve the readability of SQL statements.</li><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__li142772131306">[Notice] Only <strong id="EN-US_TOPIC_0000001188642000__b842352706115240">IS NULL</strong> and <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__b1727151044012">NULL</strong> instead of expected Boolean values is returned for <strong id="EN-US_TOPIC_0000001188642000__b842352706115627">NULL&lt;&gt;NULL</strong>, <strong id="EN-US_TOPIC_0000001188642000__b842352706115631">NULL=NULL</strong>, and <strong id="EN-US_TOPIC_0000001188642000__b842352706115635">NULL&lt;&gt;1</strong>.</li><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_0000001188642000__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_0000001188642000__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_0000001188642000__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_0000001188642000__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_0000001188642000__screen1269491605712">SELECT * FROM test WHERE timestamp_col = 20000101;</pre> <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_0000001188642000__p3801145495418">In the preceding example, if <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__b1528517173164">timestamp_col</strong> data and constant numbers are implicitly converted into the text type for calculation.</p> <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_0000001188642000__li54741939206">[Proposal] Do not use scalar subquery statements. A scalar subquery appears in the output list of a <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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> </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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
<p id="EN-US_TOPIC_0000001188642000__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> <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_0000001188642000__li6104647302">[Proposal] In <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__li20777449808">[Proposal] The filter criteria in the WHERE clause should comply with the unilateral rule. That is, the field name is placed on one side of the comparison condition. This allows the optimizer to automatically perform pruning optimization in some scenarios. Filtering conditions in a <strong id="EN-US_TOPIC_0000001188642000__b124629312895126">WHERE</strong> clause will be displayed in <strong id="EN-US_TOPIC_0000001188642000__b139129845295126">col op expression</strong> format, where <strong id="EN-US_TOPIC_0000001188642000__b119823048695126">col</strong> indicates a table column, <strong id="EN-US_TOPIC_0000001188642000__b1037389995126">op</strong> indicates a comparison operator, such as = and &gt;, and <strong id="EN-US_TOPIC_0000001188642000__b89754445695126">expression</strong> indicates an expression that does not contain a column name. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__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> </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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
<p id="EN-US_TOPIC_0000001188642000__p26912854112759">The modification is as follows:</p> <p id="EN-US_TOPIC_0000001510283305__p26912854112759">The modification is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188642000__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_0000001188642000__b842352706164621">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001188642000__b842352706164624">LIMIT</strong> can be combined to reduce resource overhead. By default, data in <span id="EN-US_TOPIC_0000001188642000__text30313868">GaussDB(DWS)</span> is sorted by ASC &amp; NULL LAST.</li><li id="EN-US_TOPIC_0000001188642000__li1294114512111">[Proposal] When the <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__li5371188317">[proposal] Do not rely on only the <strong id="EN-US_TOPIC_0000001188642000__b842352706165145">LIMIT</strong> clause to return the result set displayed in a specific sequence. Combine <strong id="EN-US_TOPIC_0000001188642000__b842352706165346">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001188642000__b842352706165350">LIMIT</strong> clauses for some specific result sets and use offset to skip specific results if necessary.</li><li id="EN-US_TOPIC_0000001188642000__li861011115">[Proposal] If the service logic is accurate, you are advised to use <strong id="EN-US_TOPIC_0000001188642000__b84235270617118">UNION ALL</strong> instead of <strong id="EN-US_TOPIC_0000001188642000__b84235270617121">UNION</strong>.</li><li id="EN-US_TOPIC_0000001188642000__li957714131716">[Proposal] If a filtering condition contains only an <strong id="EN-US_TOPIC_0000001188642000__b84235270617126">OR</strong> expression, convert the <strong id="EN-US_TOPIC_0000001188642000__b84235270617135">OR </strong>expression to <strong id="EN-US_TOPIC_0000001188642000__b84235270617131">UNION ALL</strong> to improve performance. SQL statements that use <strong id="EN-US_TOPIC_0000001188642000__b84235270617155">OR</strong> expressions cannot be optimized, resulting in slow execution. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__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_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>
<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="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> <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> </pre></div></td></tr></table></div>
</div> </div>
<p id="EN-US_TOPIC_0000001188642000__p9824563112759">Convert the statement to the following:</p> <p id="EN-US_TOPIC_0000001510283305__p9824563112759">Convert the statement to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__screen36954014112759"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span> <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>
<span class="normal">2</span> <span class="normal">2</span>
<span class="normal">3</span> <span class="normal">3</span>
<span class="normal">4</span> <span class="normal">4</span>
@ -50,25 +45,22 @@
<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">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">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> <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> </pre></div></td></tr></table></div>
</div> </div>
</li><li id="EN-US_TOPIC_0000001188642000__li88758236119">[Proposal] If an <strong id="EN-US_TOPIC_0000001188642000__b842352706163646">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_0000001188642000__b842352706163620">IN (values (va1), (val2),(val3...)</strong> statement. The optimizer will automatically convert the <strong id="EN-US_TOPIC_0000001188642000__b1458111681316">IN</strong> constraint into a non-correlated subquery to improve the query performance.</li><li id="EN-US_TOPIC_0000001188642000__li1837032616114">[Proposal] Replace <strong id="EN-US_TOPIC_0000001188642000__b842352706174314">(NOT) IN</strong> with <strong id="EN-US_TOPIC_0000001188642000__b842352706174319">(NOT) EXIST</strong> when associated columns do not contain <strong id="EN-US_TOPIC_0000001188642000__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_0000001188642000__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_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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
<p id="EN-US_TOPIC_0000001188642000__p58071969112759">Rewrite the statement as follows:</p> <p id="EN-US_TOPIC_0000001510283305__p58071969112759">Rewrite the statement as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188642000__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> <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>
</pre></div></td></tr></table></div> </pre></div></td></tr></table></div>
</div> </div>
<div class="note" id="EN-US_TOPIC_0000001188642000__note30088550112759"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001188642000__ul33169334112759"><li id="EN-US_TOPIC_0000001188642000__li6209029112759">If you cannot ensure that the values of the <strong id="EN-US_TOPIC_0000001188642000__b1897426124316">T1.C1</strong> column are <strong id="EN-US_TOPIC_0000001188642000__b1177685124314">NOT NULL</strong>, you cannot use <strong id="EN-US_TOPIC_0000001188642000__b20569184314434">(NOT) EXIST</strong> instead of <strong id="EN-US_TOPIC_0000001188642000__b212004724314">(NOT) IN</strong>.</li><li id="EN-US_TOPIC_0000001188642000__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_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></div> </div></div>
</li><li id="EN-US_TOPIC_0000001188642000__li145891038416">[Proposal] Use cursors instead of the <strong id="EN-US_TOPIC_0000001188642000__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_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>
</div> </div>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">Development and Design Proposal</a></div> <div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
<a name="EN-US_TOPIC_0000001233681777"></a><a name="EN-US_TOPIC_0000001233681777"></a> <a name="EN-US_TOPIC_0000001510283385"></a><a name="EN-US_TOPIC_0000001510283385"></a>
<h1 class="topictitle1">Guide: JDBC- or ODBC-Based Development</h1> <h1 class="topictitle1">Using JDBC or ODBC for GaussDB(DWS) Secondary Development</h1>
<div id="body1494318355094"></div> <div id="body1494318355094"></div>
<div> <div>
<ul class="ullinks"> <ul class="ullinks">

View File

@ -1,13 +1,13 @@
<a name="EN-US_TOPIC_0000001188163706"></a><a name="EN-US_TOPIC_0000001188163706"></a> <a name="EN-US_TOPIC_0000001460882696"></a><a name="EN-US_TOPIC_0000001460882696"></a>
<h1 class="topictitle1">Development Specifications</h1> <h1 class="topictitle1">Development Specifications</h1>
<div id="body1524796389552"><p id="EN-US_TOPIC_0000001188163706__p168620462426">If the connection pool mechanism is used during application development, comply with the following specifications:</p> <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_0000001188163706__ul319815399488"><li id="EN-US_TOPIC_0000001188163706__li319853920486">If GUC parameters are set in the connection, before you return the connection to the connection pool, run <strong id="EN-US_TOPIC_0000001188163706__b84235270618227">SET SESSION AUTHORIZATION DEFAULT;RESET ALL;</strong> to clear the connection status.</li><li id="EN-US_TOPIC_0000001188163706__li7553164720488">If a temporary table is used, delete it before you return the connection to the connection pool.</li></ul> <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_0000001188163706__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> <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>
</div> </div>
<div> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0085.html">Guide: JDBC- or ODBC-Based Development</a></div> <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>
</div> </div>

View File

@ -1,11 +1,11 @@
<a name="EN-US_TOPIC_0000001233681679"></a><a name="EN-US_TOPIC_0000001233681679"></a> <a name="EN-US_TOPIC_0000001460722600"></a><a name="EN-US_TOPIC_0000001460722600"></a>
<h1 class="topictitle1">Downloading Drivers</h1> <h1 class="topictitle1">Downloading Drivers</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233681679__en-us_topic_0000001099130898_p4451066501">For details, see section "Downloading the JDBC or ODBC Driver" in the <em id="EN-US_TOPIC_0000001233681679__i0667146155217">Data Warehouse Service User Guide</em>.</p> <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> <div>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0085.html">Guide: JDBC- or ODBC-Based Development</a></div> <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>
</div> </div>

View File

@ -1,7 +1,7 @@
<a name="EN-US_TOPIC_0000001233883331"></a><a name="EN-US_TOPIC_0000001233883331"></a> <a name="EN-US_TOPIC_0000001460882148"></a><a name="EN-US_TOPIC_0000001460882148"></a>
<h1 class="topictitle1">JDBC-Based Development</h1> <h1 class="topictitle1">JDBC-Based Development</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233883331__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_0000001233883331__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 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>
<div> <div>
<ul class="ullinks"> <ul class="ullinks">
@ -34,7 +34,7 @@
</ul> </ul>
<div class="familylinks"> <div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0085.html">Guide: JDBC- or ODBC-Based Development</a></div> <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>
</div> </div>

View File

@ -1,11 +1,13 @@
<a name="EN-US_TOPIC_0000001233883313"></a><a name="EN-US_TOPIC_0000001233883313"></a> <a name="EN-US_TOPIC_0000001510162777"></a><a name="EN-US_TOPIC_0000001510162777"></a>
<h1 class="topictitle1">JDBC Package and Driver Class</h1> <h1 class="topictitle1">JDBC Package and Driver Class</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001233883313__sbfa536a4d98e47b384c69d8cb91db388"><h4 class="sectiontitle">JDBC Package</h4><p id="EN-US_TOPIC_0000001233883313__p278421418394"><span id="EN-US_TOPIC_0000001233883313__ph16541135093317">Obtain the package <strong id="EN-US_TOPIC_0000001233883313__b1186245912512">dws_8.1.x_jdbc_driver.zip</strong> from the management console. For details, see <a href="dws_04_0087.html">Downloading Drivers</a>.</span></p> <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_0000001233883313__p12247165410113">JDBC driver JAR package obtained from decompression:</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_0000001233883313__p1229663019123"><strong id="EN-US_TOPIC_0000001233883313__b684245320518">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> <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> </div>
<div class="section" id="EN-US_TOPIC_0000001233883313__section3630181618106"><h4 class="sectiontitle">Driver Class</h4><p id="EN-US_TOPIC_0000001233883313__p463114164108">Before creating a database connection, you need to load the database driver class <strong id="EN-US_TOPIC_0000001233883313__b13554121666">org.postgresql.Driver</strong> (decompressed from <strong id="EN-US_TOPIC_0000001233883313__b25543211614">gsjdbc4.jar</strong>).</p> <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> </div>
</div> </div>
<div> <div>

View File

@ -1,7 +1,7 @@
<a name="EN-US_TOPIC_0000001188482318"></a><a name="EN-US_TOPIC_0000001188482318"></a> <a name="EN-US_TOPIC_0000001510163037"></a><a name="EN-US_TOPIC_0000001510163037"></a>
<h1 class="topictitle1">Development Process</h1> <h1 class="topictitle1">Development Process</h1>
<div id="body8662426"><div class="fignone" id="EN-US_TOPIC_0000001188482318__fcafbde07cfaa494ab49f20ae5bd84b7a"><span class="figcap"><b>Figure 1 </b>JDBC-based application development process</span><br><span><img id="EN-US_TOPIC_0000001188482318__i6a73e7281bc64638b280d20b489a02a6" src="figure/en-us_image_0000001188642284.png"></span></div> <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> <div>
<div class="familylinks"> <div class="familylinks">
@ -9,3 +9,10 @@
</div> </div>
</div> </div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>

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