修改mysql字段顺序的方法

如果需要修改mysql字段的顺序,应该怎么做呢?下面就将为您介绍修改mysql字段顺序的方法,原表结构如下:

 
 
 
  1. CREATE TABLE `tb_area_collect_school_week` (                         
  2.                                `id` char(36) NOT NULL,                                            
  3.                                `date_entered` varchar(20) NOT NULL,                               
  4.                                `date_modified` datetime NOT NULL,                                 
  5.                                `assigned_user_id` char(36) default NULL,                          
  6.                                `modified_user_id` char(36) default NULL,                          
  7.                                `created_by` char(36) default NULL,                                
  8.                                `name` varchar(50) NOT NULL,                                       
  9.                                `description` mediumtext,                                          
  10.                                `deleted` tinyint(1) NOT NULL default '0',                         
  11.                                `qy_id` int(10) unsigned NOT NULL auto_increment COMMENT '序号',   
  12.                                `provinces` varchar(50) default NULL COMMENT '省份',               
  13.                                `city` varchar(50) NOT NULL COMMENT '地市',                                                       
  14.                                `school_open_up` int(20) NOT NULL COMMENT '开通学校数',            
  15.                                `school_cover_percent` varchar(50) NOT NULL COMMENT '覆盖率',      
  16.                                `school_count` int(20) NOT NULL COMMENT '学校总数',   
  17.                                `area` varchar(50) default NULL,                 
  18.                                `date` varchar(10) NOT NULL COMMENT '日期',                        
  19.                                `system` varchar(10) default NULL COMMENT '系统',                  
  20.                                PRIMARY KEY USING BTREE (`id`,`qy_id`),                           
  21.                                KEY `provinces` USING BTREE (`provinces`),                         
  22.                                KEY `city` USING BTREE (`city`),                                   
  23.                                KEY `area` USING BTREE (`area`),                                   
  24.                                KEY `date` USING BTREE (`date`),                                   
  25.                                KEY `SYSTEM` (`system`)                                            
  26.                              ) ENGINE=MyISAM DEFAULT CHARSET=gbk  

原来表结构是这样,现在要表结构变成

 
 
 
  1. CREATE TABLE `tb_area_collect_school_week` (                          
  2.                                `id` char(36) NOT NULL,                                             
  3.                                `date_entered` varchar(20) NOT NULL,                                
  4.                                `date_modified` datetime NOT NULL,                                  
  5.                                `assigned_user_id` char(36) default NULL,                           
  6.                                `modified_user_id` char(36) default NULL,                           
  7.                                `created_by` char(36) default NULL,                                 
  8.                                `name` varchar(50) NOT NULL,                                        
  9.                                `description` mediumtext,                                           
  10.                                `deleted` tinyint(1) NOT NULL default '0',                          
  11.                                `qy_id` int(10) unsigned NOT NULL auto_increment COMMENT '序号',   
  12.                                `provinces` varchar(50) default NULL COMMENT '省份',                
  13.                                `city` varchar(50) NOT NULL COMMENT '地市',                         
  14.                                `area` varchar(50) default NULL,                                    
  15.                                `school_open_up` int(20) NOT NULL COMMENT '开通学校数',             
  16.                                `school_cover_percent` varchar(50) NOT NULL COMMENT '覆盖率',       
  17.                                `school_count` int(20) NOT NULL COMMENT '学校总数',                 
  18.                                `date` varchar(10) NOT NULL COMMENT '日期',                         
  19.                                `system` varchar(10) default NULL COMMENT '系统',                   
  20.                                PRIMARY KEY USING BTREE (`id`,`qy_id`),                            
  21.                                KEY `provinces` USING BTREE (`provinces`),                          
  22.                                KEY `city` USING BTREE (`city`),                                    
  23.                                KEY `area` USING BTREE (`area`),                                    
  24.                                KEY `date` USING BTREE (`date`),                                    
  25.                                KEY `SYSTEM` (`system`)                                             
  26.                              ) ENGINE=MyISAM DEFAULT CHARSET=gbk   
  27.  

修改mysql字段顺序的方法:

 
 
 
  1. ALTER TABLE `tb_area_collect_school_week` CHANGE `area` `area` VARCHAR(50) AFTER `city` ;  

【编辑推荐】

mysql添加删除主键的方法

MySQL修改密码的六种方法

linux下的常用mysql命令

九种常用mysql命令

MySQL自增字段的常用语句

名称栏目:修改mysql字段顺序的方法
网站URL:http://www.shufengxianlan.com/qtweb/news9/347509.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联