本文實(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ù)表
6、給一個(gè)表增加一列(一個(gè)字段)
alter tb_goods add column goodsName varchar(255) after goodsId;
注意:不寫(xiě)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 goodsName fromtb_goods;
模糊查找
select * from tb_goods like '%商品%';
10、更新數(shù)據(jù)表
update tb_goods set goodsName='商品2';
更多關(guān)于MySQL相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《MySQL查詢技巧大全》、《MySQL常用函數(shù)大匯總》、《MySQL日志操作技巧大全》、《MySQL事務(wù)操作技巧匯總》、《MySQL存儲(chǔ)過(guò)程技巧大全》及《MySQL數(shù)據(jù)庫(kù)鎖相關(guān)技巧匯總》
希望本文所述對(duì)大家MySQL數(shù)據(jù)庫(kù)計(jì)有所幫助。
您可能感興趣的文章:- PHP+MYSQL實(shí)現(xiàn)用戶的增刪改查
- MySQL中對(duì)于索引的基本增刪查改操作總結(jié)
- mysql增刪改查基礎(chǔ)語(yǔ)句
- Mysql的增刪改查語(yǔ)句簡(jiǎn)單實(shí)現(xiàn)
- nodejs操作mysql實(shí)現(xiàn)增刪改查的實(shí)例
- MySQL的增刪查改語(yǔ)句用法示例總結(jié)
- 自寫(xiě)的利用PDO對(duì)mysql數(shù)據(jù)庫(kù)增刪改查操作類(lèi)
- Mysql表,列,庫(kù)增刪改查問(wèn)題小結(jié)
- PHP實(shí)現(xiàn)基于面向?qū)ο蟮膍ysqli擴(kuò)展庫(kù)增刪改查操作工具類(lèi)
- 利用PHP訪問(wèn)MySql數(shù)據(jù)庫(kù)的邏輯操作以及增刪改查的實(shí)例講解
- MySQL語(yǔ)句整理及匯總介紹