Oracle 数据库管理系统
1).数据库简介
数据仓库,数据管理软。Oracle通过用户的不同权限管理数据库
优点:
支持数据类型
文件储存安全
支持多用户访问
支持数据量大
服务:(以实例orcl)
OracleServiceOrcl Oracle核心服务
OracleORCLTNSLinstener Oracle接受外部访问的服务
Oracle常用客户端:
①SQL PLUS
②iSQL PLUS (http://localhost:1158/em)
③第三方客户端 例如:PLSQL 、Navicat
2).sql – 简单查询、去重、排序、条件查询
Structure Query Language
①. 简单查询
名词:表(Table), 字段(Column), 行(Row), 主键(Primary key), 用户(Account)
语法:select 列名1,列名2,… from 表;
a, 查询部分列:
select 字段1,字段2 from 表;
b, 查询所有列:
select 字段1,… 字段n from 表; (实际开发应用,可读性好)
select * from 表;
c, 查询结果的字段重命名(别名)
select 列名1 as 别名1,列名2 as 别名2 from 表;
d, 对查询结果进行字符串拼接(‘||’)
select first_name || ‘·’ || last_name from employees;
e, 对查询的结果做算术运算(+ - * /)
select salary * 10 from employees;
f, 增加筛选条件
select salary form employees where employee_id = 100;
②. 去重
select distinct 列名 from 表;
③. 排序
select * from 表 order by 字段1 asc/desc,字段2 asc/desc; (先对字段1排序,如果相同,再对字段2排序)
④. 条件查询
a, 等值查询
select * form employees where salary = 7000;
b, 多条件查询
select * form employees where employee_id = 100 and salary = 7000;
select * form employees where salary = 2300 or salary = 7000;
c, 不等值查询(逻辑判断:> < >= <= <>不等于 !=不等于)
select * from employees where salary > 1000;
d, 区间查询( 闭区间 [临近小值, 临近大值] )
select * from employees where salary >= 1000 and salary <= 10000;
select * from employees where salary between 1000 and 10000;
e, is null 、is not null
select * form employees where commission_pct is null;
select * form employees where commission_pct is not null;
f, 枚举查询(in)
select * from employees where employee_id in(100, 103, 104);
也可以用or语句
g, 模糊查询 (like 、 not like ) 、(‘_’占位符, ‘%’通配符)
select * from employees where first_name is not like ‘%L%’; (名字不含L)
select * from employees where first_name is like ‘_ _ _ _%’; (名字长度至少是4)