常用的Sql语句

1、【插入单行】
insert [into] <表名> (列名) values (列值)
例:insert into Strdents (姓名,性别,出生日期) values ('开心朋朋','男','1980/6/15')


2、【删除<满足条件的>行】
delete from <表名> [where <删除条件>]
例:delete from a where name='开心朋朋'(删除表a中列值为开心朋朋的行)


3、【删除整个表】
truncate table <表名>
truncate table tongxunlu
注意:删除表的所有行,但表的结构、列、约束、索引等不会被删除;不能用语有外建约束引用的表


4、【修改数据】
update <表名> set <列名=更新值> [where <更新条件>]
例:update tongxunlu set 年龄=18 where 姓名='蓝色小名'

5、【查询部分行列--条件查询】
select <列名> from <表名> [where <查询条件表达试>] [order by <排序的列名>[asc或desc]]
例:select i,j,k from a where f=5
说明:查询表a中f=5的所有行,并显示i,j,k3列

6、【左外联接查询】
例:select s.name,c.courseID,c.score from strdents as s left outer join score as c on s.scode=c.strdentID
说明:在strdents表和score表中查询满足on条件的行,条件为score表的strdentID与strdents表中的sconde相同

7、【右外联接查询】
例:select s.name,c.courseID,c.score from strdents as s  right outer join score as c on s.scode=c.strdentID
说明:在strdents表和score表中查询满足on条件的行,条件为strdents表中的sconde与score表的strdentID相同

原文地址:https://www.cnblogs.com/taowd/p/6904823.html