修改mysql字段顺序的方法

数据库 MySQL
下文对修改mysql字段顺序的方法进行了介绍,如果您在修改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自增字段的常用语句

责任编辑:段燃 来源: 互联网
相关推荐

2010-11-23 15:27:00

MySQL添加字段

2010-09-28 14:46:45

SQL Xml字段

2010-10-08 09:17:06

mysql修改字段

2010-05-04 15:49:24

Oracle修改

2010-10-14 11:48:20

MySQL账户密码

2011-05-18 14:00:44

MySQL默认密码

2010-05-18 09:40:01

MySQL修改表字段

2010-10-13 10:03:08

MySQL修改表结构

2011-07-13 13:39:46

CHARINDEXSqlServer

2010-05-18 17:24:44

MySQL修改表字段

2010-09-28 11:38:26

sql字段

2010-11-23 09:13:47

mysql修改表结构

2010-10-08 15:42:39

MySQL设置自增字段

2022-01-10 06:52:59

查询MySQL字段

2010-11-25 16:40:11

MySQL大表重复字段

2010-11-24 11:52:15

MYSQL表字段最大值

2010-05-18 17:17:02

MySQL数据表

2010-02-04 11:02:54

2010-10-14 11:52:38

MySQL字符集

2020-07-16 08:33:38

ViewGroupView
点赞
收藏

51CTO技术栈公众号