
Oracle
深圳后海没有海
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
单表查询
1.对于日期型数据, 做 *, / 运算不合法:select sysdate,sysdate -1 from dual; select 5/2 from dual; 2.5 2.空值是未指定的或不可预知的值,空值不是0或者空格,凡是空值参与的运算,结果都为空 3.列的别名:别名如果由两个单词构成,中间有空格,必须加上双引号 select employee_id id,12*salary “ann...原创 2019-09-21 10:36:47 · 158 阅读 · 0 评论 -
连接查询
(多表查询一定要考虑左外连接、右外连接的问题) 内连接:合并具有同一列的两个以上的表的行, 结果集中不包含一个表与另一个表不匹配的行 1.等值连接:连接n个表,至少需要n-1个连接条件 同时查询三表数据: from employees e,departments d,locations l where e.department_id = d.department_id and d.location...原创 2019-09-21 10:37:19 · 118 阅读 · 0 评论 -
子查询
子查询在主查询之前一次执行完成,子查询的结果被主查询使用 1.单行子查询: 查询各部门中工资比本部门平均工资高的员工的员工号, 姓名和工资 select employee_id,last_name,salary from employees e1 where salary > ( select avg(salary) from employees e2 where e1.department...原创 2019-09-21 10:37:52 · 170 阅读 · 0 评论 -
查询的其他知识
SET 操作符: 以UNION操作符的使用举例: 1.如果有别名,在上面的表加别名来显示,在下面的表加别名上面的表无法显示别名 2.排序的三种方式:别名排序,相对位置排序,列名排序 使用相对位置排序: select ‘study at’ as “My Dream”,2 from dual union select ‘I want to’,1 from dual union select ‘atg...原创 2019-09-21 10:39:01 · 220 阅读 · 0 评论 -
其他对象-序列
1).创建序列seq_employee,该序列每次取的时候它会自动增加,从1开始计数,不设最大值,并且一直累加,不循环。 create sequence seq_employee increment by 1 start with 1 nomaxvalue(maxvalue 100,minvalue 10) nocycle(cycle) (nocache,cache) 2).什么是序列?序列的作用...原创 2019-09-21 10:33:08 · 133 阅读 · 0 评论 -
视图
1).创建没有分组函数的视图? create view empview as select employee_id,last_name,salary from employees where employee_id = 80 视图的数据的增删改查操作与表相同,并且视图的数据的增删改查会在基表中体现 2).创建包含分组函数的视图? 分组函数必须取名字 create or replace view e...原创 2019-09-21 10:33:50 · 102 阅读 · 0 评论 -
DML数据处理
(1)INSERT语句: 1.一次只能向表中插入一条数据: create table emp1 as select employee_id,last_name,hire_date,salary from employees where 1=3 insert into emp1 values(1001,‘AA’,sysdate,10000) insert into emp1 values(1002,...原创 2019-09-21 10:39:31 · 257 阅读 · 0 评论 -
DDL操作
新增表,重命名表,删除表,清空表 追加新列,重命名列,删除列,修改原有列 (1)CREATE TABLE语句: 表名和列名的命名规则: 必须以字母开头 必须在 1–30 个字符之间 必须只能包含 A–Z, a–z, 0–9, _, $, 和 # 必须不能和用户定义的其他对象重名 必须不能是Oracle 的保留字 1.创建表的第一种方式(白手起家): 为空表,没有任何数据 create table ...原创 2019-09-21 10:40:34 · 661 阅读 · 0 评论 -
plsql的使用
plsql的使用 1).每次运行plsql,都必须运行的语句,否则没有结果? set serveroutput on 2).plsql都有那些标识符? 变量:V_name,常量:C_name,异常标识:E_name 游标变量:name_cursor,记录类型:name_record 3).plsql 的语法规则? –declare –声明的变量、类型、游标 begin dbms_output.pu...原创 2019-09-21 10:31:16 · 601 阅读 · 0 评论