mysql 命令修改字段


  • 命令創建表
     1 create table drive_practice_statistics (
     2     id int(11) not null auto_increment,
     3     uid int(11) not null comment '用戶id',
     4     correct_num smallint(4) not null default 0 comment '用戶答對的題數',
     5     total smallint(4) not null default 0 comment '用戶總的答題數,錯誤答題數=total-correct_num',
     6     mode tinyint(1) not null comment '駕照類型,1:a1,b1;2:a2,b2;3:c1,c2;4:科目四。c1和c2題目一樣,a1和b1題目一樣,a2和b2題目一樣',
     7     addtime int(10) not null default 0,
     8     updatetime int(10) not null default 0,
     9     primary key (id),
    10     key (uid)
    11 )engine=innodb default charset=utf8;
    創建表SQL語句

     

  • 創建表之后,想要添加幾個字段
    alter table drive_cheats add status tinyint(1) not null default 0 comment '是否上架,0:no,1:yes', add is_delete tinyint(1) not null default 0;
    //兩個語句之間使用逗號隔開

     

  • 創建表之后,想要修改某個字段的類型`modify`, 字段的類型不可以省略,即便只是想改一下注釋的內容,類型也要加上
    alter table drive_question modify mode tinyint(1) not null comment '駕照類型,1:a1,b1;2:a2,b2;3:c1,c2;4:科目四。c1和c2題目一樣,a1和b1題目一樣,a2和b2題目一樣';

     

  • 修改某個字段的名稱change


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM