Help Center/ Data Warehouse Service/ Tool Guide/ DSC/ MySQL Syntax Migrating/ Table (Optional Parameters and Operations)/ LIKE (Table Cloning)
Updated on 2025-04-10 GMT+08:00
LIKE (Table Cloning)
In the MySQL database, you can use the CREATE TABLE .. LIKE .. method to clone the old table structure to create a table. It is also supported by GaussDB(DWS). DSC will add additional table attribute information during migration.
Input
1 2 3 4 5 6 7 8 | CREATE TABLE IF NOT EXISTS `public`.`runoob_tbl_old`( `dataType_1` YEAR, `dataType_2` YEAR(4), `dataType_3` YEAR DEFAULT '2018', `dataType_4` TIME DEFAULT NULL ); CREATE TABLE `runoob_tbl` (like `runoob_tbl_old`); |
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 | CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_old" ( "datatype_1" SMALLINT, "datatype_2" SMALLINT, "datatype_3" SMALLINT DEFAULT '2018', "datatype_4" TIME WITHOUT TIME ZONE DEFAULT NULL ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype_1"); CREATE TABLE "public"."runoob_tbl"( LIKE "public"."runoob_tbl_old" INCLUDING COMMENTS INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING INDEXES INCLUDING STORAGE); |
Parent topic: Table (Optional Parameters and Operations)
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.