摘要:
--恢复整个数据库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
阅读(5580)
评论(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
阅读(365)
评论(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
阅读(585)
评论(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
阅读(5118)
评论(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
阅读(361)
评论(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
阅读(242)
评论(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
阅读(148)
评论(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
阅读(137)
评论(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
阅读(182)
评论(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
阅读(203)
评论(0)
推荐(0)
摘要:
--触发器 触发器有三类: 数据操作触发器 用before触发器进行数据校验 用after触发器进行级联操作 语句触发器限制数据的操作和记录操作日志 instead of 触发器(只针对视图不允许DML操作时) 数据定义触发器 监视数据库中用户的一些重要操作 系统触发器 --触发器的限制 不应该使用 阅读全文
posted @ 2017-02-04 11:35
john2017
阅读(245)
评论(0)
推荐(0)
摘要:
--存储过程(不带参数) create or replace procedure 存储过程名as 变量、常量声明;begin 代码;end; --存储过程(带输入参数) create or replace procedure 存储过程名(参数1 类型,参数2 类型,...) --可以设默认值,如lo 阅读全文
posted @ 2017-02-04 11:34
john2017
阅读(147)
评论(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
阅读(204)
评论(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
阅读(213)
评论(0)
推荐(0)
摘要:
语法:identifier [CONSTANT] datatype [NOT NULL] [:= | DEFAULT expr] identifier:用于指定变量或常量的名称。CONSTANT:用于指定常量。当定义常量时,必须指定它的初始值,并且其数值不能变。datatype:用于指定变量或常量的 阅读全文
posted @ 2017-02-04 11:31
john2017
阅读(2702)
评论(0)
推荐(1)
摘要:
1、标识符命名规则当在 PL/SQL 中使用标识符定义变量、常量时,标识符名称必须以字符开始,并且长度不能超过 30 个字符。另外,为了提高程序的可读性,Oracle 建议用户按照以下规则定义各种标识符:--当定义变量时,建议使用 v_ 作为前缀,例如 v_sal, v_job等。--当定义常量时, 阅读全文
posted @ 2017-02-04 11:30
john2017
阅读(315)
评论(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
阅读(253)
评论(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
阅读(934)
评论(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
阅读(268)
评论(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
阅读(1175)
评论(0)
推荐(0)
摘要:
--创建 profile 概要文件create profile profile123 limit failed_login_attempts 2; --修改用户的 profile 文件alter user scott profile profile123; 确保将初始化参数 resource_lim 阅读全文
posted @ 2017-02-04 11:26
john2017
阅读(206)
评论(0)
推荐(0)
摘要:
--查看数据库运行模式(spfile还是pfile)select decode(count(*),1,'spfile','pfile') from v$spparameterwhere rownum=1 and isspecified='TRUE'; --以pfile启动数据库create pfil 阅读全文
posted @ 2017-02-04 11:25
john2017
阅读(395)
评论(0)
推荐(0)
摘要:
--查看控制文件路径 show parameter control_files; --控制文件的备份,三种方式1)使用OS命令进行拷贝;1)open状态下,使用alter database命令生成控制文件副本;2)open状态下,使用alter database backup controlfile 阅读全文
posted @ 2017-02-04 11:24
john2017
阅读(835)
评论(0)
推荐(0)
摘要:
--两个相关视图v$logv$logfile alter system switch logfile; --强制日志切换alter system checkpoint; --强制检查点 --添加日志组alter database add logfile group 4 ('/u01/app/orac 阅读全文
posted @ 2017-02-04 11:23
john2017
阅读(242)
评论(0)
推荐(0)
摘要:
--查看归档模式archive log list select log_mode from v$database; --修改为归档模式(mount下)alter database archivelog --修改为非归档模式(mount下)alter database noarchivelog --切 阅读全文
posted @ 2017-02-04 11:21
john2017
阅读(458)
评论(0)
推荐(0)
摘要:
--查看临时文件的使用/剩余空间 SQL> select * from v$temp_space_header; --查看SCOTT用户所属的临时表空间 SQL> select username ,temporary_tablespace from dba_users where username= 阅读全文
posted @ 2017-02-04 11:20
john2017
阅读(228)
评论(0)
推荐(0)
摘要:
--查询默认的undo表空间 select name,value from v$parameterwhere name like '%undo%'; --创建 undotbs2 表空间 create undo tablespace undotbs2datafile '/u01/app/oracle/ 阅读全文
posted @ 2017-02-04 11:20
john2017
阅读(713)
评论(0)
推荐(0)
摘要:
--查看表空间 select * from dba_tablespaces; select * from v$tablespace; select * from dba_data_files; --查看数据文件select * from v$datafile; select * from dba_t 阅读全文
posted @ 2017-02-04 11:19
john2017
阅读(337)
评论(0)
推荐(0)
摘要:
1.从官网http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html 选择instantclient-basic-nt-11.2.0.4.0.zip (32位的,PL/SQL貌似不支持64位 阅读全文
posted @ 2017-02-04 11:16
john2017
阅读(742)
评论(0)
推荐(0)
摘要:
先在软件运行界面卸载 Oracle 一、删掉主目录 二、删除注册表内容。 运行regedit命令,删除下面内容: --1、HKEY_CLASSES_ROOT,删除此键下所有以Ora,Oracle,Orcl,EnumOra 为前缀的键。 2、HKEY_CURRENT_USER\Software\Mic 阅读全文
posted @ 2017-02-04 11:15
john2017
阅读(434)
评论(0)
推荐(0)
摘要:
1、卸载数据库软件--10g[oracle]# cd /u01/app/oracle/product/10.2.0/db_1/oui/bin[oracle]# ./runInstaller -ignoresysprereqs --11g[oracle]# cd /u01/app/oracle/pro 阅读全文
posted @ 2017-02-04 11:14
john2017
阅读(14999)
评论(0)
推荐(0)
摘要:
一、配置环境变量1、我将环境变量配置写成了一个脚本,将这个脚本copy到一个新建的linux系统。(脚本是本人原创,前2篇文章里有,感兴趣的朋友可以去看看)2、进入脚本所在的目录。3、执行脚本,需要输入的地方:设置oracle用户密码;设置oracle sid名,其他的脚本会自动配置。脚本创建的默认 阅读全文
posted @ 2017-02-04 11:12
john2017
阅读(451)
评论(0)
推荐(0)
摘要:
#!/bin/bash #Test in RHEL 5.5 for 11g c=`cat /etc/shadow | grep oracle | wc -l`if [ $c != 0 ]then w=0 while [ $w -eq 0 ] do echo "--Find user oracle h 阅读全文
posted @ 2017-02-04 11:10
john2017
阅读(906)
评论(0)
推荐(0)
摘要:
#!/bin/bash #Test in RHEL 5.5 for 10g c=`cat /etc/shadow | grep oracle | wc -l`if [ $c != 0 ]then w=0 while [ $w -eq 0 ] do echo "--Find user oracle h 阅读全文
posted @ 2017-02-04 11:09
john2017
阅读(608)
评论(0)
推荐(0)
摘要:
--创建用户和组 用户 oracle (附加到 oinstall和 dba组) 组 oinstall dba--创建安装目录并设置权限 mkdir -p /u01/app/oracle chown -R oracle:oinstall /u01 chmod -R 775 /u01--修改系统内核参数 阅读全文
posted @ 2017-02-04 11:08
john2017
阅读(1379)
评论(0)
推荐(0)
浙公网安备 33010602011771号