本文實(shí)例講述了mysql語(yǔ)句實(shí)現(xiàn)簡(jiǎn)單的增、刪、改、查操作。分享給大家供大家參考,具體如下:
1、創(chuàng)建db_shop數(shù)據(jù)庫(kù),如果該數(shù)據(jù)庫(kù)不存在則創(chuàng)建
create database if not exists db_shop;
2、刪除數(shù)據(jù)庫(kù),如果該數(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相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《MySQL查詢技巧大全》、《MySQL常用函數(shù)大匯總》、《MySQL日志操作技巧大全》、《MySQL事務(wù)操作技巧匯總》、《MySQL存儲(chǔ)過(guò)程技巧大全》及《MySQL數(shù)據(jù)庫(kù)鎖相關(guān)技巧匯總》
希望本文所述對(duì)大家MySQL數(shù)據(jù)庫(kù)計(jì)有所幫助。
標(biāo)簽:黔西 駐馬店 梅河口 荊門 陜西 昌都 北京 鄂爾多斯
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《mysql語(yǔ)句實(shí)現(xiàn)簡(jiǎn)單的增、刪、改、查操作示例》,本文關(guān)鍵詞 mysql,語(yǔ)句,實(shí)現(xiàn),簡(jiǎn)單,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。