Updated on 2025-10-14 GMT+08:00

RENAME (Table Renaming)

The RENAME statements for tables in MySQL are slightly different from those in DWS. DSC will perform adaptation based on DWS features during migration.

Currently, DSC does not support original table names prefixed with DATABASE/SCHEMA.

  1. 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";
    
  2. 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";