ITPub博客

首页 > 数据库 > MySQL > 3、增删改查语句介绍

3、增删改查语句介绍

原创 MySQL 作者:cxmfyl 时间:2015-01-26 08:55:03 0 删除 编辑
    
增删改查
set names gbk;    //解决字符集问题,默认建表是utf8,cmd窗口是gbk字符集
create table msg (
id int,
title varchar(60),
name varchar(10),
content varchar(1000)
);

# 增 insert :
    //插入一行
insert into msg 
values
(5,'出来乍到','张飞','蛇矛');
    //插入多行
insert into msg  
values
(1,'出来乍到','张三','刚来能不能当老大'),
(2,'出来乍到','李四','刚来能不能当老大'),
(3,'出来乍到','刘备','雌雄'),
(4,'出来乍到','关羽','青龙'),
(5,'出来乍到','张飞','蛇矛')
;

# 删 delete:
delete from msg where id = 1;    删除特定行。
delete from msg ;    删除所有行。

# 改 update :
update msg 
set id = 2,
content = '爬上三大闪电了'
where 
name = '张三' ;

# 查select :
select  * from msg;    所有行,所有列
select id,title from  msg;    所有行,部分列
select * from msg  where id > 1;    部分行,所有列
select id,title from msg  where id > 1;    部分行,部分列


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24103417/viewspace-1415095/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2015-01-26

  • 博文量
    5
  • 访问量
    4662