| « | 五月 2012 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
alter index invisible/visible; alter table read only|write;
so cool!
查看全文"OPT_PARAM" is a new optimizer hint introduced in 10g Release 2. This hint behaves the same way as setting a parameter (e.g, using alter session) except that the effect is for the statement only. (Notes 377333.1) 查看全文
以前,我没有太关注过large pool,现在需要关注它了,请见metalink note 62140.1 查看全文
如果一个数据库的system表空间是LMT的,那么不能在该数据库中创建DMT的表空间,只能创建LMT的表空间 查看全文
在create index online, alter index rebuild online时,oracle是怎么工作的?
查看全文
我想查询数据库每天产生多少归档日志,可是有些数据库只能查到最近一两天的日志,感觉很奇怪,查了metalink,发现了原因
查看全文Note:159063.1 查看全文
Note 171795.1 查看全文
Note:205260.1 查看全文
Select to show Optimizer Statistics for CBO,Note:31412.1 查看全文
Note:236026.1 查看全文
Note:352582.1 查看全文
Note:164661.1 查看全文
LOCK: MR "Media Recovery"
Note:34647.1 查看全文
Editing Stored Outlines in Oracle9i - an example,note 144194.1 查看全文
年终岁末,终于明白了执行计划稳定性,看如下例子: 查看全文
worth reading 查看全文
参考如下文章 查看全文
library cache lock与library cache pin之间有什么关系? 查看全文
朋友msn上告诉我,他同学管理的数据库,断了两次电后,起不来了 查看全文
metalink Note:62364.1
metalink Note:28934.1 查看全文
metalink Note:276877.1,原文标题是:
How the performance of the query is influenced by its predicate order
Jonathan Lewis的大作 查看全文
tom给出的例子 查看全文
该参数自oracle 10g Release 1引进 查看全文
很早就注意到这个提示,但是一直没有找到它的详细解释,以oracle cardinality hint为关键字,搜索到几篇文档 查看全文
Jonathan Lewis的新作! 查看全文
今天在metalink上看到的一篇文档,很好地解释了这个问题 查看全文
metalink Note:17613.1,一篇全面介绍ora-3113的文章
今天,本人在metalink note30910.1发现一个有趣的事情 查看全文
The RESTORE command supports a PREVIEW option, which identifies the backups (backup sets or image copies, on disk or sequential media like tapes) required to carry out a given restore operation 查看全文
10g里,rman的功能真是增加了不少,除了encryption, compress之外,竞然有这个功能:可以直接删除数据库! 查看全文
很早就知道oracle备份hwm下的所有块,包括hwm之下的empty block。为什么呢,却没有想过。metalink note 153896.1给出了解释。道理很简单,但是很少有人能够想得到。
查看全文
metalink Note:30405.1
以前虽然我也读了不少关于索引内部结构的文章,感到仍然从这篇文章上收获不少。
查看全文
今天,久别了3天的metalink终于又能访问了,喜不自胜,上来搜索,果然没又有新收获!发现了一个好文:Note:296377.1
查看全文
列上的统计信息是如何影响cbo对于连接方法的选择的? asktom上,看到一个读者提问:
I dont see how statistics of a column help in a join, if let's say hash join is best then shouldnt that decision based on number of rows in both tables...? If nested loop is used shouldnt the statistics on the indexed column be enough?
查看全文在metalink note 116540.1 指出,如果在create or replace view后,该视图对应的权限丢失,那么将是一个bug。 查看全文
metalink note 234551.1 查看全文
何为stuck recovery?简单地说,就是恢复进行不下去了.看看oracle文档和metalink里如何解释: 查看全文
metalink note 186137.1 查看全文
刚才浏览metalink note 69637.1,知道disable validate约束,竟然会drops the index on the constraint! 查看全文
metalink Note:113450.1 查看全文
metalink Note:10640.1,看了之后应该更加熟悉表的结构,索引的结构,以及它们占有空间的计算方法。
最近,看到有人问statspack中,Execute to Parse为负值表示什么意思?参考http://www.itpub.net/593755.html
恰好我也不是特别清楚,就查阅了相关文档 查看全文
metalink 167492.1 提供了2种方法 查看全文
在学习oracle的时候,我们有时遇到一些内部表,他们的名字看起来很怪异,但是,这些表的命名是有来历的。到底是怎么的一个来历呢?刚才我在google新闻组里以 x$ktuxe 为关键字搜索,偶然发现这样一个帖子,讲述了 x$ 表命名的由来。虽然改贴显示资料来自metalink,我到metalink搜索,已经找不到了
查看全文在asktom上,看tom解释backup and recovery是比较少的,他回答的问题,开发与优化类的居多。昨天itpub上的一个问题使我想起了tom回复的这个帖子 查看全文
http://www.akadia.com/services/ora_parallel_processing.html#Parallel%20Query
又一个有意思的问题 查看全文
最近在研读performance tuning guide,并且在metalink里搜索与bitmap index有关的资料,发现了这个我以前不了解的bitmap index特性。 查看全文
analyze与dbms_stats包,是oracle的两个常用的工具,然而,由于涉及的方面太多,全面了解它们的应用并不容易。比如,涉及到分区表时 查看全文
一个来自metalink,一个来自asktom 查看全文
今天在metalink上逛,看了note:262948.1 ,随后,使用google搜索,又搜索到一个帖子 查看全文
今天在试验cursor_shaing参数对于不使用绑定变量时的影响,不想搜索到若干篇文档,讲述了在什么情况下,When Cursor_Sharing=Similar/Force do not Share Cursors When Literals are Used。对我来说,关注此问题,来源于itpub上的一篇帖子
查看全文
如果设置cursor_sharing=similar,那么:Causes statements that may differ in some literals, but are otherwise identical, to share a cursor, unless the literals affect either the meaning of the statement or the degree to which the plan is optimized.
本文针对此,做了试验!
查看全文note 269814.1 查看全文
这个问题,很久之前就已经注意到,并且感到很疑惑,但是没有深入思考,今天,终于看到了tom对此问题的解答 查看全文
自从去年夏天,本人就曾经偶尔思考完全检查点与增量检查点的问题,本人将自己的一些自己认为是正确的理解写下,供各位朋友来指点,以便更清晰地理解概念
查看全文看了如下例子,就会明白instead of trigger是干什么的 查看全文
本人一直没有从理论上明白这个问题。看oracle 的concepts,也没有看明白为什么。用google搜索,也没有找到理想的解释。自己试验,只是知其然,不知其索引然!如何从理论上解释呢? 查看全文
This is a script that shows the hierarchical relationship between system privileges, roles and users. 查看全文
metalink Note: 262384.1 查看全文
最近,现场传来消息,系统(ibm aix5L+oracle 9201)抛出错误ora-4030,数据库大概每隔一个月需要重新启动一次 查看全文
Nice! 查看全文
学习大师的思想 查看全文
http://www.itpub.net/529064.html
比较有用 查看全文
令人耳目一新 查看全文
Tom的方法 查看全文
读了之后受益匪浅,原来对于约束,这个几乎天天都打交道的东西,自己竟然还有那么的未知的地方 查看全文
optimizer_index_cost_adj的意思就是:如果设置为100,认为全表扫描和走索引的代价一样,如果optimizer_index_cost_adj为30,优化器认为走索引的代价是全表扫描代价的30%;如果设置为300,优化器认为走索引的代价是全表扫描的3倍。 查看全文
今天在网上搜索,发现了一篇文章,讲述oracle对于主键约束与主键索引的机制的文章,我按照该文进行了验证,发现原来主键竟然可以这样....
查看全文asktom上看到的 查看全文
原文出自:
http://dev.yesky.com/SoftChannel/72342371928965120/20021029/1637243_2.shtml
查看全文接着以前做的试验. 会了,就不难! 查看全文
数据库版本,9207, 目标数据库名称CLONE, 辅助实例 AUX1 查看全文
环境,widnwos 2000 server, oracle 9207
目标数据库名bjsignaldev,
恢复目录数据库名csorasvr,
克隆数据库名clone
根据metalink 124083.1和183377.1整理 查看全文
很有用的例子,参考metalink Note:137181.1
针对metalink note 243847.1 的试验 查看全文
从知道这个概念,到彻底理解它,运用它,花了不短的时间,现在以一个试验来演示incarnation的运用 查看全文
今天,在浏览metalink中关于rman的文章时,发现此文(note 237232.1)。关于该文中所讲述的问题,我以前即有试验,过程为: http://blog.itpub.net/post/5073/46414 仔细看该文章,仍然有收获,因为它采用了我以前没有使用过的方法:incarnation。先将此文转贴出来,然后将利用试验验证
根据metalink note 223569.1, 只有RMAN能移动或者改变备份集的位置。在一些场合下,为了维护方便,我们需要改变备份集的位置。
查看全文在sqlplus下,可以通过set timing on来做到这一点,rman下呢?我找到了metalink notes 204986.1 查看全文
很有用的oracle shell管理脚本 查看全文
1 如何修改statspack的脚本产生自定义报表?
2 如何用statspack的报表确定热表及索引?
3 如何用statspack的报表确定keep池与default池的分配?
4 如何用crontab定期产生statspack的报表?
今天,在看metalink上一篇文章:Temporary Tables and Redo Generated,Note 94402.1,中间有这么一段话:
DML statements on temporary tables do not generate redo logs for the data changes. However, undo logs for the data and redo logs for the undo logs are generated
我做试验验证了一下
查看全文最近,因为常常需要对大表进行操作,所以,对于nologging的需要也更加多了,系统地看了一些关于nologging的文章,如下是tom给出的一个nologging与append对应表 查看全文
这两天为数据库性能问题头疼,问题之一在于一些比较重要的sql里有一些子查询,它们能过滤掉很多记录,如果能控制它们先运行,就能使性能有大幅提高... 查看全文
今天晚上看Tom的expert one-on-one,第三章“封锁与并行性”,对ddl有新的认识... 查看全文
整理一下 查看全文
现场的同事问我:如何才能限制某用户同时登录数据库的次数? 查看全文
读了"关于recovery through resetlogs的研究和探讨"一文,自己反复做试验重复了其步骤。过程中间,加深了对很多概念的理解和掌握
查看全文在安装过程中,提示换第二张光盘,可是就是不能unmount,到网上查怎么回事,原来..... 查看全文
自己的学习笔记:) 查看全文
从今天开始,把一些遇到的很小很小的技巧,陆续以回帖的形式发布,以备以后查阅方便
作业运行时间间隔要求:周一,三,五晚上是21点运行,周二,四,六晚上6点运行 查看全文
由biti_rainy起的一个帖子"关于新建数据文件无备份的恢复"(http://www.itpub.net/326938.html),引起了很多讨论。本人也认真地阅读了几遍,受益非浅,可是,对于由Kamus使用的一个方法,本人在试验时,发现了一些问题。通过如下2个试验,我们不难发现端倪: 查看全文
我昨天做数据库的备份与回复试验,遭遇了一次ORA-600 2662错误,按照metalink文档上的提示,重复启动数据库达76次,才把数据库打开! 查看全文
非归档模式下,只有从联机日志文件里恢复数据库了,那么,什么情况下能恢复,什么情况下不能恢复呢? 查看全文
没有备份,只有归档日值,如何恢复数据文件? 查看全文
shhutdown abort的情况下,删除所有控制文件和联机重做日志文件 查看全文
shutdown immediate情况下,所有的控制文件和联机重做日志文件丢失 查看全文
进来非常多地使用sql_trace与10046事件,现在把使用方法简要介绍如下:) 查看全文
本文用10046事件来解析alter index rebuild与alter index rebuild online的区别
查看全文metalink Note:39836.1 查看全文
改视图显示一个特定了子游标没有与已经存在的子游标共享的原因,我将用两个试验说明之。 查看全文
在刚开始接触的oracle的时候,就知道了这个概念:sql重用。可是,什么样子的sql才算是相同的sql?也就是identical sql statement?接下来的几天,我将把精力集中于这个问题。首先,让我们先看一个连接:
http://www.adp-gmbh.ch/ora/misc/hard_parse_vs_soft_parse.html
转载metalink Note 39817.1 查看全文
我们在导出数据块时,常常看到如下内容:
BH (0x17BF9888) file#: 11 rdba: 0x02c07c69 (11/31849) class 1 ba: 0x17AFC000
那么,rdba是如何计算得来的呢?
查看全文8月10号,业主的数据库出现重大故障。 查看全文
如下试验 查看全文
X$BH里的几个字段的含义: 查看全文
数据库从9.2.0.1升级到9.2.0.6之后,在进行删除用户的操作时,报如下错误:
ORA-00600: 内部错误代码,参数: [qmxiUnpPacked2], [121], [], [], [], [], [], []
Current SQL statement for this session:
drop user chenyan
oracle的内部表 查看全文
一般来说,从低版本导入到高版本问题不大,麻烦的是将高版本的数据导入到低版本中,在Oracle9i之前,不同版本Oracle之间的EXP/IMP可以通过下面的方法来解决:
查看全文
X$KSMLRU
[K]ernal [S]torage [M]emory Management
Least recently used shared pool chunks
[LRU] flushes from the shared pool 查看全文
metalink文章:Note:131272.1 查看全文
关于library cache pin的简单介绍,Note:34579.1 查看全文
metalink文章:Note:22908.1 查看全文
metalink文章Note:122793.1 查看全文
转自metalink的一篇文章,Note:264476.1 查看全文
使用utl_inaddr包时遭遇bug,出现错误ORA-29257,note 243012.1描述了这个bug!
真是歪门邪道:) 查看全文
1 rman对数据库全备份(使用恢复目录)
2 关闭数据库,删除所有控制文件和数据文件
这种情况下,如何恢复数据库?不能搬Fenng在
http://www.itpub.net/244345.html里的步骤,因为我是使用恢复目录的,希望能比他的恢复步骤简便一些
本文是看了Fenng的文章后自己做的试验,
http://www.itpub.net/244345.html
本实验的场景和他的不完全相同,这里的场景是:有2个RMAN的备份集(RMAN备份时没有用恢复目录),在做完第二次备份后,关闭数据库,删除所有数据文件和控制文件。然后尝试用这两个备份集恢复数据库。本文中,从第二个(后做的)备份集先恢复控制文件,然后,从第一个(先做的)备份集恢复数据文件。本文用的是oracle9.2.0.1
查看全文学习使用rman的入门问题 查看全文
昨天下午,同事告诉我,他们开发的高速公路收费与监控程序时不时出现ORA-01000:超出最多允许打开的游标数。 查看全文
以前,对于cursor没有太多的研究,今天同事遇到了ORA-01000:超出最多允许打开的游标数,使我决心对游标搞个水落石出。也请各位高人指点。谢谢! 查看全文
刚好能解答我上面遇到的问题 查看全文
环境:windows 2000 + Oracle 9.2.0.1
在学习Oracle 9i的新特性flashback query,可是遇到了一个很奇怪的问题:我几乎是按照 metalink Note 143217.1 一文中描述的步骤,可是就是不能达到预期效果,如下是试验过程,请指点迷津,谢谢! 查看全文
在看与内存有关的内容,发现了这两个视图,感觉比较有用,先记下来:) 查看全文
Oracle的dbms_job是执行定时作业的很好的方式,可是,作业执行时间与设定时间之间总是有一定的误差。在oracle 9i中,隐含参数“_job_queue_interval”可以控制误差的范围
查看全文查询v$sysstat视图时,发现有这一项:redo wastage,代表什么意思呢?在大师的网站上,也有如下链接:http://www.ixora.com.au/notes/redo_wastage.htm 。可是读后仍然甚为不解,网上发贴,飞龙兄指点迷津:) 查看全文
本文为Oracle的重要视图v$sysstat提供了一个完整的解释列表,原文发表在:
http://www.mercury.com/us/products/performance-center/loadrunner/monitors/oracle.html
查看全文昨天发生的一件怪事。实际上,没有无缘无故的怪事,原来,删除4万条数据用了近1个半小时是事出有因! 查看全文
原文如下:
http://www.ixora.com.au/notes/log_switch_steps.htm
查看全文
写得很不错,原贴在:
http://www.itpub.net/showthread.php?threadid=171105
查看全文总结一下,印象更深刻,有利于学习备份与恢复:) 查看全文
这里转载一些比较简短实用的部分,原文链接如下:
http://dev.csdn.net/article/52/article/53/article/53/53546.shtm
查看全文
进来,在学习备份与恢复。随着学习的深入,越来越深入的感觉到:为了更好的了解备份与恢复,必须要深入学习体系结构以及Oracle的工作机理。通过biti的指点,在www.ixora.com.au上找到了一篇好文:SCN values used for recovery。其中最后一部分现在并不是特别明白,但是先把该文的理解写一下,其中,前两个试验,是我自己做的;后一个是引用的原文的。原文链接: http://www.ixora.com.au/q+a/0102/09221408.htm
查看全文通过转储控制文件头,我们可以清晰地看出控制文件头中包含哪些信息 查看全文
有助于深入理解oracle的机制 查看全文
很久的一个疑问,今天终于彻底得解:) 查看全文
场景如下:
1. 备份控制文件
2. 添加数据文件
3. 关闭数据库,并删除所有控制文件和新增的数据文件
如何恢复?请参照如下试验:) 查看全文
关于core dump的简单介绍 查看全文
ora-07445是与ora-600类似的错误,都是那么棘手,现在转载metalink上介绍 ora-07445的文章 note 211909.1
查看全文建议onlie redo logfile设置多大合适 查看全文
Oracle为了减少非计划当机时间,引入了一些参数来控制它。本文从FAST_START_MTTR_TARGET参数入手,介绍了一些影响非计划当机的参数 查看全文
ora-600[12700][a][b][c]错误的简单介绍 查看全文
早就听说ora-600错误变化多端,比较神秘,很早就想猎奇。今天,在网上到处浏览时,潜心看了关于ora-600的一些metalink,结合网上一个帖子,找到了这个与jdbc驱动有关的bug的解决方法!
查看全文
在写这篇短文的当天上午,本人还对这两个参数感到很陌生,只是偶尔的注意过有这两个参数,但是从来没有研究,没有认真地看过。查阅各种文档,终于对这两个参数有了一点认识
查看全文
控制文件是Oracle数据库中极其重要的文件。它记录着数据库的关键信息。什么情况下需要重建控制文件?如何重建控制文件?本文翻译了metalink, Note:1012929.6,对上述两个问题给出了回答。
查看全文
如果当前联机日志文件损坏,那么,加入在pfile中加入参数 _allow_resetlogs_corruption=true,可以解决问题!
查看全文联机日志可以分为当前连机日志文件和非当前联机日志文件。这里模拟了非当前联机日志文件损坏发生时处理问题的方法 查看全文
基于SCN的恢复 查看全文
备份spfile的意义在于:我用RMAN自动备份了SPFILE。那么,如果有一天,spfile,pfile都丢失了或者损坏了,那么数据库不能startup nomount了。这时,我可以手工新创建一个pfile,一些参数设置可能与丢失前的spfile、pfile不一致,但是不要紧,我可以先把数据库nomount。在此状态下,可以利用RMAN恢复spfile。就把spfile恢复到丢失以前的状态了。
查看全文
经过昨天晚上2个小时,今天早上2个小时,今天晚上半小时,终于成功配置了Oracle 9.2 Data Guard!
高兴!将把配置过程详细整理出来!
有助于internal的理解:) 查看全文
根据asktom上的例子,模拟出现Ora-1555错误 查看全文
摘自metalink 查看全文
metalink Note:40689.1,非常好的讲述经典错误ora-01555的文献 查看全文
今天在业主处用imp导入数据的时候,当导入导一个具有long raw字段的表时,遭遇错误IMP-00020! 查看全文
转载自biti的blog 查看全文
Oracle 9i提供了一个dbms_metadata包,可以得到建立各种数据库对象的语句。今天,因为工作需要,尝试使用了一下! 查看全文
根据asktom上的例子,自己就索引组织表做了一些试验。 查看全文
前几天,因有人误删了所有的设备数据,使得我边学习边实践,将新学习的知识马上应用于实践,从而加深了印象:) 查看全文
在Oracle 9i 中,一个新的文件 ——spfile被引入,用于服务器端,管理初始化参数。 查看全文
dbms_transaction包中的函数 查看全文
Oracle的锁的简单介绍 查看全文
由于对public权限的不了解,在一个关于权限的试验中,我执行了如下语句
revoke select any table from public;引起了严重的后果——所有的package失效!
查看全文Oracle能否控制字段权限? 查看全文
session_cached_cursors参数的影响
can you explain what means the default value (0) of session_ casched_cursor
parameter? Oracle always has a cache
of sqls in sga and size of this cache is determinated through init.ora parameter
shared_pool_size.
Followup:
The default value of ZERO means that by default, ZERO cursors will be cached for
your session.
They will be cached in the shared pool -- but your session will have to find
them there. Session Cached Cursors can remove the need to have to "find" them.
Consider this example that shows the difference spent when soft parsing without
session cached cursors vs soft parsing WITH session cached cursors:
ops$tkyte@ORA817DEV.US.ORACLE.COM> create table emp as select * from scott.emp;
Table created.
ops$tkyte@ORA817DEV.US.ORACLE.COM> create table run_stats ( runid varchar2(15),
name varchar2(80), value int );
Table created.
ops$tkyte@ORA817DEV.US.ORACLE.COM> create or replace view stats
2 as select 'STAT...' || a.name name, b.value
3 from v$statname a, v$mystat b
4 where a.statistic# = b.statistic#
5 union all
6 select 'LATCH.' || name, gets
7 from v$latch;
View created.
ops$tkyte@ORA817DEV.US.ORACLE.COM> column name format a40
ops$tkyte@ORA817DEV.US.ORACLE.COM> declare
2 l_start number;
3 l_cnt number;
4 begin
5 execute immediate 'alter session set session_cached_cursors=0';
6 insert into run_stats select 'before', stats.* from stats;
7
8 l_start := dbms_utility.get_time;
9 for i in 1 .. 1000
10 loop
11 execute immediate 'select count(*) from emp' into l_cnt;
12 end loop;
13 dbms_output.put_line( (dbms_utility.get_time-l_start) || ' hsecs' );
14
15 execute immediate 'alter session set session_cached_cursors=100';
16 insert into run_stats select 'after 1', stats.* from stats;
17
18 l_start := dbms_utility.get_time;
19 for i in 1 .. 1000
20 loop
21 execute immediate 'select count(*) from emp' into l_cnt;
22 end loop;
23 dbms_output.put_line( (dbms_utility.get_time-l_start) || ' hsecs' );
24
25 insert into run_stats select 'after 2', stats.* from stats;
26 end;
27 /
45 hsecs
35 hsecs
PL/SQL procedure successfully completed.
so, session cached cursors RAN faster (i ran this a couple of times, there
were no hard parses going on. But the real good news is:
ops$tkyte@ORA817DEV.US.ORACLE.COM> select a.name, b.value-a.value run1,
c.value-b.value run2,
2 ( (c.value-b.value)-(b.value-a.value)) diff
3 from run_stats a, run_stats b, run_stats c
4 where a.name = b.name
5 and b.name = c.name
6 and a.runid = 'before'
7 and b.runid = 'after 1'
8 and c.runid = 'after 2'
9 and (c.value-a.value) > 0
10 and (c.value-b.value) <> (b.value-a.value)
11 order by abs( (c.value-b.value)-(b.value-a.value))
12 /
NAME RUN1 RUN2 DIFF
---------------------------------------- ---------- ---------- ----------
LATCH.checkpoint queue latch 3 4 1
LATCH.redo allocation 30 31 1
STAT...consistent gets 5088 5089 1
STAT...deferred (CURRENT) block cleanout 2 3 1
applications
STAT...calls to get snapshot scn: kcmgss 5019 5018 -1
STAT...enqueue releases 10 9 -1
STAT...execute count 1015 1014 -1
STAT...opened cursors cumulative 1015 1014 -1
STAT...parse count (total) 1015 1014 -1
STAT...session cursor cache count 0 1 1
STAT...redo entries 28 27 -1
STAT...recursive calls 1180 1179 -1
STAT...physical reads 1 0 -1
LATCH.direct msg latch 2 0 -2
LATCH.session queue latch 2 0 -2
LATCH.done queue latch 2 0 -2
STAT...free buffer requested 8 6 -2
STAT...enqueue requests 11 9 -2
LATCH.messages 3 0 -3
STAT...db block changes 47 44 -3
LATCH.redo writing 3 0 -3
LATCH.ksfv messages 4 0 -4
STAT...session logical reads 17128 17123 -5
LATCH.row cache objects 184 178 -6
STAT...db block gets 12040 12034 -6
STAT...parse time elapsed 9 3 -6
STAT...parse time cpu 13 4 -9
STAT...recursive cpu usage 51 38 -13
LATCH.cache buffers chains 34315 34335 20
STAT...redo size 23900 24000 100
STAT...session cursor cache hits 3 1002 999
LATCH.shared pool 2142 1097 -1045
LATCH.library cache 17361 2388 -14973
34 rows selected.
ops$tkyte@ORA817DEV.US.ORACLE.COM>
see the significantly REDUCED number of LATCH counts on the library and shared
pool. Since a latch is a lock, a lock is a serialization device, serialization
implies WAITS -- using the session cached cursors will increase scalability and
performance as you add more and more users. Its not only FASTER, but more
scalable as well...
Tom 解释软解析与硬解析的区别:
Hi Tom
Can you explain briefly the difference between soft and hard parse?
cheers
and we said...
Here is a long winded answer, it is extracted in part from a new book coming out
soon "beginning Oracle programming" that I collaborated on:
Parsing
This is the first step in the processing of any statement in Oracle. Parsing is
the act of breaking the submitted statement down into its component parts ?
determining what type of statement it is (query, DML, DDL) and performing
various checks on it.
The parsing process performs two main functions:
o Syntax Check: is the statement a valid one? Does it make sense given the SQL
grammar documented in the SQL Reference Manual. Does it follow all of the rules
for SQL.
o Semantic Analysis: Going beyond the syntax ? is the statement valid in light
of the objects in the database (do the tables and columns referenced exist). Do
you have access to the objects ? are the proper privileges in place? Are there
ambiguities in the statement ? for example if there are two tables T1 and T2 and
both have a column X, the query ?select X from T1, T2 where ?? is ambiguous, we
don?t know which table to get X from. And so on.
So, you can think of parsing as basically a two step process, that of a syntax
check to check the validity of the statement and that of a semantic check ? to
ensure the statement can execute properly. The difference between the two types
of checks are hard for you to see ? Oracle does not come back and say ?it failed
the syntax check?, rather it returns the statement with a error code and
message. So for example, this statement fails with a syntax error:
SQL> select from where 2;
select from where 2
*
ERROR at line 1:
ORA-00936: missing expression
While this statement failed with a semantic error ? if the table NOT_A_TABLE
existed and we had permission to access it, this statement would have succeeded:
SQL> select * from not_a_table;
select * from not_a_table
*
ERROR at line 1:
ORA-00942: table or view does not exist
That is the only way to really tell the difference between a semantic and
syntactic error ? if the statement COULD have executed given the proper objects
and privileges, you had a semantic error, otherwise if the statement could not
execute under any circumstances, you have a syntax error. Regardless ? Oracle
will not execute the statement for you!
The next step in the parse operation is to see if the statement we are currently
parsing has already in fact been processed by some other session. If it has ?
we may be in luck here, we can skip the next two steps in the process, that of
optimization and row source generation. If we can skip these next two steps in
the process, we have done what is known as a Soft Parse ? a shorter process
to getting our query going. If we cannot, if we must do all of the steps, we
are performing what is known as a Hard Parse ? we must parse, optimize,
generate the plan for the query. This distinction is very important. When
developing our applications we want a very high percentage of our queries to be
Soft Parsed ? to be able to skip the optimize/generate phases ? as they are
very CPU intensive as well as a point of contention (serialization). If we have
to Hard Parse a large percentage of our queries, our system will function
slowly and in some cases ? not at all.
The way this sharing of SQL in Oracle is accomplished is via the shared pool, a
piece of memory in the SGA maintained by Oracle. We covered this topic in
chapter 5 but will revisit is again in the context of processing a query. After
Oracle parses the query and it passes the syntax and semantic checks ? it will
look in the shared pool component of the SGA to see if that same exact query has
already been processed by another session. Since it has performed the semantic
check it has already figured out:
o Exactly what tables are involved
o That we have access to the tables (the proper privileges are there)
And so on. Now, it can look at all of the queries in the shared pool that have
already been parsed/optimized and generated to see if the work has already been
done.
........
关于v$sql中三个mem字段的含义
本问题原发表于itpub:
http://www.itpub.net/336646.html
SQL> desc v$sql
名称 是否为空? 类型
----------------------------------------- -------- --------------------
SQL_TEXT VARCHAR2(1000)
SHARABLE_MEM NUMBER
PERSISTENT_MEM NUMBER
RUNTIME_MEM NUMBER
.......................
关于这三个字段,意义一直不明白,查阅了metalink,解释如下
SHARABLE_MEM
Amount of shared memory, in bytes, used by this child cursor
PERSISTENT_MEM
Fixed amount of memory, in bytes, used for the lifetime of this child cursor
RUNTIME_MEM
Fixed amount of memory required during the execution of this child cursor
这三个字段之间的联系与区别呢?此外,什么叫child cursor?
我们知道,一个sql,被解析后,在library cache存放有
1. sql语句文本
2. 分析树(编译后的语句)
3. 执行计划(optimizer定义的语句执行步骤)
解释如下(http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:6590760178912):
xinjingcool:
文本相同,引用对象或schema不同(PARSING_USER_ID,PARSING_SCHEMA_ID),就会产生child cursor,
他的parent cursor 在V$sqlarea中
jametong:
1. 当有字段使用绑定变量的时候, 绑定的变量的大小不同也可能产生相同的hash_value,address,
但是产生不同的child_cursor.
quote:
--------------------------------------------------------------------------------
SQL> create table t(col1 varchar2(200));
Table created.
SQL> declare
2 v_col1 varchar2(200);
3 begin
4 v_col1 := 't';
5 for i in 1..199 loop
6 v_col1 := v_col1 ||'t';
7 insert into t values(v_col1);
8 end loop;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> col sql_text format a60
SQL> select sql_text,executions,child_number
2 from v$sql
3 where parsing_user_id = 59
4 and sql_text like '%INSERT INTO T%'
5 /
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
CHILD_NUMBER
------------
INSERT INTO T VALUES(:B1 ) 31
0
INSERT INTO T VALUES(:B1 ) 96
1
INSERT INTO T VALUES(:B1 ) 72
2
从这个结果, 我们可以看出, 当执行次数达到31一次即变量的长度为32时产生第一次变化,
变量长度达到96 + 32 = 128 时产生第二次变化,
SQL_TEXT EXECUTIONS
------------------------------------------------------------ ----------
CHILD_NUMBER
------------
select sql_text,executions,child_number from v$sql where par 1
sing_user_id = 59 and sql_text like '%INSERT INTO T%'
0
SQL> spool off
Jametong
quote:
--------------------------------------------------------------------------------
The persistent area is stuff that can be shared across all sessions -- the query
itself for example.
persistent area应该是对应于persistent_mem,也是多个session之间共享的,比如说这条sql语句本身
The runtime or session specific area is the state variables YOUR session has
maintained regarding that cursor -- eg: the SCN in place at the time your query
began. The current location a result set you might be. Things specific to your
session.
runtime_area or session specific area应该是对应于这边的runtime_mem, 主要用户存储当前
session的一些与这条sql语句相关变量,比如sql语句开始时的scn,当前cursor的position,对应的内
存为UGA中的内存块
The result set is not part of the cursor -- it is pointed to by a cursor perhaps
but not part of.
(this discussion should also point out why we cannot tell you how many rows a
query will return when you open it - we ourselves most likely have no idea --
we do not prebuild result sets in general)
--------------------------------------------------------------------------------
sharable_mem 应该就是我们的库缓存中的对应的编译后的代码的所占用的内存了, 这是存放在library
cache中的内存块
quote:
--------------------------------------------------------------------------------
Private SQL Area
A private SQL area contains data such as bind information and runtime memory structures.
Eachsession that issues a SQL statement has a private SQL area. Each user that submits
the same SQL statement has his or her own private SQL area that uses a single shared
SQL area. Thus, many private SQL areas can be associated with the same shared SQL area.
The private SQL area of a cursor is itself divided into two areas whose lifetimes are
different:
* The persistent area, which contains, for example, bind information. It is freed only
when the cursor is closed.
persistent area在Private sql Area中. 包含当前cursor的绑定信息
* The run-time area, which is freed when the execution is terminated.
Oracle creates the runtime area as the first step of an execute request. For INSERT,
UPDATE, and DELETE statements, Oracle frees the runtime area after the statement has
been run. For queries, Oracle frees the runtime area only after all rows are fetched
or the query is canceled.
The location of a private SQL area depends on the type of connection established for
a session. If a session is connected through a dedicated server, private SQL areas
are located in the server process's PGA. However, if a session is connected through
a shared server, part of the private SQL area is kept in the SGA.
--------------------------------------------------------------------------------
如何通过SQL语句判断当前的SQL语句没有使用绑定变量?
这是ITPUB上的帖子:
http://www.itpub.net/335137.html
1. Jametong
减产前40个字符相同, 有多于5个不同sql版本的sql语句^_^
select substr(sqltext,1,40) sql_text,count(*)
from v$sql
group by substr(sqltext,1,40)
having count(*) >= 5;
2. husthxd
定位应该使用绑定变量的sql语句
SELECT substr(sql_text,1,40) "SQL",
count(*) ,
sum(executions) "TotExecs"
FROM v$sqlarea
WHERE executions < 5
GROUP BY substr(sql_text,1,40)
HAVING count(*) > 30
ORDER BY 2
/
40表示sql语句的前40个字符是一样的,5表示执行次数小于5次,30表示在shared_pool_size中出现不下30次。
3. Yong Huang:
quote:
--------------------------------------------------------------------------------
最初由 jametong 发布
减产前40个字符相同, 有多于5个不同sql版本的sql语句^_^
select substr(sqltext,1,40) sql_text,count(*)
from v$sql
group by substr(sqltext,1,40)
having count(*) >= 5;
--------------------------------------------------------------------------------
That's a commonly suggested method to find SQLs not using bind variables.
Its shortcoming is obvious; how do you know 40 is enough or too much?
I have another way. For queries,
select sql_text from v$sql where upper(sql_text) like 'SELECT%WHERE%'
and sql_text not like '%:%' order by 1;
Change SELECT to other keywords. This approach is based on the fact
that SQLs using bind variables have colons in them. But the shortcoming
is that it will miss bad SQLs like this:
select * from myreport where msg like 'Today: good%' and msg_type = 123;
So, there's no absolutely perfect way. You get the idea.
Yong Huang
4. biti_rainy:
我的习惯,如果不是极度繁忙的系统,一般允许做如下操作
set line 1500
set pagesize 0
spool sql.txt
select sql_text,executions,... from v$sqlarea order by sql_text;
spool off;
我可能在几个有代表性的时间点做这个操作,然后统计出来对比
通常这可能有上万条sql,不过这不要紧,在 urltraedit or execel 中很容易看出来的,顺着往下一拉,一目了然,大量没有绑定而类似的sql,有几十条或者几百条的,你一下子就能感觉到的,类似的sql没有绑定,有多少句,分别大致执行了多少次,很容易就统计出来了。这就是我的 笨办法 你可能以为这很累,实际上我在半小时之内就几乎能统计好大部分没有绑定的sql。
另外,绑定的sql,在v$sqlarea 中,是用占位符号的(和你的绑定变量的定义符号无关),可能形式如:
select * from t where ... col1 = :1 ... col2 = :a ...
2004年11月,在广东项目现场,我们遇到如下问题:
在选用Oracle’s Driver(OCI) Version:8.1.7, 9.0.1, 9.2.0驱动建立数据库连接池,出现错误:
java.lang.UnsatisfiedLinkError: Can't find library ocijdbc9 (libocijdbc9.a or .so) in sun.boot.library.path or java.library.path
sun.boot.library.path=/usr/java14/jre/bin
java.library.path=/usr/java14/jre/bin:/usr/java14/jre/bin/classic:/usr/java14/jre/bin:/arc/bea/weblogic/server/lib/aix:/usr/lib
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2020)
at java.lang.Runtime.loadLibrary0(Runtime.java:824)
at java.lang.System.loadLibrary(System.java:908)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:265)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:362)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:536)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:328)
at weblogic.management.console.utils.JDBC.testConnection(JDBC.java:143)
at weblogic.management.console.actions.mbean.JDBCConnectionPoolTestAction.prePerform(JDBCConnectionPoolTestAction.java:106)
at weblogic.management.console.actions.mbean.DoMBeanWizardAction.perform(DoMBeanWizardAction.java:215)
at weblogic.management.console.actions.internal.ActionServlet.doAction(ActionServlet.java:173)
at weblogic.management.console.actions.internal.ActionServlet.doPost(ActionServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java(Compiled Code))
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java(Compiled Code))
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java(Compiled Code))
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
>
解决方法如下:
编辑.profile文件,对于libpath,加入一项:$WL_HOME/server/lib/aix/oci920_8,使得LIBPATH=$WL_HOME/server/lib/aix/oci920_8:$ORACLE_HOME/lib:$LIBPATH
重新启动操作系统,即可解决问题。
注意:本数据库版本是Oracle 9.2.0.5
如果数据库版本是9.0.1,加入的项目为$WL_HOME/server/lib/aix/oci901_8
如果数据库版本是8.1.7,加入的项目为$WL_HOME/server/lib/aix/oci817_8
如果有问题,请先检查设置的环境是否有效。进入该用户的默认目录,先执行一下.profile文件,即:
. ./.profile
(点空格点斜杠点profile)
关于本方法,请参考文档:http://e-docs.bea.com/wls/docs81/oracle/install_jdbc.html
初到项目现场,华南咨讯给安装的Oracle 9.2.0.5数据库不支持DBMS_XMLDOM, DBMS_XMLPARSER包,
结果导致我们的一个使用到这两个包的所有存储过程不能正常工作。经过苦苦寻觅和试验,终于发现问题
所在。如下是解决过程:
1 建立XDB用户(为建立XDB用户,先建立XDB表空间),并且给XDB用户授予connect, resource权限。
2 运行/ORACLE_HOME/rdbms/admin/catqm.sql脚本(运行该脚本时,需要输入xdb用户的密码,缺省表空间名称,缺省临时表空间 名称)。
3 脚本运行成功后,重新编译DBMS_XMLDOM, DBMS_XMLPARSER所在的包,问题即得到解决。
由于数据库进行大规模的排序,使得临时表空间无限扩展。可以通过如下方法解决问题:
1 新建临时表空间
create temporary tablespace temp2 tempfile '/oradata/oracle/user_temp1.dbf' size 200m
2 改变数据库缺省临时表空间
alter database default temporary tablespace temp2;
3 删除原来的临时表空间:
drop temporary tablespace temp including contents and datafiles;
4 重新建立临时表空间
create temporary tablespace temp tempfile ‘/oradata/oracle/temp01.dbf’ size 512m;
5 切换默认临时表空间
alter database default temporary tablespace temp;
6 删除过度用的临时表空间及文件
drop temporary tablespace temp2 including contents and datafiles;
如下是我见到的一种最简单的方法:
Oracle数据库的初始化参数,主要来源于两个Oracle内部数据字典表:X$KSPPCV,X$KSPPI
通常我们查询的v$parameter视图就来源于这两个表,只不过隐去了部分参数。
通过以下脚本可以查询获得这些被隐含的参数:
set linesize 132
column name format a30
column value format a25
select
x.ksppinm name,
y.ksppstvl value,
y.ksppstdf isdefault,
decode(bitand(y.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE') ismod,
decode(bitand(y.ksppstvf,2),2,'TRUE','FALSE') isadj
from
sys.x$ksppi x,
sys.x$ksppcv y
where
x.inst_id = userenv('Instance') and
y.inst_id = userenv('Instance') and
x.indx = y.indx and
x.ksppinm like '%_&par%'
order by
translate(x.ksppinm, ' _', ' ')
/
|
本文是我在itpub上发表的一个问题(http://www.itpub.net/showthread.php?s=&threadid=335115)
关于dba_extents中RELATIVE_FNO字段的疑问
SQL> desc dba_extents
名称 是否为空? 类型
----------------------------------------- -------- ----------------------
OWNER VARCHAR2(30)
SEGMENT_NAME VARCHAR2(81)
PARTITION_NAME VARCHAR2(30)
SEGMENT_TYPE VARCHAR2(18)
TABLESPACE_NAME VARCHAR2(30)
EXTENT_ID NUMBER
FILE_ID NUMBER
BLOCK_ID NUMBER
BYTES NUMBER
BLOCKS NUMBER
RELATIVE_FNO NUMBER
发现存在两个字段, file_id, relative_fno,从字面上看,第二字段表示的是相对文件号,那么它与第一个有什么不一样呢?
我执行如下查询:
SQL> select file_id, relative_fno, segment_name, owner from dba_extents
where file_id <> relative_fno;
未选定行
请哪位指出relative_fno这个字段的作用?谢谢!
biti_rainy做了回答:
参考
http://blog.itpub.net/post/330/22749
归根结底的原因是因为 ROWID 的存储格式造成的,因为 rowid 中文件编号标志只有10bit,最大数据容量1024,由于不存在0编号文件,所以实际上只允许1023个文件编号。
在oracle8 之前的版本的数据库中,rowid是受限的,只包括 file# /block# /row# ,则数据库最多只允许1023个文件。 而oracle8开始rowid 包括 data_object_id# / Rfile# /block# /rowid#
data object id 的引入,同时支持了表分区的概念,一个表可以拥有多个分区(segment),而一个分区可以在不同的表空间中(由Rfile# 表示在segment对应的表空间中对应的 相对文件编号)。这样表的容量也增大了。 扩展的rowid使得oracle不再局限于数据文件只能有1023个的限制,而一个表可以分区,也使得表的容量不再局限于单个表空间中(1023个文件的限制)。
当然,你或许要问,为什么oracle不调整rowid中表示 file# 的 bit数量,这个应该是由于兼容性的引起的,在 oracle7 的索引中存储的rowid就是 file# + block# + row# ,,因为这样处理后关于索引的存储,oracle8和oracle7没有发生变化(在oracle8中一个索引(可能分区)segment肯定对应了一个表(可能分区)的segment,这个可以由数据字典关系得到,从而确立了 索引中的rowid 对应哪个 表空间中的数据文件),在升级的时候就不用关心 索引的问题,而直接升级oracle软件以及运行相关的包,否则将会大动干戈解决索引的问题。这就是oracle实现物理文件升级的基础。
当然,真正升级的时候,一些数据文件头的 rfile# 需要发生变化,这也是有文件的一些存储的特性决定的,为了不和oracle8的格式发生冲突,才需要修改。这个修改代价非常的小,所以oracle选择了这个方案。详细的信息,大家可以去参考metalink相关内容,有详细的 存储(byte 中字节位)的变化关系。
http://metalink.oracle.com/metalink...T&p_id=122926.1
喝凉水都能塞牙:)
问题描述:本地Oracle客户端版本为9.2.0.1,而数据库服务器版本为9.2.0.5。在本地利用exp将数据从服务器导出时,在遇到有大对象(BLOB, CLOB)的表时,出现错误:EXP-00003。经过确认,发现时Oracle的Bug。解决方法如下:
方法一:将客户端升级版本升级为9.2.0.5。
方法二:
步骤1 修改$ORACLE_HOME/rdbms/admin/catexp.sql文件(在修改之前,请务必对该文件做备份,以防失误),
将“UNION ALL select * from sys.exu9tneb”加入到视图exu9tne定义的最后一行,如下:
CREATE OR REPLACE VIEW exu9tne (
tsno, fileno, blockno, length) AS
SELECT ts#, segfile#, segblock#, length
FROM sys.uet$
WHERE ext# = 1
UNION ALL
SELECT * from sys.exu9tneb
/
步骤2 以sys帐号执行该脚本。
这样,即可以用低版本的客户端导出版本为9.2.0.5的数据库服务器上的数据。
以上两种方法,相比之下,建议采用第二种,因为这样可以不用升级每个客户端,从而减少了麻烦。但是采用第二种方法时,一定要对注意catexp.sql进行备份。
首先,向jeffli73和eygle致谢。本人在解决这个问题时,主要参考了
如下2篇文章:
http://www.itpub.net/276524.html
http://www.eygle.com/index-special.htm
我们现在在做一个政府项目,我们公司是总承包商。软件共有2个部分,
一个由我们自己开发,另外一个购买第三方产品(称为A公司)。我们
的数据库都选择Oracle,为了省钱,在一个小型机上建立2个数据库。
我们公司方面在做报表时,需要使用到A公司的原始数据,A公司给我们
提供数据库视图,通过数据库链接来实现。我们的应用是J2EE,他们的
应用是PB。应该强调指出的是,双方的程序各自独立运行时,没有任何
问题,工作都很正常。
同时,先把系统环境交待一下,我们的操作系统是AIX 5.1,数据库是
oracle 9.2.0.5,IBM ps6000小型机。
前几天,在调试报表时,发现一个莫名其妙的问题,就是我们的J2EE程序
报错:“无法读取数据库列值!“。我就怀疑是双方的字符集不一致。
为了验证自己的想法,就以sys用户登录到A公司的数据库,检查发现:
SQL> select value$ from props$ where name = 'NLS_CHARACTERSET';
VALUE$
-----------------------------------------------------------------------------
WE8ISO8859P1
SQL> show parameter nls
NAME TYPE VALUE
------------------------------------ ----------- --------------------
nls_calendar string
nls_comp string
nls_currency string
nls_date_format string
nls_date_language string
nls_dual_currency string
nls_iso_currency string
nls_language string AMERICAN
nls_length_semantics string BYTE
nls_nchar_conv_excp string FALSE
nls_numeric_characters string
NAME TYPE VALUE
------------------------------------ ----------- --------------------
nls_sort string
nls_territory string AMERICA
nls_time_format string
nls_time_tz_format string
nls_timestamp_format string
nls_timestamp_tz_format string
显然,对方使用的是WE8ISO8859P1字符集,是西文字符集。
而我们自己的数据库:
SQL> select value$ from props$ where name = 'NLS_CHARACTERSET';
VALUE$
-----------------------------------------------------------------
ZHS16GBK
SQL> show parameter nls
NAME TYPE VALUE
------------------------------------ ----------- ----------------
nls_calendar string
nls_comp string
nls_currency string
nls_date_format string
nls_date_language string
nls_dual_currency string
nls_iso_currency string
nls_language string AMERICAN
nls_length_semantics string BYTE
nls_nchar_conv_excp string FALSE
nls_numeric_characters string
NAME TYPE VALUE
------------------------------------ ----------- ----------------
nls_sort string
nls_territory string AMERICA
nls_time_format string
nls_time_tz_format string
nls_timestamp_format string
nls_timestamp_tz_format string
我们的数据库使用的是中文字符集。双方的字符集不一致!
他们的应用为什么能够正常工作而不出现乱码呢?A公司的应用安装由4个客户端,
于是,我就查找这四个客户端。无一例外,发现四台电脑的注册表的
nls_lang=AMERICAN_AMERICA.WE8ISO8859P1
问题清楚了,因为这4台客户端的nls_lang设置和数据库字符集一致,所以数据在
客户与数据库之间的存取过程中将不发生任何转换。同样,当他们自己的应用从
数据库中取出数据时,Oracle检测到服务器与客户端的字符集一致,也不做任何
转换。所以,他们客户端的显示仍是正常的!这就相当于”负负得正“的效果!
果然,在自己的电脑上,我通过 sqlplus 连接对方的数据库,查询得到的结果中
涉到汉字的都显示为乱码。(我的客户端设置为nls=AMERICAN_AMERICA.ZHS16GBK)
如何解决问题呢?最根本的方法当然是删除对方的数据库,重新建立新数据库。这
牵涉到2个公司之间的事情。于是,请示完我们公司的主管后,和A公司联系。 A
公司当天下午就派员从2个小时之外的深圳赶过来。我向A公司的这位朋友了解情况。
令人沮丧的是,这个公司的大部分人都不太懂数据库,只有这位朋友还算了解得多
一些。原来,该公司的开发一直采用WE8ISO8859P1字符集,并且他们的数据库版本
目前为止还是Oracle 8.1.7。他们的数据库导出文件也是WE8ISO8859P1字符集。
晚上,我们重新建立了数据库,不敢有丝毫的马虎,数据库字符集选择了ZHS16GBK。
然后,我们把A公司的数据库导出文件使用UltraEdit打开,其第2,3个字节为00 1F,
为WE8ISO8859P1字符集:
SQL> select nls_charset_id('WE8ISO8859P1') from dual;
NLS_CHARSET_ID('WE8ISO8859P1')
------------------------------
31
将其转换为16进制,
SQL> select to_char('31', 'xxxx') from dual;
TO_CH
-----
1f
我们将其更该为03 54,
SQL> select nls_charset_id('ZHS16GBK') from dual;
NLS_CHARSET_ID('ZHS16GBK')
--------------------------
852
SQL> select to_char('852','xxxx') from dual;
TO_CH
-----
354
然后执行导入操作,将文件导入到新建立的数据库,导入后,再使用我电脑上的
sqlplus连接新数据库,结果正确。(导入时,我分别使用了oralce 8i的exp工具
和9i的exp工具分别导入,都能正确完成)
接着,我们调试报表,结果也完全正常!至此,问题得到了解决。
我有点不好意思地问A公司的朋友:你们公司给别的客户安装,难道都是使用WE8ISO8859P1
字符集吗?这位朋友说:是的。
他们的产品一般都是独立运行的,所以没有发现问题!汗!
项目现场,操作系统Aix 5L,数据库版本9.2.0.1,使用dbms_stat分析表遇到bug!
C:>sqlplus
SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 1月 28 15:00:48 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
请输入用户名: sys/wangweifeng@oracle as sysdba
连接到:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
SQL> conn
请输入用户名: csjtdev/csjt@oracle
已连接。
SQL> exec dbms_stats.gather_table_stats(ownname=>'csjtdev', tabname=>'flux_fluxr
ecord');
BEGIN dbms_stats.gather_table_stats(ownname=>'csjtdev', tabname=>'flux_fluxrecor
d'); END;
*
ERROR 位于第 1 行:
ORA-06521: PL/SQL: Error mapping function
ORA-06512: at "SYS.DBMS_STATS", line 9643
ORA-06512: at "SYS.DBMS_STATS", line 9657
ORA-06512: at line
寻找解决方案ing!
项目中,需要在操作系统启动时,自动启动数据与监听器,经过试验,
按照如下步骤,成功实现目标:
1 在 /home/oracle目录下,建立startdb文件,文件内容如下:
echo "begin to start oracle"
lsnrctl start
sqlplus /nolog <<EOF
connect /as sysdba
startup
exit
exit
echo "oracle have started"
给startdb执行权限
2 在/etc下建立文件rc.startdb,脚本如下:
su - oracle "-c /oracle/startdb" #启动oracle
给文件执行权限
3 把启动信息放到/etc/inittab中,使用如下命令:
mkitab “startdb:2:wait:/etc/rc.startdb”
按照上面步骤,启动AIX系统后就可以自动启动Oracle数据库与监听器。
12月18号,我们注意到回滚段表空间无限扩展,已经达到10G。这可能与我们17号进行了大规模的清理数据库有关。我们解决了这个问题,过程如下:
1 新建一个回滚表空间:
create undo tablespace undo_ts datafile '/oradata/oracle/undo_ts.dbf' size 400m autoextend on next 10m maxsize 800m;
2 将系统的回滚表空间切换到新建立的undo_ts上
alter system set undo_tablespace = undo_ts;
3 删除原来的回滚表空间
drop tablespace UNDOTBS1;
4 删除原来的表空间对应的文件
rm /oradata/oracle/undotbs01.dbf
这几天净遇到棘手的事情:前天遇到字符集问题,今天遇到数据库时区问题。
不过,经过努力,都解决了。现在,先把解决时区问题的经过说一遍:
我们的环境:os是aix 5.1,oracle是9.2.0.5。
昨天晚上用 dbca 建立的数据库,今天上午发现时区不对。
SQL> select dbtimezone from dual;
DBTIME
------
0:00
当时,我们查时间:
SQL> select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual;
2005-01-15 03:15:33
其时,操作时间是2005-01-15 11:15:33,相差是8个小时。数据库时区和操作系统
不是一个时区(下午看了一些文档后,感到很纳闷,用dbca建立数据库时,自动读取操作系统时区,按说数据库时区与操作系统时区是应该一致的。)。于是,我就想办法把数据库时区更正过来。对于时区方面,我没有任何的经验,该怎么解决呢?
摸着石头过河吧!
首先到tahiti.oracle.com上查timezone的相关信息,结果找到文档
http://download-west.oracle.com/doc...15a.htm#2133743
该文档说:更改 timezone,可以使用 alter database set time_zone语句修改。
于是,我就以sys用户登陆数据库,然后发出命令:
SQL> alter database set time_zone = '+8:00';
alter database set time_zone = '+8:00'
*
第 1 行出现错误:
ORA-02231: 缺少或无效的 ALTER DATABASE 选项
出现上述错误!我就在asktom, metalink上搜索,发现一些文章:
http://asktom.oracle.com/pls/ask/f?...D:3083336233923
http://metalink.oracle.com/metalink...T&p_id=230099.1
问题是数据库中有一些列的数据类型是:TIMESTAMP WITH LOCAL TIME ZONE只要把这些列删除了就可以了。metalink上的230099.1提供了一个脚本,查找哪些列的数据类型是TIMESTAMP WITH LOCAL TIME ZONE类型。执行该脚本:
SQL> select u.name || '.' || o.name || '.' || c.name
2 TSLTZcolumn from sys.obj$ o, sys.col$ c, sys.user$ u
3 where c.type# = 231 and o.obj# = c.obj# and u.user# = o.owner#;
TSLTZCOLUMN
------------------------------------------------------------------------
OE.ORDERS.ORDER_DATE
发现oe用户下orders表中的字段 order_date TIMESTAMP WITH LOCAL TIME ZONE类型的:
SQL> desc oe.orders
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
ORDER_ID NOT NULL NUMBER(12)
ORDER_DATE NOT NULL TIMESTAMP(6) WITH LOCAL TIME
ZONE
ORDER_MODE VARCHAR2(8)
CUSTOMER_ID NOT NULL NUMBER(6)
ORDER_STATUS NUMBER(2)
ORDER_TOTAL NUMBER(8,2)
SALES_REP_ID NUMBER(6)
PROMOTION_ID NUMBER(6)
该表是一个无关紧要的表,于是删除该中order_date字段。
SQL> alter table oe.orders drop column order_date;
表已更改。
然后尝试更改数据库时区:
SQL> alter database set time_zone='+8:00';
数据库已更改。
接着,重新启动数据库,
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 160504432 bytes
Fixed Size 453232 bytes
Variable Size 134217728 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
数据库已经打开。
查询时区信息
SQL> select dbtimezone from dual;
DBTIME
------
+08:00
至此,我们已经更改数据库时区成功!
本文原发表于http://www.itpub.net/312046.html