共計(jì) 883 個(gè)字符,預(yù)計(jì)需要花費(fèi) 3 分鐘才能閱讀完成。
自動(dòng)寫代碼機(jī)器人,免費(fèi)開通
mysql 中有哪些增、刪、改、查語句?針對(duì)這個(gè)問題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡(jiǎn)單易行的方法。
1、創(chuàng)建 db_shop 數(shù)據(jù)庫,如果該數(shù)據(jù)庫不存在則創(chuàng)建
create database if not exists db_shop;
2、刪除數(shù)據(jù)庫,如果該數(shù)據(jù)存在就刪除
drop database if exists db_shop;
3、給 db_shop 創(chuàng)建數(shù)據(jù)表
use db_shop;
drop table if exists tb_goods;
CREATE TABLE tb_goods( `goodsId` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`tb_goods`)
);
4、根據(jù)舊表創(chuàng)建新表
create table tb_goods01 like tb_goods;
5、刪除數(shù)據(jù)表
drop table tb_goods01;
6、給一個(gè)表增加一列(一個(gè)字段)
alter tb_goods add column goodsName varchar(255) after goodsId;
注意:不寫 after、before 則默認(rèn)添加到最后
7、刪除字段
alter table tb_goods drop column goodsName;
8、插入數(shù)據(jù)
insert into tb_goods (goodsId,goodsName) values (1002, 商品 1
9、查詢
查詢所有
select * from tb_goods;
查詢特定
select goodsName fromtb_goods;
模糊查找
select * from tb_goods like % 商品 %
10、更新數(shù)據(jù)表
update tb_goods set goodsName= 商品 2
關(guān)于 mysql 中有哪些增、刪、改、查語句問題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注丸趣 TV 行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
向 AI 問一下細(xì)節(jié)
正文完