SQL学习一
来源:互联网 发布:魔兽世界5.4.8数据库 编辑:程序博客网 时间:2024/06/05 17:06
sql大小写不敏感
select:
select * from 表名
select 列 from 表名
distinct :
select distinct 列 from 表名
where:
select 列 from 表名 where 列 操作符 值
where子句中使用
select * from persons where city = 'bj‘
SQL 使用单引号来环绕文本值(大部分数据库系统也接受双引号)。如果是数值,不要使用引号。
between and:
select distinct need from type where id between 10 and 15(包含情况视数据库而定)
select distinct need from type where id not between 10 and 15
select distinct need from type where name between 'abd' and 'c'
like:
select distinct need from type where name like '%d'(d结尾)
select distinct need from type where name like 'd%'(d开头)
select distinct need from type where name like '%d%'(包含d)
select distinct need from type where name not like '%d%'(包含d)
order by:
select distinct need from type order by id desc
select distinct need from type order by id asc,name desc(在第一列中有相同的值时,第二列是以升序排列的。如果第一列中有些值为 nulls 时,情况也是这样的。)
insert into:
insert into 表名 values(值1,值2,...)
insert into 表名 (列1,列2,...)values(值1,值2,...)
update:
语句用于修改表中的数据。
update 表名 set 列名 = 新值,列名 = 新值 where 列名 = 某值
delete:
语句用于删除表中的行。
delete from 表名 where 列名 = 值
delete from 表名 (删除所有行)
Top:
用于规定要返回的记录的数目。
select 列名 from 表名 limit 数目
通配符:
SQL 通配符必须与 LIKE 运算符一起使用。
[^charlist]
或者
[!charlist]
不在字符列中的任何单一字符select * from persons where city like 'n%'
select * from persons where city like '%n%'
select * from persons where city like '_nv'
select * from persons where city like '_nv_n_d'
in:
操作符允许我们在 WHERE 子句中规定多个值。
select * from persons where city in ('a','b')
alter table:
语句用于在已有的表中添加、修改或删除列。
alter table 表名 add 列名 数据类型
alter table 表名 drop column 列名
function:
count(*)获取数目,可以和where 组合
count(列名),count(distinct 列名)
- SQL学习笔记(一)
- SQL语法学习一
- SQL学习笔记(一)
- PL/SQL学习一
- SQl学习(一)
- 学习sql历程一
- T-SQL 学习(一)
- SQL学习一
- oracle sql学习一
- SQL学习(一)
- SQL Server学习一
- SQL语句学习一
- SQL注入学习一
- PL/SQL学习笔记一
- SQL SERVER学习笔记一
- my sql 学习一: 常用命令
- PL/SQL学习笔记一
- SQL学习总结(一)
- inet_ntoa、 inet_aton、inet_addr 详细介绍
- 关于IP网络号和主机号的原理
- Linux md5sum命令的使用
- 黑马程序员--反射
- Plus One
- SQL学习一
- mysql 中的内置函数
- java 读取文件路径中空格和中文的处理.. this.class.getResource
- codeforces-#478C. Table Decorations
- When would someone use Apache Tez instead of Apache Spark, or vice versa?
- swift-数组array
- CI框架提交表单时出现 Disallowed Key Characters 错误提示
- 曾国藩读书的十二条规矩
- STM32串口中断接收方式详细比较