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

MySQL簡(jiǎn)單操作之a(chǎn)lter table改變表的結(jié)構(gòu)

數(shù)據(jù)庫 MySQL
本文我們主要介紹了一些MySQL數(shù)據(jù)庫的簡(jiǎn)單操作:用alter table來改變表的結(jié)構(gòu)的方法,包括增加列、刪除列、改變列以及改變表的名字等操作,希望能夠?qū)δ兴鶐椭?/div>

我們知道,MySQL數(shù)據(jù)庫常常與PHP結(jié)合來開發(fā)出功能強(qiáng)大的應(yīng)用程序。那么對(duì)于我們初學(xué)PHP編程的人來說,就很有必要了解一些MySQL數(shù)據(jù)庫的簡(jiǎn)單操作了。本文我們對(duì)MySQL數(shù)據(jù)庫使用alter table語句來修改表結(jié)構(gòu)的知識(shí)進(jìn)行了介紹,接下來就讓我們來一起了解一下這部分內(nèi)容。

1. 增加列

alter table tbl_name add col_name type

例如,  給pet的表增加一列 weight,

mysql>alter table pet add weight int;

2. 刪除列

alter table tbl_name drop col_name

例如, 刪除pet表中的weight這一列

mysql>alter table pet drop weight;

3. 改變列

分為改變列的屬性和改變列的名字

改變列的屬性——方法1:

alter table tbl_name modify col_name type

例如,改變weight的類型

mysql>alter table pet modify weight varchar(30);

改變列的屬性——方法2:

alter table tbl_name change old_col_name col_name type

例如,改變weight的類型

alter table pet change weight weight varchar(30);

改變列的名字:

alter table tbl_name change old_col_name col_name

例如改變pet表中weight的名字:

mysql>alter table pet change weight wei;

4. 改變表的名字

alter table tbl_name rename new_tbl

例如, 把pet表更名為animal

mysql>alter table pet rename animal;

關(guān)于MySQL數(shù)據(jù)庫alter table改變表結(jié)構(gòu)的知識(shí)就介紹到這里了,接下來我們還會(huì)介紹一些MySQL數(shù)據(jù)庫的簡(jiǎn)單操作方法,希望本次的介紹能夠?qū)δ兴斋@吧!

【編輯推薦】

  1. MySQL數(shù)據(jù)庫的查詢緩沖機(jī)制
  2. MySQL數(shù)據(jù)庫查詢步驟和緩存原理
  3. MySQL數(shù)據(jù)庫負(fù)荷較高時(shí)的原因排查思路
  4. MySQL數(shù)據(jù)庫中關(guān)于ENUM類型的詳細(xì)解釋
  5. MySQL數(shù)據(jù)庫主從服務(wù)器文檔的部署與切換詳解
責(zé)任編輯:趙鵬 來源: 博客園
相關(guān)推薦

2010-05-18 18:19:40

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

2010-10-13 09:37:48

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

2010-05-18 17:47:28

2010-05-18 17:39:13

MySQL alter

2011-08-24 09:45:14

alter_table中文man

2010-10-13 10:27:35

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

2022-09-21 08:03:45

MySQLtable表結(jié)構(gòu)

2009-08-12 18:35:17

C#數(shù)據(jù)結(jié)構(gòu)

2011-08-11 11:51:39

MySQLselect

2011-07-01 09:17:11

MariaDB

2023-03-28 07:44:23

數(shù)據(jù)結(jié)構(gòu)數(shù)組

2010-05-18 18:11:33

MySQL ALTER

2010-11-23 13:24:16

MySQL MyISA

2010-10-15 10:29:25

Mysql表結(jié)構(gòu)

2010-11-23 12:39:05

MySQL InnoD

2010-06-12 10:10:55

2011-08-16 13:59:42

MySQL初學(xué)者表的操作

2010-11-23 09:13:47

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

2022-08-12 19:13:07

etswifi連接操作

2010-11-23 16:21:07

MySQL大表備份
點(diǎn)贊
收藏

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