FLASHBACK的一些设置经验
以下是工作中对database flashback的一些设置经验:[@more@]1)Change the initialization Parmeter- init.ora.db_recovery_file_dest_size=20gdb_recovery_file_dest='/axptpharch/axptphq/flasharea'DB_FLASHBACK_RETENTION_TARGET=10080log_archive_dest_1='location=/oradb/arch'control_file_record_keep_time=14#log_archive_format=oradb_arc_%t_%s_%r.arcand comment out #log_archive_dest='/oradb/arch' 2)Starting database in flashback Mode:svr << EOFspool $spooltofile_tempshutdown immediate;startup mount;alter
10G TTS-将tablespace从aix转到linux
主要遵从以下步骤:Transportable Tablespaces Steps:· Determine the source and target database oracle version( Source database version can not be more than target database version).· Verification of endian compatibilities of source and target and if there is any conversions required .· Check Database Character set and national Character set for compatibility between source and target.· Determine if there are external objects (external tables ,directory structures) need to moved separately to t
虚拟索引
在做sql tuning时,可以引用虚拟索引技术而不用创建物理索引来进行tuning判断。sql>create index index_name on table_name(column_name) nosegment;在使用时,要这样才能生效:SQL> alter session set "_use_nosegment_indexes"=TRUE; [@more@]
oracle 10g 的recyble bin
以下内容为转载:[@more@]Oracle] Oracle 10G 中的"回收站"作者:Fenng 日期:11-Jan-2004 出处:http://www.dbanotes.net版本:1.0 $29-Oct-2004$在Oracle 10g数据库中,引入了一个回收站(Recycle Bin)的数据库对象。 回收站,从原理上来说就是一个数据字典表,放置用户Drop掉的数据库对象信息。用户进行Drop操作的对象并没有被数据库删除,仍然会占用空间。除非是由于用户手工进行Purge或者因为存储空间不够而被数据库清掉。数据库有了这样的功能,能够减少很多不必要的麻烦。常常看到开发人员误把表删除,急急忙忙找DBA 来
AWR report 报告中db time的说明(转)
关于awr report中db time的说明2008-08-12 16:39在10g的awr report出了个db time,这里做个简单的说明先摘录一些官方的说明:Oracle Database Performance Tuning Guide 10g Release 2 (10.2)B14211-01DB TimeAmount of elapsed time (in microseconds) spent performing Database user-level calls. This does not include the time spent on instance background processes such as PMON.The most important of the time model statistics is DB time. This statistics represents the total time spent in database calls and is a indi
了解autotrace的输出
对以下autotrace输出内容的解释SQL> select * from emp,dept where emp.deptno(+)=dept.deptno;已选择15行。执行计划---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5 Card=14 Bytes=798) 1 0 HASH JOIN (OUTER) (Cost=5 Card=14 Bytes=798) 2 1 TABLE ACCESS (FULL) OF 'DEPT' (Cost=2 Card=4 Bytes=80) 3 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=14 Bytes=518)[@more@]1.cost:--CBO赋予查询计划的每个步骤的成本.CBO通过对相同查询生
ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_DDL"
在10g打完一个CPU后,在做export时发现以下错误:EXP-00008: ORACLE error 4063 encounteredORA-04063: package body "SYS.DBMS_DDL" has errorsORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_DDL"ORA-06512: at line 1EXP-00056: ORACLE error 1403 encounteredORA-01403: no data foundEXP-00000: Export terminated unsuccessfully[@more@]检查invalid的object数,发现多达90多个。以下是解决办法:$sqlplus "/as sysdba"SQL> startup upgradeSQL > @?/rdbms/admin/ca
v$session的妙用(引用)
以下文章出处:http://www.oracle.com.cn/viewthread.php?tid=38191&extra=page%3D1%26amp%3Bfilter%3Ddigest&page=1在工作中,有时要给开发提供session的open_cursor,虽然在toad里面都能看到,但通过v$open_cursor也是很方便的。比如:select b.sid,a.sql_text from v$sql a,v$open_cursor b where a.hash_value in (select hash_value from v$open_cursor where sid=72) and b.sid=72 group by b.sid,a.sql_text[@more@]V$session 表的妙用^_^v$session 表中比较常用的几个字段说明^_^1. sid,serial#通过sid我们可以查询与这个s
左右外连接的一些小结
我们可以用select ....from table1 [left|right|inner|full] join table2 on table1.col1=table2.col2的方式来实行各种外连接。也可以用(+)来实现外连接。在用(+)来实现外连接时,有几点是需要注意的:[@more@]1.(+)操作符执行出现在where子句中,并且不能与outer join语法同时使用。2.当使用(+)操作符执行外连接时,如果where子句中包含多个条件,则必须在所有条件中都要包含(+)操作符。如:SELECT a.dname, b.ename FROM dept a, emp b WHERE a.deptno = b.deptno(+) AND b.deptno(+) = 10如果只出现在a.deptno = b.deptno(+) 而不
什么时候重建索引
在网上查找,现引用一下:[@more@]条件1在分析(analyze)指定索引之后,查询index_stats的height字段的值,如果这个值>=4 ,则最好重建(rebuild)这个索引。虽然这个规则不是总是正确,但如果这个值一直都是不变的,则这个索引也就不需重建。条件2在分析(analyze)指定索引之后,查询index_stats的del_lf_rows和lf_rows的值,如果(del_lf_rows/lf_rows)*100 > = 20,则这个索引也需要重建。例子:SQL > analyze index IND_PK validate structure;SQL > select name,height,del_lf_rows,lf_rows,(del_lf_rows/lf_rows) *100 from
oracle 10g的connect by bug修复
在系统升级到10g后,碰到了一些connect by的bug。如:select">select AvGroupLevel, AvGroupCode, AvGroupCodeParent2 from AvGroupCodeTable where SUBSTR(NLS_LOWER(DataAreaId),1,3) = SUBSTR(NLS_LOWER('845'),3 START WITH AvGroupCode = '110'4 CONNECT BY PRIOR AvGroupCodeParent = AvGroupCode5 and SUBSTR(NLS_LOWER(DataAreaId),1,3) = SUBSTR(NLS_LOWER('845'),1,3)6 order by AvGroupLevel DESC7 ;and SUBSTR(NLS_LOWER(DataAreaId),1,3) = SUBSTR(NLS_LOWER('845'),1,3)*ERROR at line 5:ORA-00600: internal error code
export中涉及到时区的问题
由于在一台server中既有美国的数据库,又有菲律宾的数据库,因此,就存在一个市区(TimeZone)的问题。现在服务器以美国的时间的为准,则菲律宾的db在重起listener及重起库时,需要加export TZ=GMT-8。同时,菲律宾的db备份采用export。在备份参数中,用了consistent=y。在备份log中却发现了以下错误:EXP-00056: ORACLE error 1466 encounteredORA-01466: unable to read data - table definition has changed这也是与timezone有关,解决方法有:1.去掉参数consistent=y2.在备份脚本中加export TZ=GMT-8[@more@]
Rman -按时间进行不完全恢复-restore archivelog
在日常恢复中,我们会遇到这样一种情况,当我们在脚本用set until time "to_date('20080520 12:00:00','YYYYMMDD hh24:mi:ss')";设置了restore controlfile,restore datafiles之后.我们怎么找到我们想恢复的archive log?[@more@]可以这样:1.在rman中,列出某个时间段所涉及到的archivelog: rman> list backup of archivelog time between "to_date('2008-05-20 00:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2008-05-20 12:00:00','yyyy-mm-dd hh24:mi:ss')";2.根据内容,在恢复脚本中列出所需要的arc
oracle 10g exp ORA-00932 错误
EXP-00056: ORACLE error 932 encounteredORA-00932: inconsistent datatypes: expected BLOB, CLOB got CHAREXP-00056: ORACLE error 932 encounteredORA-00932: inconsistent datatypes: expected BLOB, CLOB got CHAREXP-00000: Export terminated unsuccessfully要解决这个错误,需要运行2个脚本:1.sql>@?/rdbms/admin/catmetx.sql2.sql>@?/rdbms/admin/utlrp.sql 运行完问题解决。[@more@]
用optimizer_index_cost_adj让sql走索引
在OLTP系统中,设置参数optimizer_index_cost_adj的值从1-50,可以让oracle趋向于走索引。通过实践证明,it works[@more@]
10g 自动内存管理--当前各参数值的的大小
10g开始,内存参数如shared_pool_size,db_cache_size在sqlplus中用show parameters都会显示为0,那么在当前状态下如何获得各个pool的值呢?[@more@]1.data buffer pool:SQL> select current_size from v$buffer_pool;CURRENT_SIZE------------33122.其他的poolSQL> select pool,sum(bytes)/1024/1024 from v$sgastat group by pool;POOL SUM(BYTES)/1024/1024------------ --------------------3327.99767shared pool 736.00457large pool 16java pool 16
读后感:oracle性能调整 Shared pool深入分析及性能调整
今天在网上读了文章:oracle性能调整 Shared pool深入分析及性能调整。在这篇文章中,对以下问题做了比较深刻的解释:1.为什么程序中引用了绑定变量可以加快效率2.ORA-04031的成因[@more@]1.为什么程序中引用了绑定变量可以加快效率oracle 对sql语句的解析实际上生成执行计划。在生成执行计划时是需要消耗资源的。为了实现这一过程,oracle实际上对sql语句进行了概括与抽象。将sql语句分成静态与动态两部分。静态部分包括oracle的关键字,如select,from等,以及表名,列名等。而动态部分实际上就是数据。静态部分是有限的小部分,而数据是
Windows平台 用邮件方式发送export备份情况
windows平台,对于export备份,希望能在备份结束后将出错信息发给相关人员。可以这么做:[@more@]1.写export的bat文件:set nls_lang=AMERICAN_AMERICA.WE8MSWIN1252EXP username/password@service_name FILE=*.dmp LOG=*.LOG FULL=Y COMPRESS=Ntype *.LOG | find "Export terminated successfully without warnings."IF ERRORLEVEL 1 GOTO SendAlertGOTO End:SendAlertcscript D:DBEXPBackupAlert.vbs:End2.BackupAlert.vbs:Option ExplicitDim objMessage, strReceiver, strSender, strSubject, strContent, strAttachmentst
对表归档的一个思路及方法
随着数据库的日渐庞大,有时需要进行归档。以下是一些思路:1.新建一个表空间存放各表的历史数据。1.1写一个存储过程搬数据,数据搬迁到历史表后,在基表中将搬迁的数据删除。2.定期将历史数据exp到磁带中去做永久保存。3.历史数据exp之后,可以清空各历史数据表。这样,表空间的大小实际上是很容易伸缩及控制的。在这个过程当中,我们可以看到基本的数据由于可以定期清理到历史数据表,继而再清理到磁带。因此,数据库不会越来越大。方便备份及减少查询时间。具体的实现过程如下:[@more@]procedure的思路是:1.创建临时表:CREATE GLOBA
10g的一个bug:'IN' IS NOT A VALID INTEGER VALUE
今天在调试一个procedure的时候,需要有这样的一个语句:insert into table_a select rowid from table_b where...调试过程中报'IN' IS NOT A VALID INTEGER VALUE错。以下是解决过程:[@more@]解决方法:1.以sys登陆,将view:ALL_ARGUMENTS 改名以做backup。2.运行以下sql:CREATE OR REPLACE VIEW ALL_ARGUMENTS (OWNER, OBJECT_NAME, PACKAGE_NAME, OBJECT_ID, OVERLOAD, ARGUMENT_NAME, POSITION, SEQUENCE, DATA_LEVEL, DATA_TYPE, DEFAULT_VALUE, DEFAULT_LENGTH, IN_OUT, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, RADIX, CHARAC