redhat下通过rman自动备份db!
仅仅是思路和过程,根据自己的需求调整:1 cp /home/oracle/.bash_profile dbbak.sh之所以要拷贝这个文件,是因为它是oracle用户的环境变量文件,里面包含了oracle用户所需要的所有环境变量2. 在dbbak.sh文件中加入如下语句:rman target sys/password@tns cmdfile=/home/oracle/dbbak.sql3. 编写dbbak.sql如下:backup tablespace 'TEST';这里只是用来测试!4. chmod +x dbbak.sh5. 利用crontab来调用dbbak.sh脚本实现自动备份db,假如想每天晚上21:38分自动备份db,那么可以通过crontab -e来编辑root用户的自动定时任务:[root@xys orac
windows部分联机自动备份脚本!
c:dbbak.batdbbak.bat内容如下:sqlplus / as sysdba @ dbbak.sql把批处理文件dbbak.bat放到任务计划里或者通过at命令调用就可以实现自动备份db[@more@]--================================select 'alter tablespace '||tablespace_name||' begin backup;' from dba_data_files;select 'host copy '||file_name||' C:oracleproduct10.2.0oradataonline;' from dba_data_filesselect 'alter tablespace '||tablespace_name||' end backup;' from dba_data_files;dbbak.sql脚本内容可以通过上面语句构造dbbak.sql内容如下:alter tablespace
Dynamic Sampling!
The purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing plans.[@more@]Dynamic SamplingThe purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing pl
transaction使用的undo block组成了一个单向列表!
通过试验验证了一下。[@more@]SQL> insert into tt select * from dba_objects;已创建40231行。SQL> select ubafil,ubablk,start_ubablk,used_ublk from v$transaction; UBAFIL UBABLK START_UBABLK USED_UBLK---------- ---------- ------------ ---------- 2 183 99 19SQL> select segment_name,extent_id,file_id,block_id from dba_extents where segment_name='RBS1';SEGMENT_NAME EXTENT_ID FILE_ID BLOCK_ID-------------------- ---------- ---------- --------
what's xidsqn and ubasqn in v$transaction?
不容易理解的2个字段,Jonathan Lewis的解释http://www.dbforums.com/archive/index.php/t-1314288.html[@more@]Jonathan LewisThe slots in the transaction table in the undo segment headerare continuously being reused. Each time a slot it re-used,its sequence number (xidsqn) goes up.Similarly, undo blocks are re-used (though it takes moretime to get round to re-using them than transaction slots).Each time an undo block is "newed" and reused, itssequence number UBASQN goes up.
解惑v$rollstat中的curext、curblk字段!
坦率的说这2个字段困扰了自己很久,每次看到的是doc的解释:CUREXTNUMBERCurrent extentCURBLKNUMBERCurrent block都不理解什么意思,每次想到的总是去dump这个block,而没有去dump undo segment header,所以一直也没搞清楚它的确切意思。[@more@]SQL> select count(*) from tt; COUNT(*)---------- 40190SQL> insert into tt select * from tt;已创建40190行。SQL> select usn,curext,curblk from v$rollstat where xacts=1; USN CUREXT CURBLK---------- ---------- ---------- 12 1
oracle block type!
http://www.ixora.com.au/notes/cache_block_types.htm[@more@]http://www.ixora.com.au/notes/cache_block_types.htm
oracle的block其实是和os的扇区相对应!
oracle的block其实是和os的扇区相对应![@more@]之所以要说明oracle的block和os的扇区相对应,是因为oracle的doc上提到oracle的block是os的block的整数倍(DB_BLOCK_SIZE specifies (in bytes) the size of Oracle database blocks. Typical values are 4096 and 8192. The value of this parameter must be a multiple of the physical block size at the device level.),那么oracle中提到的os的block到底是指os的什么需要明确。oracle的block其实是和os的扇区相对应,和簇应该没有任何关系!os的扇区是os的最小io单位为什么这样说:1、
有关参数o7_DICTIONARY_ACCESSIBILITY!
O7_DICTIONARY_ACCESSIBILITY是针对select any table权限控制是否可以访问data dictionary的![@more@]SQL> connect /as sysdba已连接。SQL> show parameter o7NAME TYPE VALUE------------------------------------ ----------- ------------------------------O7_DICTIONARY_ACCESSIBILITY boolean FALSESQL> select name from system_privilege_map where name like '%SELECT ANY TABLE%';NAME----------------------------------------SELECT ANY TABLESQL> grant se
列权限的一点总结!
oracle 部分对象权限(insert,update,references)可以控制到列![@more@]SQL> connect test5/test5已连接。SQL> grant insert(id , name) , update(sex) ,select on t to test2;授权成功。SQL> show userUSER 为 "TEST5"SQL> connect test2/test2已连接。SQL> select * from test5.t; ID NAME S---------- ---------- - 2 a 2 3 a 2SQL> insert into test5.t values(1 , 'a' , 1);insert into test5.t values(1 , 'a' , 1) *第 1 行出现错误:
oracle数据字典的一点总结!
oracle的数据字典比较多,其实也比较复杂。通过分类简单的做了一点总结。[@more@]Data Dictionary包括: 1.base table 基表 在create database时通过调用$ORACLE_HOMEsql.bsq而创建的,大致可以通过下面语句获得,当然也可以直接查看sql.bsq文件 select * from dba_tableswhere owner='SYS' AND tablespace_name='SYSTEM' 2.Data Dictionary views Data Dictionary views是通过create database之后调用脚本($ORACLE_HOMErdbmsadmincatalog.sql)创建的,如果手工创建db的话可以很容易的观查和实验。 可以通过查询dict来获得
状态为inactive的日志一定归档了吗?
inactive表示该日志在实例恢复时不再需要被用到,仅此而已,和是否归档没有任何关系,前端时间看到pub上有人问起这个问题,我们通常看到状态为inactive的日志archived=YES也就是通常都归档了,不太容易观察到archived=no,在9i下可以通过设置log_archive_start=false来控制不归档,但是10g是否不太容易控制,这里通过缩小flash_recovery_area使其没有空间从而不能实现归档来观察一下状态为inactive且archived=no的日志!SQL> select group#,sequence#,status,archived from v$log; GROUP# SEQUENCE# STATUS ARC--------
sqlldr和external table的关系!
其实external table是对sqlldr工具的一个补充和完善![@more@]--创建目录SQL> connect /as sysdba已连接。SQL> create or replace directory sqldr2 as 'F:f_temporaclesqlldrtest6'3 ;目录已创建。SQL> select * from dba_directories;OWNER DIRECTORY_NAM DIRECTORY_PATH---------- ------------- --------------------------------------------------SYS SQLDR F:f_temporaclesqlldrtest6SYS DATA_PUMP_DIR e:oracleproduct10.2.0adminorcldpdump--给使用目录的用户授权SQL> grant read , write on directory sqldr to xys
flashback table也会用到temp表空间?
无意中执行的一个简单的flashback table操作提示:SQL> flashback table t to scn 340592;flashback table t to scn 340592 *第 1 行出现错误:ORA-00604: 递归 SQL 级别 1 出现错误ORA-25153: 临时表空间为空那么到底是flashback table操作需要用到temp tbs呢还是在执行flashback table操作的其他系统操作用到temp tbs?有点疑问[@more@]SQL> desc t 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- ID
oracle的两种global temporary table!
1. on commit delete rows2.on commit preserve rows[@more@]SQL> create global temporary table gt1 (id int) ;表已创建。SQL> insert into gt1 values(1);已创建 1 行。SQL> insert into gt1 values(2);已创建 1 行。SQL> select * from gt1;ID----------12SQL> commit;提交完成。SQL> select * from gt1;未选定行SQL> create global temporary table gt2 (id int) on commit delete rows ;表已创建。SQL> create global temporary table gt3 (id int) on commit preserve rows ;表已创建。SQL> insert int
当存在read only或者offline表空间时,重建控制文件时要注意!
当存在read only或者offline表空间时,重建控制文件分两种情况:1、重建controlfile的script中包含read only或者offline所对应的datafile;这种情况比较简单,datafile不需要rename,如果是offline的表空间,那么重建controlfile之后只需要online tbs即可;如果是read only tbs那么重建controlfile之后需要对其对应的daafile进行恢复。2、重建controlfile的script中不包含read only或者offline所对应的datafile;重建controlfile之后需要rename datafile到正确的位置,之后如果是offline的表空间,那么重建controlfile之后只需要online tb
一个有意思的权限问题!
题意是这样的:有3个用户test,test1,test2test下有一表ttest1下有一个view:create view v1as select * from test.t现在test1要把v1的select权限授予test2,需要具备什么条件?[@more@]1、第一种想法test用户在授予t的select 权限给test1时需要带上grant option选项以保证test1在授予v1的select权限时能保证它可以把test.t的select权限授予test2SQL> create user test identified by test;用户已创建。SQL> create user test1 identified by test1;用户已创建。SQL> grant connect, resource to test,test1;授权成功。SQL> c
connect-time failover的配置!
我的理解connect-time failover通常用在rac中,不过单实例环境下依然可以enable connect-time failover特性,实际意义有多大暂且不说![@more@]配置两个监听:listener,和1(之所以叫1,是因为在win下服务中监听对应的服务会自动加上listener,所以最终是为了看起来舒服,我们看到的会是listener1,否则看到的就是...listenerlistener1),这两个监听同时都监听数据库test,port分别是1521和1522,然后配置tns如下:TEST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xys)(PORT = 1521)) (ADDRESS
dbms_scheduler中参数repeat_interval的一些例子!
来至于管理向导上的一些例子![@more@]Using the Scheduler Calendaring SyntaxThe primary method of setting how often a job will repeat is by setting the repeat_interval attribute with a Scheduler calendaring expression. See Oracle Database PL/SQL Packages and Types Reference for a detailed description of the calendaring syntax for repeat_interval as well as the CREATE_SCHEDULE procedure.Examples of Calendaring ExpressionsThe following examples illustrate simple repeat intervals. For simplicity, it
oracle标准版和企业版的区别!
经常有人我,正好找到一个比较全面而又简洁的doc介绍,随手记录一下![@more@]http://www.oracle.com/lang/cn/database/product_editions.html