doc-exports/docs/dws/tool/dws_16_0122.html
Lu, Huayi 27019c2991 DWS TOOL 830.201 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:35:25 +00:00

99 lines
11 KiB
HTML

<a name="EN-US_TOPIC_0000001772536492"></a><a name="EN-US_TOPIC_0000001772536492"></a>
<h1 class="topictitle1">AUTO_INCREMENT</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p48341613162011">In database application, unique numbers that increase automatically are needed to identify records. In MySQL, the <strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_b99954976132331">AUTO_INCREMENT</strong> attribute of a data column can be used to automatically generate the numbers. When creating a table, you can use <strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_b7674789032331">AUTO_INCREMENT=</strong><em id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_i37129044132331">n</em> to specify a start value. You can also use the <strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_b169406172032331">ALTER TABLE </strong><em id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_i67596692132331">TABLE_NAME</em><strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_b137749725732331"> AUTO_INCREMENT=</strong><em id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_i65815891032331">n</em> command to reset the start value. GaussDB(DWS) does not support this parameter. During DSC migration, the columns with this attribute set are migrated to the SERIAL type, and the keyword is deleted. The following <a href="#EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_table10533101812314">Table</a> describes the conversion:</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_table10533101812314"></a><a name="en-us_topic_0000001658024682_en-us_topic_0000001435896181_table10533101812314"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_table10533101812314" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Data type conversion</caption><thead align="left"><tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row135331218103115"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.1"><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p17533101813116">MySQL Numeric Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.2"><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1653310187316">MySQL INPUT</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.2.2.4.1.3"><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p85341518193115">GaussDB(DWS) OUTPUT</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row1753451813116"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p253401811312">TINYINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p653481893112">TINYINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1534181833118">SMALLSERIAL</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row45341118103120"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1853413183315">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p135341318163117">SMALLINT UNSIGNED</p>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p16287125823317">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1453414188312">SERIAL</p>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p16194016113416">SMALLSERIAL</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row155344187311"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p853491823116">DOUBLE/FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1353412182310">DOUBLE/FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p17534151823116">BIGSERIAL</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row85341918153111"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1653431818314">INT/INTEGER</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p199405433510">INT/INTEGER UNSIGNED</p>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p8868553614">INT/INTEGER</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p10763121673611">BIGSERIAL</p>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1677151815367">SERIAL</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_row1553413185313"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p6534418113112">BIGINT/SERIAL</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p364217703716">BIGINT/SERIAL</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_p1353411180311">BIGSERIAL</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p6645131502215"><strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_b6512225193817">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_screen41228368223">CREATE TABLE `public`.`job_instance` (
`job_sche_id` int(11) NOT NULL AUTO_INCREMENT,
`task_name` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`job_sche_id`)
) ENGINE=InnoDB AUTO_INCREMENT=219 DEFAULT CHARSET=utf8;</pre>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p1523917273222"><strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_b690518362380">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_screen1489394112228">CREATE TABLE "public"."job_instance"
(
"job_sche_id" SERIAL NOT NULL,
"task_name" VARCHAR(400) NOT NULL DEFAULT '',
PRIMARY KEY ("job_sche_id")
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("job_sche_id");</pre>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p7586132133119">In addition, GaussDB(DWS) does not support table definition modification using the <strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_b39517671232331">AUTO_INCREMENT</strong> attribute. DSC will delete this attribute during migration.</p>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p15219154320327"><strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_b208996209548">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_screen1725735293216">CREATE TABLE IF NOT EXISTS `public`.`runoob_alter_test`(
`dataType1` int NOT NULL AUTO_INCREMENT,
`dataType2` FLOAT(10,2),
PRIMARY KEY(`dataType1`)
);
ALTER TABLE runoob_alter_test AUTO_INCREMENT 100;
ALTER TABLE runoob_alter_test AUTO_INCREMENT=100;</pre>
<p id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_p10773347173215"><strong id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_b1388842385419">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001772536492__en-us_topic_0000001658024682_en-us_topic_0000001435896181_en-us_topic_0214164775_screen143081457173210">CREATE TABLE IF NOT EXISTS "public"."runoob_alter_test"
(
"datatype1" SERIAL NOT NULL,
"datatype2" REAL,
PRIMARY KEY ("datatype1")
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("datatype1");</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0119.html">Table (Optional Parameters and Operations)</a></div>
</div>
</div>