共計(jì) 1810 個(gè)字符,預(yù)計(jì)需要花費(fèi) 5 分鐘才能閱讀完成。
自動(dòng)寫(xiě)代碼機(jī)器人,免費(fèi)開(kāi)通
這篇文章主要介紹了怎么修改 mysql 數(shù)據(jù)庫(kù)表結(jié)構(gòu),具有一定借鑒價(jià)值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓丸趣 TV 小編帶著大家一起了解一下。
修改 mysql 數(shù)據(jù)庫(kù)表結(jié)構(gòu)的方法:1、查看表結(jié)構(gòu);2、添加列;3、刪除列,代碼為【mysql alter table student drop column birthday】;4、修改列,代碼為【mysql alter table】。
修改 mysql 數(shù)據(jù)庫(kù)表結(jié)構(gòu)的方法:
1、查看表結(jié)構(gòu)
mysql show create table student;
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| student | CREATE TABLE `student` ( `ID` int(11) NOT NULL AUTO_INCREMENT,
`NAME` varchar(20) NOT NULL,
`AGE` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.09 sec)
2、添加列
mysql alter table student add column birthday datetime;
Query OK, 0 rows affected (2.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
3、刪除列
mysql alter table student drop column birthday;
Query OK, 0 rows affected (0.80 sec)
Records: 0 Duplicates: 0 Warnings: 0
4、修改列
--1. 修改列的類(lèi)型
mysql alter table student modify age int not null;
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
--2. 修改列的名稱(chēng)
mysql alter table student change column name sname varchar(20);
Query OK, 0 rows affected (1.31 sec)
Records: 0 Duplicates: 0 Warnings: 0
感謝你能夠認(rèn)真閱讀完這篇文章,希望丸趣 TV 小編分享怎么修改 mysql 數(shù)據(jù)庫(kù)表結(jié)構(gòu)內(nèi)容對(duì)大家有幫助,同時(shí)也希望大家多多支持丸趣 TV,關(guān)注丸趣 TV 行業(yè)資訊頻道,遇到問(wèn)題就找丸趣 TV,詳細(xì)的解決方法等著你來(lái)學(xué)習(xí)!
向 AI 問(wèn)一下細(xì)節(jié)
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!