随笔分类 -  oracle

1
摘要:解决方法如下:=========================================================SQL> select session_id from v$locked_object;SESSION_ID---------- 56SQL> SELECT s... 阅读全文
posted @ 2015-05-18 15:14 领导来根辣条 阅读(233) 评论(0) 推荐(0)
摘要:declare --定义游标, 因为需要对游标定义的数据进行修改操作, 所以添加了 for update 子句 cursor sal_cursor(dept_id number) is select salary sal from employees where dep... 阅读全文
posted @ 2015-05-17 23:57 领导来根辣条 阅读(1063) 评论(0) 推荐(0)
摘要:------------------------------------------------触发器 begin---------------------------------29. 触发器的 helloworld: 编写一个触发器, 在向 emp 表中插入记录时, 打印 'helloworl... 阅读全文
posted @ 2015-05-17 23:24 领导来根辣条 阅读(216) 评论(0) 推荐(0)
摘要:------------------------------------------------存储过程 begin---------------------------------27. 定义一个存储过程: 获取给定部门的工资总和(通过 out 参数), 要求, 部门号和工资总额定义为参数cre... 阅读全文
posted @ 2015-05-17 21:21 领导来根辣条 阅读(186) 评论(0) 推荐(0)
摘要:------------------------------------------------函数 begin---------------------------------22. 函数的 helloworld: 返回一个 "helloworld--!" 的字符串create or repla... 阅读全文
posted @ 2015-05-17 21:20 领导来根辣条 阅读(132) 评论(0) 推荐(0)
摘要:-----------------------------------oracle语法练习 begin-----------------------------------------0. 准备工作:set serveroutput onhellowrold 程序begindbms_output.... 阅读全文
posted @ 2015-05-17 20:48 领导来根辣条 阅读(262) 评论(0) 推荐(0)
摘要:-----------------------------游标 begin-----------------------------------------12. 使用游标要求: 打印出 80 部门的所有的员工的工资: salary: xxxdeclare --1. 定义游标 cursor s... 阅读全文
posted @ 2015-05-17 20:47 领导来根辣条 阅读(236) 评论(0) 推荐(0)
摘要:18. 异常的基本程序: 通过 select ... into ... 查询某人的工资, 若没有查询到, 则输出 "未找到数据"declare --定义一个变量 v_sal employees.salary%type;begin --使用 select ... into ... 为 v_sa... 阅读全文
posted @ 2015-05-17 14:45 领导来根辣条 阅读(254) 评论(0) 推荐(0)
摘要:57. 定义非空约束1). 非空约束只能定义在列级.2). 不指定约束名create table emp2 (name varchar2(30) not null, age number(3)); 3). 指定约束名 create table emp3(name varchar2(30) const... 阅读全文
posted @ 2015-05-17 14:24 领导来根辣条 阅读(205) 评论(0) 推荐(0)
摘要:--删除employee_id=113的记录delete from employees where employee_id=113;--保存回滚点,命名回滚点名称为emp113savepoint emp113; --删除employee_id=112的记录delete from employe... 阅读全文
posted @ 2015-05-17 13:45 领导来根辣条 阅读(380) 评论(0) 推荐(0)
摘要:55. 更改 108 员工的信息: 使其工资变为所在部门中的最高工资, job 变为公司中平均工资最低的 job1). 搭建骨架update employees set salary = (), job_id = () where employee_id = 108; 2). 所在部门中的最高工资... 阅读全文
posted @ 2015-05-17 13:28 领导来根辣条 阅读(1244) 评论(0) 推荐(0)
摘要:51. 利用子查询创建表 myemp, 该表中包含 employees 表的 employee_id(id), last_name(name), salary(sal), email 字段1). 创建表的同时复制 employees 对应的记录create table myemp asselect... 阅读全文
posted @ 2015-05-17 13:09 领导来根辣条 阅读(236) 评论(0) 推荐(0)
摘要:40. 谁的工资比 Abel 高?1). 写两条 SQL 语句.SELECT salaryFROM employeesWHERE last_name = 'Abel' --返回值为 11000SELECT last_name, salaryFROM employeesWHERE salary > ... 阅读全文
posted @ 2015-05-17 00:37 领导来根辣条 阅读(263) 评论(0) 推荐(0)
摘要:ORACLE 测试一、完成下列SQL语句1.查询员工姓名(last_name或first_name),hire_date , department_id 满足以下条件:雇用时间在1997年之后,department_id 为80 或 90 或110, commission_pct不为空select... 阅读全文
posted @ 2015-05-16 20:04 领导来根辣条 阅读(422) 评论(0) 推荐(0)
摘要:synonye 同义词为employees表起别名SQL> create synonym e for employees;Synonym createdSQL> select * from e; 阅读全文
posted @ 2015-05-16 18:07 领导来根辣条 阅读(189) 评论(0) 推荐(0)
摘要:创建索引SQL> create index emp_name_index on emp2(name);Index created 以下情况可以创建索引:列中数据值分布范围很广列经常在 WHERE 子句或连接条件中出现表经常被访问而且数据量很大 ,访问的数据大概占数据总量的2%到4%下列情况不要创建... 阅读全文
posted @ 2015-05-16 17:57 领导来根辣条 阅读(106) 评论(0) 推荐(0)
摘要:序列create sequence FIXED_ASSETS_TYPE_SEminvalue 1maxvalue 9999999999999999999999999999start with 1increment by 1nocache; 触发器create or replace trigger ... 阅读全文
posted @ 2015-05-16 17:43 领导来根辣条 阅读(261) 评论(0) 推荐(0)
摘要:--创建表create table emp2 as select employee_id id,last_name name from employees where 1=2; 创建序列create sequence emp_seq; --查看当前序列的值select emp_seq.currva... 阅读全文
posted @ 2015-05-16 17:41 领导来根辣条 阅读(173) 评论(0) 推荐(0)
摘要:--创建视图SQL>create or replace view emp_viewasselect employee_id id,last_name name,email,department_name,cityfrom employees e,departments d,locations lwh... 阅读全文
posted @ 2015-05-16 16:40 领导来根辣条 阅读(778) 评论(0) 推荐(0)
摘要:sqlplus / as sysdba grant create any index to scott 授予创建任何索引grant create procedure to scott 授予创建储存过程grant create sequence to scott 授予创建序列grant create ... 阅读全文
posted @ 2015-05-16 13:58 领导来根辣条 阅读(210) 评论(0) 推荐(0)

1