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