1.登录数据库 >mysql -u root -p 数据库名称 2.查询所有数据表 >show tables; 3.查询表的字段信息 >desc 表名称; 4.1.修改某个表的字段类型及指定为空或非空 >alter table 表名称 change 字段名称 字段名称 字段类型 [是否允许非空]; >alter table 表名称 modify 字段名称 字段类型 [是否允许非空]; 4.2.修改某个表的字段名称及指定为空或非空 >alter table 表名称 change 字段原名称 字段新名称 字段类型 [是否允许非空]; 例如: 修改表expert_info中的字段birth,允许其为空 >alter table expert_info change birth birth varchar(20) null;
mysql> alter table t_news change content content text; //将content的属性改为text类型 Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
|