本文實例講述了mysql語句實現(xià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ù)表
6、給一個表增加一列(一個字段)
alter tb_goods add column goodsName varchar(255) after goodsId;
注意:不寫after、before則默認添加到最后
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)容感興趣的讀者可查看本站專題:《MySQL查詢技巧大全》、《MySQL常用函數(shù)大匯總》、《MySQL日志操作技巧大全》、《MySQL事務操作技巧匯總》、《MySQL存儲過程技巧大全》及《MySQL數(shù)據(jù)庫鎖相關(guān)技巧匯總》
希望本文所述對大家MySQL數(shù)據(jù)庫計有所幫助。
您可能感興趣的文章:- PHP+MYSQL實現(xiàn)用戶的增刪改查
- MySQL中對于索引的基本增刪查改操作總結(jié)
- mysql增刪改查基礎語句
- Mysql的增刪改查語句簡單實現(xiàn)
- nodejs操作mysql實現(xiàn)增刪改查的實例
- MySQL的增刪查改語句用法示例總結(jié)
- 自寫的利用PDO對mysql數(shù)據(jù)庫增刪改查操作類
- Mysql表,列,庫增刪改查問題小結(jié)
- PHP實現(xiàn)基于面向?qū)ο蟮膍ysqli擴展庫增刪改查操作工具類
- 利用PHP訪問MySql數(shù)據(jù)庫的邏輯操作以及增刪改查的實例講解
- MySQL語句整理及匯總介紹