MySQL 表的操作

創(chuàng)建表

create table table-name(
id int not null auto_increment primary key comment 'id'
name varchar(10) not null comment '名字',
email varchar(20) not null comment '電子郵件'
);

查看所有表

show tables

查看表結(jié)構(gòu)

desc table_name

查看表狀態(tài)

show table status

刪除一個(gè)表

drop table table_name

添加一個(gè)字段

alter table table_name add 字段名 int(10) not null

刪除一個(gè)字段

alter table table_name drop column 字段

修改字段類型

alter table table_name modify 字段 varchar(15) null

更新表中的數(shù)據(jù)

update table_name set 字段 = ' '

刪除表的所有行

delete from table_name

刪除表并重新創(chuàng)建表結(jié)構(gòu)

truncate table_name

插入數(shù)據(jù)

insert into table_name values ( )

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容