doc-exports/docs/ddm/umn/ddm_08_0029.html
Ru, Li Yi 4b09a03a51 ddm_umn
Reviewed-by: Wagner, Fabian <fabian.wagner@t-systems.com>
Co-authored-by: Ru, Li Yi <liyiru7@huawei.com>
Co-committed-by: Ru, Li Yi <liyiru7@huawei.com>
2024-04-11 11:39:26 +00:00

46 lines
3.3 KiB
HTML

<a name="ddm_08_0029"></a><a name="ddm_08_0029"></a>
<h1 class="topictitle1">Creating a Table</h1>
<div id="body0000001076404783"><div class="note" id="ddm_08_0029__note17832182104516"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="ddm_08_0029__ul186991928143015"><li id="ddm_08_0029__li4699172863019">Do not create tables whose names start with <strong id="ddm_08_0029__b614563314374">_ddm</strong>. DDM manages such tables as internal tables by default</li><li id="ddm_08_0029__li8699152863016">Sharded tables do not support globally unique indexes. If the unique key is different from the sharding key, data uniqueness cannot be ensured.</li><li id="ddm_08_0029__li632110169107">The auto-increment key should be a BIGINT value. To avoid duplicate values, do not use TINYINT, SMALLINT, MEDIUMINT, INTEGER, or INT as the auto-increment key.</li></ul>
</div></div>
<div class="section" id="ddm_08_0029__section16499134915119"><h4 class="sectiontitle">Database and Table Sharding</h4><p id="ddm_08_0029__p8060118">The following is an example statement when HASH is used for database sharding and MOD_HASH for table sharding:</p>
<pre class="screen" id="ddm_08_0029__screen768013001216">CREATE TABLE tbpartition_tb1 (
id bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key id',
name varchar(128),
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
DBPARTITION BY HASH(id)
TBPARTITION BY MOD_HASH(name) tbpartitions 8;</pre>
</div>
<div class="section" id="ddm_08_0029__section19466202493719"><h4 class="sectiontitle">Database Sharding</h4><p id="ddm_08_0029__p984217511672">The following is an example statement when HASH is used:</p>
<pre class="screen" id="ddm_08_0029__screen1070855283716">CREATE TABLE dbpartition_tb1 (
id bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key id',
name varchar(128),
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
DBPARTITION BY HASH(id);</pre>
</div>
<div class="section" id="ddm_08_0029__section1234151111474"><h4 class="sectiontitle">Creating a Broadcast Table</h4><p id="ddm_08_0029__p741623674718">The following is an example statement:</p>
<pre class="screen" id="ddm_08_0029__screen156062610489">CREATE TABLE broadcast_tb1 (
id bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key id',
name varchar(128),
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
BROADCAST;</pre>
</div>
<div class="section" id="ddm_08_0029__section1046418314532"><h4 class="sectiontitle">Creating a Table When Sharding Is not Used</h4><p id="ddm_08_0029__p2424172219914">A global sequence can also be specified for an unsharded table, but this function is always ignored. An unsharded table provides auto-increment using auto-increment values of corresponding physical tables.</p>
<p id="ddm_08_0029__p1290771945313">The following is an example statement:</p>
<pre class="screen" id="ddm_08_0029__screen5247648135313">CREATE TABLE single_tb1 (
id bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key id',
name varchar(128),
PRIMARY KEY(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="ddm_08_0003.html">DDL</a></div>
</div>
</div>