doc-exports/docs/dws/tool/dws_16_0152.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

48 lines
2.5 KiB
HTML

<a name="EN-US_TOPIC_0000001819416237"></a><a name="EN-US_TOPIC_0000001819416237"></a>
<h1 class="topictitle1">UNION</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_p4248204901710"><strong id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_b2197346633181">UNION</strong> is a table creation parameter of the MERGE storage engine. Creating a table using this keyword is similar to creating a common view. The created table logically combines the data of multiple tables that are specified by UNION. DSC migrates this feature to the view creation statement in GaussDB.</p>
<p id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_p524954714513"><strong id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_b39993815565">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_screen48015451078">CREATE TABLE t1 (
a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
message CHAR(20)
) ENGINE=MyISAM;
CREATE TABLE t2 (
a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
message CHAR(20)
) ENGINE=MyISAM;
CREATE TABLE total (
a INT NOT NULL AUTO_INCREMENT,
message CHAR(20))
ENGINE=MyISAM UNION=(t1,t2) INSERT_METHOD=LAST;</pre>
<p id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_p12114173518210"><strong id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_b424094218566">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001819416237__en-us_topic_0000001657865594_en-us_topic_0000001385456450_en-us_topic_0214164504_screen1145484581614">CREATE TABLE "public"."t1" (
"a" SERIAL NOT NULL PRIMARY KEY,
"message" CHAR(80)
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("a");
CREATE TABLE "public"."t2" (
a SERIAL NOT NULL PRIMARY KEY,
message CHAR(80)
)
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
NOCOMPRESS
DISTRIBUTE BY HASH ("a");
CREATE VIEW "public"."total"(a, message) AS
SELECT * FROM "public"."t1"
UNION ALL
SELECT * FROM "public"."t2";</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>