2011年5月3日
摘要: Oracle笔记 一、oracle的安装、sqlplus的使用 Oracle笔记 二、常用dba命令行Oracle笔记 三、function 、selectOracle笔记 四、增删改、事务Oracle笔记 五、创建表、约束、视图、索引、序列、同义词、表空间Oracle笔记 六、PL/SQL简单语句块、变量定义Oracle笔记 七、PL/SQL 异常处理Oracle笔记 八、PL/SQL跳转/判断/循环语句块Oracle笔记 九、PL/SQL 游标的使用Oracle笔记 十、PL/SQL存储过程Oracle笔记 十一、PL/SQL函数和触发器Oracle笔记 十二、PL/SQL 面向对象oop 阅读全文
posted @ 2011-05-03 18:27 hoojo 阅读(3433) 评论(5) 推荐(2) 编辑
摘要: --1.随机数select dbms_random.value from dual;select mod(dbms_random.random, 10) from dual;--0-9随机数select abs(mod(dbms_random.random, 10)) from dual;--40-49随机数select 40 + abs(mod(dbms_random.random, 10))... 阅读全文
posted @ 2011-05-03 16:24 hoojo 阅读(2834) 评论(0) 推荐(1) 编辑
摘要: --将方法和过程用包定义create or replace package pkg_empas --输入员工编号查询出员工信息 procedure pro_findInfo( in_empno emp2.empno%type, out_name out emp2.ename%type, out_sal out emp2.sal%type ); --根据部门编号修改本部门员工工资 procedur... 阅读全文
posted @ 2011-05-03 16:16 hoojo 阅读(2229) 评论(0) 推荐(1) 编辑
摘要: ------------------------抽象数据类型-------------创建地址类型,一定要加as object,还可以在类型中加过程或方法create or replace type address as object ( province varchar2(10), --省份属性 city varchar2(10) --市属性) not final; --not final表示... 阅读全文
posted @ 2011-05-03 16:11 hoojo 阅读(3934) 评论(0) 推荐(4) 编辑
摘要: --创建函数create or replace function add_sal(sSal number) return numberisbegin if (sSal > 5000) then return sSal + 51; elsif (sSal > 3000) then return sSal + 111; else return sSal + 222; end if;end;selec... 阅读全文
posted @ 2011-05-03 16:01 hoojo 阅读(1876) 评论(0) 推荐(1) 编辑
摘要: --create or replace 创建或替换,如果存在就替换,不存在就创建create or replace procedure pis cursor c is select * from dept2 for update;begin for row_record in c loop if (row_record.deptno = 30) then update dept2 set dna... 阅读全文
posted @ 2011-05-03 15:57 hoojo 阅读(2500) 评论(2) 推荐(0) 编辑
摘要: --演示隐式游标,系统自动声明,自动打开,自动使用并且自动关闭begin update emp set sal = 1000; dbms_output.put_line('影响的行数:' || sql%rowcount);end;rollback;/*游标的使用方法:第一步:声明游标第二步:打开游标第三步:使用游标进行循环操作第四步:关闭游标*/--普通游标,游标本身就是一个变量declare ... 阅读全文
posted @ 2011-05-03 15:45 hoojo 阅读(6584) 评论(0) 推荐(2) 编辑
摘要: --goto跳转语句--在goto 后,跳转到相应的语句,然后执行该语句和后面所有语句begin dbms_output.put_line('goto开始了'); goto c; --不被执行 dbms_output.put_line('goto'); dbms_output.put_line('goto'); dbms_output.put_line('goto'); dbms_output.... 阅读全文
posted @ 2011-05-03 15:37 hoojo 阅读(5280) 评论(0) 推荐(0) 编辑
摘要: --异常处理declare sNum number := 0;begin sNum := 5 / sNum; dbms_output.put_line(sNum);exception when others then dbms_output.put_line('is Error!');end;--自定义异常declare ex_custom_invaild_age exception; --自定... 阅读全文
posted @ 2011-05-03 15:30 hoojo 阅读(2361) 评论(0) 推荐(2) 编辑
摘要: 1、简单SQL语句,HellWorld示例--输出信息begin dbms_output.put_line('Oracle Hello World!');end;2、变量的定义、使用--定义变量declare sName varchar2(20);begin sName := 'jack'; dbms_output.put_line(sName);end; --常用类型declare sNum ... 阅读全文
posted @ 2011-05-03 15:24 hoojo 阅读(24260) 评论(0) 推荐(2) 编辑
摘要: alter table userInfo add(msn varchar2(20));1、建表 create table userInfo ( id number(6), name varchar2(20), sex number(1), age number(3), birthday date, address varchar2(50), email varchar2(25), tel num... 阅读全文
posted @ 2011-05-03 15:18 hoojo 阅读(6991) 评论(2) 推荐(3) 编辑
摘要: 1、插入 insert into dept values(50, 'soft', 'Guangzhou'); insert into dept(deptno, dname) values(60, 'software test'); insert into dept select * from dept where deptno = 20;2、删除 delete from dept where d... 阅读全文
posted @ 2011-05-03 14:21 hoojo 阅读(2357) 评论(0) 推荐(1) 编辑
摘要: Scott表下有这么几个常用的表,而且还带有数据。分别是emp、dept、salgrade;1、查看表结构用desc desc emp;2、空表dual,最常用的空表,如: select 2 * 4 from dual; select sysdate from dual;3、双引号能保持格式 如:select sysdate “toDay 日 期” from dual;4、|| 字符串连接 如:... 阅读全文
posted @ 2011-05-03 13:58 hoojo 阅读(3881) 评论(2) 推荐(4) 编辑
摘要: 1、给用户解锁 alter user scott account unlock; 2、注销、断开、切换当前用户连接 quit conn scott/tiger 3、用户权限查询 A .查看所有用户: select * from dba_users; select * from all_users; select * from user_users; B.查看用户或角色系统权限(直接赋值给用户或角色的系统权限): select * from dba_sys_privs; select * from user_sys_privs; C.查看角色(只能查看登陆用户拥有的角色)所包含的权限 selec 阅读全文
posted @ 2011-05-03 13:28 hoojo 阅读(5054) 评论(0) 推荐(1) 编辑
摘要: 1、 首先你得安装Oracle数据库服务器端和客户端软件,在安装过程中要注意的是,选择oracle的安装目录,切记不要用中文目录或的带空格的目录。 下载地址: http://hi.baidu.com/dashuaiwang/blog/item/42f8e7fab96978d6b58f314b.html/cmtid/d5bba9190dd0904a42a9ad77 2、 安装结束后,会提示你记住一些东西。也就是一些网址,这个也很重要。下面是我的oracle提示的信息: Enterprise Manager Database Control URL - (oracle) : http://hooj 阅读全文
posted @ 2011-05-03 12:40 hoojo 阅读(12090) 评论(0) 推荐(3) 编辑