程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 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自增字段的常用語句

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved