自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL添加字段和刪除字段

數(shù)據(jù)庫 MySQL
在MySQL數(shù)據(jù)庫中,對字段進(jìn)行添加或者刪除等操作是很常見的操作,下文對添加字段和刪除字段的語句寫法作了詳盡的闡述,供您參考。

MySQL添加字段應(yīng)該如何實(shí)現(xiàn)呢?這是很多剛剛接觸MySQL數(shù)據(jù)庫的新人都提到過的問題,下面就為您介紹MySQL添加字段和刪除字段的方法,希望對您能有所啟迪。

MySQL添加字段:

  1. alter table `user_movement_log`   
  2. Add column GatewayId int not null default 0 AFTER `Regionid` (在哪個字段后面添加)  
  3.  

刪除字段:

  1. alter table `user_movement_log` drop column Gatewayid  
  2.  

調(diào)整字段順序:

  1. ALTER TABLE `user_movement_log` CHANGE `GatewayId` `GatewayId` int not null default 0 AFTER RegionID  
  2.  
  3. //主鍵  
  4.  
  5. alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);//增加一個新列  
  6.  
  7. alter table t2 add d timestamp;  
  8. alter table infos add ex tinyint not null default '0';//刪除列  
  9.  
  10. alter table t2 drop column c;//重命名列  
  11.  
  12. alter table t1 change a b integer;  
  13. //改變列的類型  
  14.  
  15. alter table t1 change b b bigint not null;  
  16. alter table infos change list list tinyint not null default '0';  
  17. //重命名表  
  18.  
  19. alter table t1 rename t2;加索引  
  20.  
  21. mysql> alter table tablename change depno depno int(5) not null;  
  22. mysql> alter table tablename add index 索引名 (字段名1[,字段名2 …]);  
  23. mysql> alter table tablename add index emp_name (name);加主關(guān)鍵字的索引  
  24.  
  25. mysql> alter table tablename add primary key(id);加***限制條件的索引  
  26.  
  27. mysql> alter table tablename add unique emp_name2(cardnumber);刪除某個索引  
  28.  
  29. mysql>alter table tablename drop index emp_name;修改表:  
  30.  

增加字段:

  1. mysql> ALTER TABLE table_name ADD field_name field_type;修改原字段名稱及類型:  
  2.  
  3. mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;刪除字段:  
  4.  
  5. mysql> ALTER TABLE table_name DROP field_name;  

 

 

 

 

【編輯推薦】

MySQL定義外鍵的方法

詳解MySQL中SlowLog的實(shí)際配置

帶您深入了解MYSQL字符串連接

MySQL字段類型簡介

Mysql外鍵用法分析

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-11-23 15:27:00

MySQL添加字段

2010-10-13 10:03:08

MySQL修改表結(jié)構(gòu)

2010-09-01 15:59:44

SQL刪除字段

2010-09-03 11:16:54

SQL刪除

2010-10-08 10:37:00

MYSQL添加新字段

2010-09-02 09:29:02

SQL刪除字段

2010-09-01 17:13:07

SQL刪除約束

2010-11-22 11:55:23

MySQL字段

2010-11-22 10:57:22

MySQL字段類型

2011-08-25 11:22:39

SQL Server數(shù)據(jù)庫字段說明

2010-09-28 15:07:14

SQL語句

2009-07-22 08:34:47

Scala方法和字段

2021-06-06 13:03:53

MySQL普通索引

2010-11-22 12:59:30

MySQL字段

2010-11-22 12:14:55

MySQL字段

2009-07-21 12:24:01

Scala先決條件添加字段

2010-10-08 14:59:00

MySql字段

2010-11-22 10:29:42

MySQL字段自增長

2010-10-08 09:17:06

mysql修改字段

2010-09-16 15:56:15

SQL Server表
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號