2017年2月4日
摘要: --恢复整个数据库run {shutdown immediate;startup mount;restore database;recover database;alter database open;} --恢复表空间usersrun {sql 'alter tablespace users of 阅读全文
posted @ 2017-02-04 11:45 john2017 阅读(5348) 评论(0) 推荐(0) 编辑
摘要: run{ allocate channel d1 type disk; backup database format='/u01/backup/%T_%d_%s.bak'; sql 'alter system archive log current'; backup archivelog all f 阅读全文
posted @ 2017-02-04 11:44 john2017 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 1、shell脚本1)vi rman_backup.cmd#rman_backup.cmdconnect target /run{ allocate channel d1 device type disk; backup database format='/u01/backup/%T_%d_%s.b 阅读全文
posted @ 2017-02-04 11:43 john2017 阅读(566) 评论(0) 推荐(0) 编辑
摘要: --登录rman rman target / rman target sys/passwork rman target sys/passwork nocatalog (控制文件方式) rman target sys/passwork catalog (恢复目录方式) --查看参数 show all 阅读全文
posted @ 2017-02-04 11:42 john2017 阅读(5035) 评论(0) 推荐(0) 编辑
摘要: exp 客户端工具expdp 服务端工具 expdp help=y 帮助命令directory 导出目录逻辑名 --查询默认数据泵目录select * from dba_directorieswhere directory_name='DATA_PUMP_DIR'; --修改默认数据泵目录creat 阅读全文
posted @ 2017-02-04 11:40 john2017 阅读(341) 评论(0) 推荐(0) 编辑
摘要: --导出表exp userid=hr/oracle123 tables=employees direct=y file=/u01/employees.dmp log=/u01/employees.log --导入表 (表存在时要加ignore参数)imp userid=hr/oracle123 ta 阅读全文
posted @ 2017-02-04 11:39 john2017 阅读(229) 评论(0) 推荐(0) 编辑
摘要: --查看存储过程源代码IKKI@ test10g> select text from user_source where name='ADD_DEPT'; TEXT procedure add_dept(dno number, dname varchar2 default null, loc var 阅读全文
posted @ 2017-02-04 11:38 john2017 阅读(140) 评论(0) 推荐(0) 编辑
摘要: --定义包头 create or replace package 包名as 变量、常量声明; 函数声明; 过程声明;end; --定义包体 create or replace package body 包名as 函数实际代码; 过程实际代码;end; create or replace packag 阅读全文
posted @ 2017-02-04 11:37 john2017 阅读(132) 评论(0) 推荐(0) 编辑
摘要: --PL/SQL错误 编译时 运行时--运行时的出错处理 EXCEPTION --异常处理块DECLARE …BEGIN …EXCEPTION WHEN OTHERS THEN handler_error(…);END; --用户自定义的异常DECLARE e_TooManyStudents EXC 阅读全文
posted @ 2017-02-04 11:36 john2017 阅读(170) 评论(0) 推荐(0) 编辑
摘要: --函数 create or replace function 函数名称(参数1 类型1,参数2 类型2,...) return 数据类型as 变量、常量声明;begin 代码;end; create or replace function fun_change_name(name varchar2 阅读全文
posted @ 2017-02-04 11:35 john2017 阅读(196) 评论(0) 推荐(0) 编辑
摘要: --触发器 触发器有三类: 数据操作触发器 用before触发器进行数据校验 用after触发器进行级联操作 语句触发器限制数据的操作和记录操作日志 instead of 触发器(只针对视图不允许DML操作时) 数据定义触发器 监视数据库中用户的一些重要操作 系统触发器 --触发器的限制 不应该使用 阅读全文
posted @ 2017-02-04 11:35 john2017 阅读(230) 评论(0) 推荐(0) 编辑
摘要: --存储过程(不带参数) create or replace procedure 存储过程名as 变量、常量声明;begin 代码;end; --存储过程(带输入参数) create or replace procedure 存储过程名(参数1 类型,参数2 类型,...) --可以设默认值,如lo 阅读全文
posted @ 2017-02-04 11:34 john2017 阅读(140) 评论(0) 推荐(0) 编辑
摘要: --游标 declare cursor 游标名字 is 查询语句;begin 其他语句;end; --游标的属性%FOUND%NOTFOUND%ISOPEN%ROWCOUNT(当前游标的指针位移量) --FETCH的两种形式FETCH cursor_name INTO var1, var2, …;F 阅读全文
posted @ 2017-02-04 11:33 john2017 阅读(192) 评论(0) 推荐(0) 编辑
摘要: --IF语法IF condition THEN statements;[ELSIF condition THEN statements;][ELSE statements;]END IF; --CASE 语法1、在 CASE 语句中使用单一选择符进行等值比较 CASE selector WHEN e 阅读全文
posted @ 2017-02-04 11:32 john2017 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 语法:identifier [CONSTANT] datatype [NOT NULL] [:= | DEFAULT expr] identifier:用于指定变量或常量的名称。CONSTANT:用于指定常量。当定义常量时,必须指定它的初始值,并且其数值不能变。datatype:用于指定变量或常量的 阅读全文
posted @ 2017-02-04 11:31 john2017 阅读(2613) 评论(0) 推荐(1) 编辑
摘要: 1、标识符命名规则当在 PL/SQL 中使用标识符定义变量、常量时,标识符名称必须以字符开始,并且长度不能超过 30 个字符。另外,为了提高程序的可读性,Oracle 建议用户按照以下规则定义各种标识符:--当定义变量时,建议使用 v_ 作为前缀,例如 v_sal, v_job等。--当定义常量时, 阅读全文
posted @ 2017-02-04 11:30 john2017 阅读(283) 评论(0) 推荐(0) 编辑
摘要: --创建同义词create public synonym employees for hr.employees; --公共同义词需要 create public synonym 权限表的所有用户授予公共权限 grant select on employees to public;create syn 阅读全文
posted @ 2017-02-04 11:29 john2017 阅读(229) 评论(0) 推荐(0) 编辑
摘要: --主、外键约束 create table t( id int primary key); create table t1( id int references t(id));或者create table t( id int constraint pk_t_id primary key); crea 阅读全文
posted @ 2017-02-04 11:28 john2017 阅读(909) 评论(0) 推荐(0) 编辑
摘要: --查看表的结构 desc ygb; select * from user_tab_columnswhere table_name='YGB'; --新建表ygb create table ygb( bh number(3), eid varchar2(6) constraint eid_p pri 阅读全文
posted @ 2017-02-04 11:27 john2017 阅读(255) 评论(0) 推荐(0) 编辑
摘要: --查询帐户的状态select username,account_status from dba_users where username='SCOTT'; --创建用户create user john identified by johndefault tablespace usersquota 阅读全文
posted @ 2017-02-04 11:26 john2017 阅读(1120) 评论(0) 推荐(0) 编辑