Mysql常见语句-持续更新

#插入数据

insert into shop_market values(1,"家乐福");

#增加列

alter table shop add column market_id int not null default 1;

#in和limit的用法

SELECT * FROM senguocc.coupon_customer where coupon_key in ('000j1C914M2457','001c5C61M1143','001k2C787M1076') limit 2;

 limit 3:记录的前3行

    limt 5,10:记录的6到11行

 limt 4,-1:记录的5到最后一行

#join的用法

SELECT * FROM senguocc.coupon_customer join senguocc.coupon_shop on coupon_customer.coupon_shop_id=coupon_shop.id where coupon_shop.shop_id=272;

#删除列

ALTER TABLE `senguocc`.`chain_charge_type` 
DROP COLUMN `storage`;

#数据库修改编码

alter database db_name CHARACTER SET utf8;
#模糊查询

# 查询名称以梨结束的水果
select * from fruit where name like "%梨"

# 查询名称以梨开头的水果
select * from fruit where name like "梨%"

# 查询名称包含梨字的水果
select * from fruit where name like "%梨%" 



你可能感兴趣的:(个人经验总结,数据库常见操作)