sql学习(一)sql基础,以sql server数据库为例
来源:互联网 发布:免费杂志阅读软件 编辑:程序博客网 时间:2024/06/05 17:33
根据w3c学习
SQL简介:SQL是用于访问和处理数据库的标准的计算机语言
注意:SQL对大小写不敏感
select * from student where name='zhangsan'
1.SELECT语句用来从表中选取数据,结果被存储到结果表中(结果集)
select 列名 from 表名;
或
select * from 表名;
其中‘*’代表所有的列
select * from student
2.DISTINCT 用于返回唯一不同的值
select DISTINCT name from student where name='zhangsan'
3.where 用来规定选择的标准
select 列名 from 表名 where 列 运算符 值
select * from student where name='zhangsan' and age>300
select * from student where age between 213 and 456;
包括213和456
注意:文本用单引号,数字不用引号
4.and & or 基于一个以上的条件对记录进行过滤
select * from student where name='lisi' or name='zhangsan';
显示name为zhangsan或者为lisi的
select * from student where name='zhangsan' and age=213;
显示name为zhangsan并且age为213的
select * from student where name='zhangsan' and (age=213 or age=456)
5.order by 用于对结果集进行排序
select * from student order by age desc;
根据age倒序排列
select * from student order by age asc;
select * from student order by age;
根据age顺序排列
select * from student order by name desc,age asc;
name按字母倒序排列,并且age按顺序排列
6.insert into 向表格中插入新的行
语法:
insert into 表名 values (值1,值2,值3,...);
insert into 表名 (列1,列2,列3,...) values (值1,值2,值3,...);
例子
insert into student values (3,'lisi',44);
insert into student (id,name,age) values (3,'lisi',44);
7.update 修改表中的数据
update 表名 set 列名=新值 where 列名=某值;
update student set name='liuliu',age=20 where name='lisisi';
8.delete 删除表中的行
删除某行:
delete from 表名 where 列名=某值;
delete from student where name='lisi';
删除所有行:
再不删除表的情况下,删除所有的行,意味着表的结构,属性,索引都是完整的
delete from 表名;
delete * from 表名;
- sql学习(一)sql基础,以sql server数据库为例
- Java连接数据库(以Sql Server为例)
- C#实现数据库备份(以Sql Server为例)
- sql语句基础要点(以sql server 2008 为例)
- 【PB】配置外源数据库(以SQL Server为例)
- SQL Server 基础(一)
- SQL Server基础(一)
- SQL server 2000数据库基础编程(一)
- sql server 数据库基础
- SQL Server数据库基础
- SQL Server 数据库基础
- SQL server数据库基础
- sql数据库学习系列一之SQL Server 数据库设计
- SQL基础学习(一)- SQL 简介
- 学习记录之--SQL Server 数据库学习笔记(一)
- SQL Server 2005学习之T-SQL数据库设计一
- SQL Server学习一
- 远程连接SQL Server (以sql server2008 Express为例)
- js 时间与时间戳的转换
- 通过NTP协议进行时间同步
- 697. Degree of an Array
- javaScript中的类与对象,引用,原型,原型链的定义
- CentOS 7 下sudo: update-grub: command not found
- sql学习(一)sql基础,以sql server数据库为例
- 循环链表(约瑟夫问题的衍生问题)
- iPhone X 为啥弃 TouchID?
- Python-爬取网页信息
- 使用Eclipse构建Spark Java集成开发环境
- Java设计之日期格式的转换
- 一位资深程序员大牛给予Java初学者的学习路线建议
- python实现QR法解线性方程组
- 关于java中如何复制字节数组