next up previous contents
Next: 實機操作練習題 Up: ALTER 語法 Previous: SET DEFAULT 設定預設值   Contents   DYWANG_HOME

RENAME 重新命名

  1. ALTER RENAME TO 變更資料表 tbl 名稱為 atbl。
    mariadb root@localhost:dyw> alter table tbl rename atbl;                        
    You're about to run a destructive command.
    Do you want to proceed? (y/n): y
    Your call!
    Query OK, 0 rows affected
    Time: 0.059s
    
  2. 再查看資料表。
    mariadb root@localhost:dyw> show tables;                                        
    +---------------+
    | Tables_in_dyw |
    +---------------+
    | atbl          |
    | dcount        |
    +---------------+
    2 rows in set
    Time: 0.024s
    
  3. ALTER RENAME TO 再將資料表 atbl 名稱變更回 tbl。
    mariadb root@localhost:dyw> alter table atbl rename tbl;                        
    You're about to run a destructive command.
    Do you want to proceed? (y/n): y
    Your call!
    Query OK, 0 rows affected
    Time: 0.080s
    
  4. 再查看資料表。
    mariadb root@localhost:dyw> show tables;                                        
    +---------------+
    | Tables_in_dyw |
    +---------------+
    | dcount        |
    | tbl           |
    +---------------+
    2 rows in set
    Time: 0.020s
    



De-Yu Wang 2020-04-07