next up previous contents
Next: DROP 刪除 Up: ALTER 語法 Previous: MODIFY 修改   Contents   DYWANG_HOME

CHANGE 改變

  1. CHANGE 同時改變資料表 tbl 欄位 ti 的名稱及格式,由原 ti 格式 TINYINT 改成 bi 格式 bigint。
    mariadb root@localhost:dyw> alter table tbl change ti bi bigint;                
    You're about to run a destructive command.
    Do you want to proceed? (y/n): y
    Your call!
    Query OK, 4 rows affected
    Time: 0.155s
    
  2. 再查看資料表 tbl 的欄位格式。
    mariadb root@localhost:dyw> show columns from tbl;                              
    +-----------------+--------------+------+-----+---------+----------------+
    | Field           | Type         | Null | Key | Default | Extra          |
    +-----------------+--------------+------+-----+---------+----------------+
    | bi              | bigint(20)   | YES  |     | <null>  |                |
    | id              | int(11)      | NO   | PRI | <null>  | auto_increment |
    | c               | char(10)     | YES  |     | <null>  |                |
    | title           | varchar(100) | NO   |     | <null>  |                |
    | author          | varchar(40)  | NO   |     | <null>  |                |
    | submission_date | date         | YES  |     | <null>  |                |
    +-----------------+--------------+------+-----+---------+----------------+
    
    6 rows in set
    Time: 0.026s
    



De-Yu Wang 2020-04-07