您的位置:首页 > 其它

(转自pc0123.com)介绍一下CPU至今为止的发展历程

2008-03-08 20:07 387 查看
[align=center]sql笔记之三:表中数据的操作[/align]
创建了表,那么我们就该对数据进行操作了:
插入数据:insert
插入数据分为几种情况:
1、完全插入:insert into tablename (列1、列2、…..列n) values(表达式1、表达式2、表达式n)
实例:insert into tablename (id,name,sex,age) values(1,’miller’,’male’,21)
列与表达式一一对应,且类型一致。字符型和日期型值用单引号括起来。
2、部分插入:
实例:insert into tablename (name,age) values(’miller’,21)
3、多条插入:
实例:insert into tablename (id,name,sex,age)
values(1,’miller’,’male’,21)
(2,’jim’,’male’,19)
(3,’rose’,’famale’,18)
(4,’jordan’,’male’,21)
……………
4、省略插入:

实例:insert into tablename values(1,’miller’,’male’,21)
(2,’jim’,’male’,19)
(3,’rose’,’famale’,18)
(4,’jordan’,’male’,21)
上面讲的便是几种插入方式,既然数据已经插入了,那么我们也想看看插入后的样子。
查看数据:select
Select的功能很是强大,不是一两句讲完的,简便说说。
查看表中所有数据:select * from tablenam
查看表中指定数据:select id name from tablename where 条件
实例:select id name from players where sex=’male’
便可查询players表中所有性别为男的的id。
在查看之后发现有个数据输入有误,那么我们就应该用下面的语句了:
修改数据:
格式:update tablename set 列1=值1 列2=值2…..where 条件
实例:在players表中id=2的行中改性别为女:
update players set sex=’famale’ where id=2
当一条记录没有存在的意义之后,我们需要删除它:
删除数据:
格式 delete from tablename where 条件
实例:delete from tablename where id=2
说明:删除id=2这一行的数据。from可以省略。
删除全部数据:delete tablename
怎么才能用select语句更好更快的查询呢,结合or、and、is null、is not null、!=来说说这些符号的应用:
Or:
select * from table_name where 条件 or 条件
delete table_name where 条件 or 条件
and:
select * from table_name where 条件 and 条件
delete table_name where 条件 and 条件
is null
select * from table_name where 条件 is null
delete table_name where 条件is null
is not null
select * from table_name where 条件 is not null
delete table_name where 条件is not null
!= :
select * from table_name where 列名!=表达式或值
delete table_name where列名!=表达式或值
本文出自 “diesel的星星之火.” 博客,请务必保留此出处http://diesel.blog.51cto.com/1557620/432381
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: