1、cmd登录自己电脑上的mysql,mysql -u用户名 -p密码;
cmd登录其他电脑上的mysql,mysql -h主机地址 -P端口 -u用户名 -p密码。
2、修改字段数据类型
alter table t_defect_type_dic modify column id int;
3、创建表单时,如果主键没有设置成自动递增,后续无法修改成自动递增,只能重新创建表单。
4、创建表单t_defect_type_dic_2
create table t_defect_type_dic_2(
id int unsigned unique primary key not null auto_increment,
defect_code tinyint(1) DEFAULT NULL COMMENT '缺陷类型编码',
defect_name varchar(255) DEFAULT NULL COMMENT '缺陷类型名称');
5、删除表单t_defect_type_dic
drop table t_defect_type_dic;
6、修改表单名称
alter table t_defect_type_dic_2 rename to t_defect_type_dic;
7、删除字段
alter table t_defect_type_dic drop column id;
8、添加字段
alter table t_defect_type_dic add column id int primary key not null auto_increment;
9、移动字段位置
# id放在defect_code后面
alter table t_defect_type_dic modify id int after defect_code;
# defect_code放在id后面
alter table t_defect_type_dic modify defect_code tinyint after id;