forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: luhuayi <luhuayi@huawei.com> Co-committed-by: luhuayi <luhuayi@huawei.com>
9.2 KiB
9.2 KiB
RENAME (Table Renaming)
The statement for renaming a table in MySQL is slightly different from that in GaussDB(DWS). DSC will perform adaptation based on GaussDB(DWS) features during migration.
- MySQL allows you to use the RENAME TABLE statement to change a table name.
Input
1 2 3 4 5
# Rename a single table. RENAME TABLE DEPARTMENT TO NEWDEPT; # Rename multiple tables. RENAME TABLE NEWDEPT TO NEWDEPT_02,PEOPLE TO PEOPLE_02;
Output
1 2 3 4 5 6
-- Rename a single table. ALTER TABLE "public"."department" RENAME TO "newdept"; -- Rename multiple tables. ALTER TABLE "public"."newdept" RENAME TO "newdept_02"; ALTER TABLE "public"."people" RENAME TO "people_02";
- In MySQL, the ALTER TABLE RENAME statement is used to change a table name. When this statement is migrated by DSC, the keyword AS is converted to TO.
Input
1 2 3 4 5
## A. ALTER TABLE runoob_alter_test RENAME TO runoob_alter_testnew; ## B. ALTER TABLE runoob_alter_testnew RENAME AS runoob_alter_testnewnew;
Output
1 2 3 4 5
-- A. ALTER TABLE "public"."runoob_alter_test" RENAME TO "runoob_alter_testnew"; -- B. ALTER TABLE "public"."runoob_alter_testnew" RENAME TO "runoob_alter_testnewnew";
Parent topic: Table (Optional Parameters and Operations)
