如果需要修改mysql字段的顺序,应该怎么做呢?下面就将为您介绍修改mysql字段顺序的方法,原表结构如下:
- CREATE TABLE `tb_area_collect_school_week` (
- `id` char(36) NOT NULL,
- `date_entered` varchar(20) NOT NULL,
- `date_modified` datetime NOT NULL,
- `assigned_user_id` char(36) default NULL,
- `modified_user_id` char(36) default NULL,
- `created_by` char(36) default NULL,
- `name` varchar(50) NOT NULL,
- `description` mediumtext,
- `deleted` tinyint(1) NOT NULL default '0',
- `qy_id` int(10) unsigned NOT NULL auto_increment COMMENT '序号',
- `provinces` varchar(50) default NULL COMMENT '省份',
- `city` varchar(50) NOT NULL COMMENT '地市',
- `school_open_up` int(20) NOT NULL COMMENT '开通学校数',
- `school_cover_percent` varchar(50) NOT NULL COMMENT '覆盖率',
- `school_count` int(20) NOT NULL COMMENT '学校总数',
- `area` varchar(50) default NULL,
- `date` varchar(10) NOT NULL COMMENT '日期',
- `system` varchar(10) default NULL COMMENT '系统',
- PRIMARY KEY USING BTREE (`id`,`qy_id`),
- KEY `provinces` USING BTREE (`provinces`),
- KEY `city` USING BTREE (`city`),
- KEY `area` USING BTREE (`area`),
- KEY `date` USING BTREE (`date`),
- KEY `SYSTEM` (`system`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gbk
原来表结构是这样,现在要表结构变成
- CREATE TABLE `tb_area_collect_school_week` (
- `id` char(36) NOT NULL,
- `date_entered` varchar(20) NOT NULL,
- `date_modified` datetime NOT NULL,
- `assigned_user_id` char(36) default NULL,
- `modified_user_id` char(36) default NULL,
- `created_by` char(36) default NULL,
- `name` varchar(50) NOT NULL,
- `description` mediumtext,
- `deleted` tinyint(1) NOT NULL default '0',
- `qy_id` int(10) unsigned NOT NULL auto_increment COMMENT '序号',
- `provinces` varchar(50) default NULL COMMENT '省份',
- `city` varchar(50) NOT NULL COMMENT '地市',
- `area` varchar(50) default NULL,
- `school_open_up` int(20) NOT NULL COMMENT '开通学校数',
- `school_cover_percent` varchar(50) NOT NULL COMMENT '覆盖率',
- `school_count` int(20) NOT NULL COMMENT '学校总数',
- `date` varchar(10) NOT NULL COMMENT '日期',
- `system` varchar(10) default NULL COMMENT '系统',
- PRIMARY KEY USING BTREE (`id`,`qy_id`),
- KEY `provinces` USING BTREE (`provinces`),
- KEY `city` USING BTREE (`city`),
- KEY `area` USING BTREE (`area`),
- KEY `date` USING BTREE (`date`),
- KEY `SYSTEM` (`system`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gbk
修改mysql字段顺序的方法:
- ALTER TABLE `tb_area_collect_school_week` CHANGE `area` `area` VARCHAR(50) AFTER `city` ;
【编辑推荐】