<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>happydba</title>
	<atom:link href="http://www.orablogger.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.orablogger.com</link>
	<description>Enjoy your work, and your life. (arie.sun # hotmail.com)</description>
	<lastBuildDate>Thu, 22 Sep 2011 03:05:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<copyright>2006-2007 </copyright>
	<managingEditor>ariebeyond@gmail.com (happydba)</managingEditor>
	<webMaster>ariebeyond@gmail.com (happydba)</webMaster>
	<image>
		<url>http://www.orablogger.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>happydba</title>
		<link>http://www.orablogger.com</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>oracle dba&#039;s site</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &#38; Culture" />
	<itunes:author>happydba</itunes:author>
	<itunes:owner>
		<itunes:name>happydba</itunes:name>
		<itunes:email>ariebeyond@gmail.com</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.orablogger.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Additional Considerations for Direct-Path INSERT &amp; NOtes added on</title>
		<link>http://www.orablogger.com/2011/09/additional-considerations-for-direct-path-insert-notes-added-on/</link>
		<comments>http://www.orablogger.com/2011/09/additional-considerations-for-direct-path-insert-notes-added-on/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 03:05:31 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[Internal]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[Direct-Path]]></category>
		<category><![CDATA[INSERT]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=526</guid>
		<description><![CDATA[Advantages of Using Direct-Path INSERT The following are performance benefits of direct-path INSERT: During direct-path INSERT, you can disable the logging of redo and undo entries. Conventional insert operations, in contrast, must always log such entries, because those operations reuse free space and maintain referential integrity. To create a new table with data from an [...]]]></description>
			<content:encoded><![CDATA[<p>Advantages of Using Direct-Path INSERT</p>
<p>The following are performance benefits of direct-path INSERT:</p>
<p>During direct-path INSERT, you can disable the logging of redo and undo entries. Conventional insert operations, in contrast, must always log such entries, because those operations reuse free space and maintain referential integrity.</p>
<p>To create a new table with data from an existing table, you have the choice of creating the new table and then inserting into it, or executing a CREATE TABLE &#8230; AS SELECT statement. By creating the table and then using direct-path INSERT operations, you update any indexes defined on the target table during the insert operation. The table resulting from a CREATE TABLE &#8230; AS SELECT statement, in contrast, does not have any indexes defined on it; you must define them later.</p>
<p>Direct-path INSERT operations ensure atomicity of the transaction, even when run in parallel mode. Atomicity cannot be guaranteed during parallel direct-path loads (using SQL*Loader).</p>
<p>If errors occur during parallel direct-path loads, some indexes could be marked UNUSABLE at the end of the load. Parallel direct-path INSERT, in contrast, rolls back the statement if errors occur during index update.</p>
<p>Direct-path INSERT must be used if you want to store the data in compressed form using table compression.</p>
<p>Enabling Direct-Path INSERT</p>
<p>You can implement direct-path INSERT operations by using direct-path INSERT statements, inserting data in parallel mode, or by using the Oracle SQL*Loader utility in direct-path mode. Direct-path inserts can be done in either serial or parallel mode.</p>
<p>To activate direct-path INSERT in serial mode, you must specify the APPEND hint in each INSERT statement, either immediately after the INSERT keyword, or immediately after the SELECT keyword in the subquery of the INSERT statement.</p>
<p>When you are inserting in parallel DML mode, direct-path INSERT is the default. In order to run in parallel DML mode, the following requirements must be met:</p>
<p>You must have Oracle Enterprise Edition installed.</p>
<p>You must enable parallel DML in your session. To do this, run the following statement:</p>
<p>ALTER SESSION { ENABLE | FORCE } PARALLEL DML;</p>
<p>You must specify the parallel attribute for the target table, either at create time or subsequently, or you must specify the PARALLEL hint for each insert operation.</p>
<p>To disable direct-path INSERT, specify the NOAPPEND hint in each INSERT statement. Doing so overrides parallel DML mode.</p>
<p>How Direct-Path INSERT Works</p>
<p>You can use direct-path INSERT on both partitioned and non-partitioned tables.</p>
<p>Serial Direct-Path INSERT into Partitioned or Non-partitioned Tables<br />
The single process inserts data beyond the current high water mark of the table segment or of each partition segment. (The high-water mark is the level at which blocks have never been formatted to receive data.) When a COMMIT runs, the high-water mark is updated to the new value, making the data visible to users.</p>
<p>Parallel Direct-Path INSERT into Partitioned Tables<br />
This situation is analogous to serial direct-path INSERT. Each parallel execution server is assigned one or more partitions, with no more than one process working on a single partition. Each parallel execution server inserts data beyond the current high-water mark of its assigned partition segment(s). When a COMMIT runs, the high-water mark of each partition segment is updated to its new value, making the data visible to users.</p>
<p>Parallel Direct-Path INSERT into Non-partitioned Tables<br />
Each parallel execution server allocates a new temporary segment and inserts data into that temporary segment. When a COMMIT runs, the parallel execution coordinator merges the new temporary segments into the primary table segment, where it is visible to users.</p>
<p>Specifying the Logging Mode for Direct-Path INSERT</p>
<p>Direct-path INSERT lets you choose whether to log redo and undo information during the insert operation.</p>
<p>You can specify logging mode for a table, partition, index, or LOB storage at create time (in a CREATE statement) or subsequently (in an ALTER statement).</p>
<p>If you do not specify either LOGGING or NOLOGGING at these times:</p>
<p>The logging attribute of a partition defaults to the logging attribute of its table.</p>
<p>The logging attribute of a table or index defaults to the logging attribute of the tablespace in which it resides.</p>
<p>The logging attribute of LOB storage defaults to LOGGING if you specify CACHE for LOB storage. If you do not specify CACHE, then the logging attributes defaults to that of the tablespace in which the LOB values resides.</p>
<p>You set the logging attribute of a tablespace in a CREATE TABLESPACE or ALTER TABLESPACE statements.</p>
<p>Note:<br />
If the database or tablespace is in FORCE LOGGING mode, then direct path INSERT always logs, regardless of the logging setting.<br />
Direct-Path INSERT with Logging<br />
In this mode, Oracle Database performs full redo logging for instance and media recovery. If the database is in ARCHIVELOG mode, then you can archive redo logs to tape. If the database is in NOARCHIVELOG mode, then you can recover instance crashes but not disk failures.</p>
<p>Direct-Path INSERT without Logging<br />
In this mode, Oracle Database inserts data without redo or undo logging. (Some minimal logging is done to mark new extents invalid, and data dictionary changes are always logged.) This mode improves performance. However, if you subsequently must perform media recovery, the extent invalidation records mark a range of blocks as logically corrupt, because no redo data was logged for them. Therefore, it is important that you back up the data after such an insert operation.</p>
<p>Additional Considerations for Direct-Path INSERT</p>
<p>The following are some additional considerations when using direct-path INSERT.</p>
<p>Index Maintenance with Direct-Path INSERT<br />
Oracle Database performs index maintenance at the end of direct-path INSERT operations on tables (partitioned or non-partitioned) that have indexes. This index maintenance is performed by the parallel execution servers for parallel direct-path INSERT or by the single process for serial direct-path INSERT. You can avoid the performance impact of index maintenance by dropping the index before the INSERT operation and then rebuilding it afterward.</p>
<p>Space Considerations with Direct-Path INSERT<br />
Direct-path INSERT requires more space than conventional-path INSERT.</p>
<p>All serial direct-path INSERT operations, as well as parallel direct-path INSERT into partitioned tables, insert data above the high-water mark of the affected segment. This requires some additional space.</p>
<p>Parallel direct-path INSERT into non-partitioned tables requires even more space, because it creates a temporary segment for each degree of parallelism. If the non-partitioned table is not in a locally managed tablespace in automatic segment-space management mode, you can modify the values of the NEXT and PCTINCREASE storage parameter and MINIMUM EXTENT tablespace parameter to provide sufficient (but not excess) storage for the temporary segments. Choose values for these parameters so that:</p>
<p>The size of each extent is not too small (no less than 1 MB). This setting affects the total number of extents in the object.</p>
<p>The size of each extent is not so large that the parallel INSERT results in wasted space on segments that are larger than necessary.</p>
<p>After the direct-path INSERT operation is complete, you can reset these parameters to settings more appropriate for serial operations.</p>
<p>Locking Considerations with Direct-Path INSERT<br />
During direct-path INSERT, the database obtains exclusive locks on the table (or on all partitions of a partitioned table). As a result, users cannot perform any concurrent insert, update, or delete operations on the table, and concurrent index creation and build operations are not permitted. Concurrent queries, however, are supported, but the query will return only the information before the insert operation.</p>
<p>NOtes Added On<br />
(1) in 10.x and previous releases the APPEND hint gets ignored when it is present in an INSERT with VALUES clause and that is the expected behavior for previous versions, including 9i and 10g. On 11g Release 1, the APPEND hint it is not ignored and a direct-path load is executed for an INSERT with VALUES clause, therefore such statements will allocate one row/database block.</p>
<p>(2) On 11g Release 2, there is a new hint &#8220;APPEND_VALUES&#8221;, i.e. use direct path load only when the &#8220;APPEND_VALUES&#8221; hint is referenced. On 11g Release 2 the &#8220;APPEND&#8221; hint is ignored for INSERT statements with VALUES clause. This is the expected behavior on 11g and it is currently implemented only in 11g Release 2.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2011/09/additional-considerations-for-direct-path-insert-notes-added-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Tar安装oracle 10g</title>
		<link>http://www.orablogger.com/2011/09/linux-tar%e5%ae%89%e8%a3%85oracle-10g/</link>
		<comments>http://www.orablogger.com/2011/09/linux-tar%e5%ae%89%e8%a3%85oracle-10g/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 15:08:49 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[排错]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=523</guid>
		<description><![CDATA[链接：http://www.dbasky.net/archives/2009/04/linux-taroracle-10g.html 最近公司业务的不断扩大，对数据库的使用也不断的增加，导致了基本每天都要进行安装的安装和配置。其实oracle的安装是很简单，不知道是否有更加方便，快捷的安装方式呢？答案：有的，那就是用linux常用的命令tar来进行安装。今天我就来尝试了在linux as4上用tar方式安装oracle 10g，下面简单记录下这次的操作过程。 原数据库所在服务器信息： kfserver-> more /etc/issue Red Hat Enterprise Linux AS release 4 (Nahant Update 5) Kernel \r on an \m kfserver-> uname -a Linux kfserver 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux 新数据库所在服务器信息： root@testserver:[/root]more /etc/issue Red Hat Enterprise Linux AS release 4 (Nahant Update 5) Kernel [...]]]></description>
			<content:encoded><![CDATA[<p>链接：http://www.dbasky.net/archives/2009/04/linux-taroracle-10g.html </p>
<p>       最近公司业务的不断扩大，对数据库的使用也不断的增加，导致了基本每天都要进行安装的安装和配置。其实oracle的安装是很简单，不知道是否有更加方便，快捷的安装方式呢？答案：有的，那就是用linux常用的命令tar来进行安装。今天我就来尝试了在linux as4上用tar方式安装oracle 10g，下面简单记录下这次的操作过程。</p>
<p>原数据库所在服务器信息：</p>
<p>kfserver-> more /etc/issue<br />
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)<br />
Kernel \r on an \m</p>
<p>kfserver-> uname -a<br />
Linux kfserver 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux<br />
新数据库所在服务器信息：</p>
<p> root@testserver:[/root]more /etc/issue<br />
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)<br />
Kernel \r on an \m<br />
 root@testserver:[/root]uname -a<br />
Linux testserver 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux<br />
以上二个系统版本是一样的。</p>
<p>1、在新服务器上添加用户<br />
 groupadd oinstall<br />
 useradd -g oinstall oracle</p>
<p>2、在新服务器上添加相关目录<br />
 mkdir -p /opt/oracle/product</p>
<p>3、设置核心参数<br />
 vi /etc/sysctl.conf，添加</p>
<p> # Controls whether core dumps will append the PID to the core filename.<br />
# Useful for debugging multi-threaded applications.<br />
kernel.core_uses_pid = 1<br />
kernel.shmall   =       2097152<br />
kernel.shmmax   =       2147483648<br />
kernel.shmmni   =       4096<br />
kernel.sem      =       250 32000 100 128<br />
fs.file-max     =       65536<br />
net.ipv4.ip_local_port_range    =       1024 65000<br />
net.core.rmem_default   =       1048576<br />
net.core.rmem_max       =       1048576<br />
net.core.wmem_default   =       262144<br />
net.core.wmem_max       =       262144</p>
<p> 使设置生效：<br />
 sysctl -p</p>
<p>4、修改oracle用户的环境变量<br />
 su &#8211; oracle<br />
 vi  .bash_profile 添加：</p>
<p># User specific environment and startup programs<br />
PATH=$PATH:$HOME/bin</p>
<p>export PATH<br />
unset USERNAME<br />
export PS1=&#8221;` /bin/hostname -s ` -> &#8221;<br />
export EDITOR=vi<br />
export ORACLE_SID=nuage<br />
export ORACLE_BASE=/opt/oracle<br />
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1<br />
export ORACLE_CLIENT=$ORACLE_BASE/product/10.2.0/cleint<br />
export LD_LIBRARY=$ORACLE_HOME/lib<br />
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin<br />
export NLS_LANG=&#8221;SIMPLIFIED CHINESE_CHINA.ZHS16GBK&#8221;</p>
<p>5、在原服务器打包程序<br />
把$ORACLE_HOME下的东西打包压缩：<br />
 cd $ORACLE_BASE/product<br />
 tar cfz oracle10203.tar 10.2</p>
<p>6、传送到新服务器并解压<br />
 scp 上传</p>
<p> cd $ORACLE_BASE/product<br />
 tar -xzfv oracle10203<br />
7、修改解压后的文件属主</p>
<p>[root@testserver oracle]# chown -R oracle:oinstall /opt/<br />
chown: changing ownership of `/opt/oracle/product/10.2/rdbms/filemap&#8217;: No such file or directory</p>
<p>这里出现一个错误，提示文件不存在，经检查这是一个软链接：</p>
<p>[root@testserver oracle]# ls -l /opt/oracle/product/10.2/rdbms/filemap<br />
lrwxrwxrwx  1 root root 22 Jan 10 17:22 /opt/oracle/product/10.2/rdbms/filemap -> /opt/ORCLfmap/prot1_64<br />
经检查，当前的系统确实不存在/opt/ORCLfmap目录，实际上/opt/ORCLfmap是有root.sh生成的，先删除这个软链接：<br />
rm -f /opt/oracle/product/10.2/rdbms/filemap</p>
<p>重新执行root.sh：</p>
<p>[root@testserver opt]# /opt/oracle/product/10.2/root.sh<br />
 Running Oracle10 root.sh script&#8230;</p>
<p> The following environment variables are set as:<br />
     ORACLE_OWNER= oracle<br />
     ORACLE_HOME=  /opt/oracle/product/10.2</p>
<p> Enter the full pathname of the local bin directory: [/usr/local/bin]:<br />
    Copying dbhome to /usr/local/bin &#8230;<br />
    Copying oraenv to /usr/local/bin &#8230;<br />
    Copying coraenv to /usr/local/bin &#8230;</p>
<p> Creating /etc/oratab file&#8230;<br />
 Entries will be added to the /etc/oratab file as needed by<br />
 Database Configuration Assistant when a database is created<br />
 Finished running generic part of root.sh script.<br />
 Now product-specific root actions will be performed.<br />
此时软连接和目录都已经存在：</p>
<p> [root@testserver opt]# ls /opt/oracle/product/10.2/rdbms/filemap<br />
 bin  etc  log<br />
 [root@testserver opt]# ls -l /opt/oracle/product/10.2/rdbms/filemap<br />
 lrwxrwxrwx  1 root root 22 Jan 10 17:40 /opt/oracle/product/10.2/rdbms/filemap -> /opt/ORCLfmap/prot1_64<br />
8、创建数据库<br />
   运行dbca，一步一步设置好就可以。</p>
<p>9、清理原网络相关文件、原密码文件等。</p>
<p>一般会出现的问题：<br />
1、chown: changing ownership of `/opt/oracle/product/10.2/rdbms/filemap&#8217;: No such file or directory<br />
这个问题在上文已有描述，这里不再赘述。</p>
<p>2、Exception in thread &#8220;main&#8221; java.lang.UnsatisfiedLinkError: /opt/oracle/product/10.2/jdk/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory</p>
<p>执行dbca时报错：</p>
<p> testserver ->$ dbca<br />
 Exception in thread &#8220;main&#8221;<br />
testserver ->$<br />
这里报错信息非常少，无法判断是什么原因，再执行netca就可以看得更多的错误信息了：</p>
<p>[oracle@testserver bin]$ netca<br />
Exception in thread &#8220;main&#8221; java.lang.UnsatisfiedLinkError: /opt/oracle/product/10.2/jdk/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory<br />
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)<br />
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)<br />
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)<br />
        at java.lang.Runtime.loadLibrary0(Runtime.java:788)<br />
        at java.lang.System.loadLibrary(System.java:834)<br />
        at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)<br />
        at java.security.AccessController.doPrivileged(Native Method)<br />
        at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)<br />
        at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)<br />
        at java.awt.Component.<clinit>(Component.java:506)  </p>
<p>这个问题主要是缺少一个包xorg-x11-deprecated-libs导致的，把包安装上就可以：<br />
[root@testserver soft]# rpm -ivh xorg-x11-deprecated-libs-6.8.2-1.EL.13.37.i386.rpm<br />
 warning: xorg-x11-deprecated-libs-6.8.2-1.EL.13.37.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516<br />
 Preparing&#8230;                ########################################### [100%]<br />
    1:xorg-x11-deprecated-lib########################################### [100%]</p>
<p>   注意：虽然系统是64位的，但是这里要安装32位的包。</p>
<p>3、ORA-12547: TNS: 丢失连接<br />
在创建数据库前，简单测试一下sqlplus是否正常，发现了这个问题：</p>
<p> testserver ->$ sqlplus &#8220;/as sysdba&#8221;</p>
<p> SQL*Plus: Release 10.2.0.3.0 &#8211; Production on 星期四 1月 10 17:51:35 2008</p>
<p> Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.</p>
<p> oraclenewdemo: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory<br />
 ERROR:<br />
 ORA-12547: TNS: 丢失连接</p>
<p>请输入用户名: </p>
<p>引起问题的原因是libaio系统包，把相关包安装即可：</p>
<p> [root@testserver soft]# ls<br />
 libaio-0.3.105-2.i386.rpm  libaio-0.3.105-2.x86_64.rpm  libaio-devel-0.3.105-2.x86_64.rpm<br />
 [root@testserver soft]# rpm -ivh *<br />
 warning: libaio-0.3.105-2.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516<br />
 Preparing&#8230;                ########################################### [100%]<br />
    1:libaio                 ########################################### [ 33%]<br />
    2:libaio                 ########################################### [ 67%]<br />
    3:libaio-devel           ########################################### [100%]</p>
<p> 同样，这里也需要安装两个32位的包。 </p>
<p>4、ORA-01031: insufficient privileges<br />
testserver ->$ sqlplus &#8220;/as sysdba&#8221;</p>
<p>SQL*Plus: Release 10.2.0.3.0 &#8211; Production on 星期五 1月 11 10:48:35 2008</p>
<p>Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.</p>
<p>ERROR:<br />
ORA-01031: insufficient privileges</p>
<p>请输入用户名: </p>
<p>这个问题是因为用户组不一致造成的。</p>
<p>原库：</p>
<p>[oracle@kfserver oraInventory]$ id -a<br />
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba) context=user_u:system_r:unconfined_t<br />
新库：</p>
<p>[oracle@testserver oraInventory]$ id -a<br />
uid=500(oracle) gid=500(oinstall) groups=500(oinstall) context=user_u:system_r:unconfined_t<br />
在新库上为oracle用户添加组就可以了：</p>
<p>[root@testserver ~]# usermod -G dba oracle</p>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2011/09/linux-tar%e5%ae%89%e8%a3%85oracle-10g/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PRAGMA EXCEPTION_INIT的用法</title>
		<link>http://www.orablogger.com/2011/09/pragma-exception_init/</link>
		<comments>http://www.orablogger.com/2011/09/pragma-exception_init/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 03:23:41 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Exception]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=477</guid>
		<description><![CDATA[ 如果要处理未命名的内部异常，必须使用OTHERS异常处理器或PRAGMA EXCEPTION_INIT 。PRAGMA由编译器控制，或者是对于编译器的注释。PRAGMA在编译时处理，而不是在运行时处理。EXCEPTION_INIT告诉编译器将异常名与ORACLE错误码结合起来，这样可以通过名字引用任意的内部异常，并且可以通过名字为异常编写一适当的异常处理器。 　　 　　在子程序中使用EXCEPTION_INIT的语法如下： 　　PRAGMA EXCEPTION_INIT(exception_name, -Oracle_error_number); 　　在该语法中，异常名是声明的异常，下例是其用法： 　　DECLARE 　　deadlock_detected EXCEPTION; 　　PRAGMA EXCEPTION_INIT(deadlock_detected, -60); 　　BEGIN 　　&#8230; &#8212; Some operation that causes an ORA-00060 error 　　EXCEPTION 　　WHEN deadlock_detected THEN 　　&#8211; handle the error 　　END; 下面看一个例子 create or replace procedure SP_Del_Test (P_ItemAdmin in mfitem.itemadmin%type, &#8211;ItemAdmin P_ItemCd in mfitem.itemcd%type, &#8211;ItemCode P_Return out number &#8211;输出参数 ) is exp [...]]]></description>
			<content:encoded><![CDATA[<h5> 如果要处理未命名的内部异常，必须使用OTHERS异常处理器或PRAGMA EXCEPTION_INIT 。PRAGMA由编译器控制，或者是对于编译器的注释。PRAGMA在编译时处理，而不是在运行时处理。EXCEPTION_INIT告诉编译器将异常名与ORACLE错误码结合起来，这样可以通过名字引用任意的内部异常，并且可以通过名字为异常编写一适当的异常处理器。<br />
　　<br />
　　在子程序中使用EXCEPTION_INIT的语法如下：<br />
　　PRAGMA EXCEPTION_INIT(exception_name,<strong> -Oracle_error_number</strong>);<br />
<span id="more-477"></span><br />
　　在该语法中，异常名是声明的异常，下例是其用法：<br />
　　DECLARE<br />
　　deadlock_detected EXCEPTION;<br />
　　PRAGMA EXCEPTION_INIT(deadlock_detected, -60);<br />
　　BEGIN<br />
　　&#8230; &#8212; Some operation that causes an ORA-00060 error<br />
　　EXCEPTION<br />
　　WHEN deadlock_detected THEN<br />
　　&#8211; handle the error<br />
　　END;<br />
下面看一个例子</h5>
<h5>create or replace procedure SP_Del_Test<br />
(P_ItemAdmin in mfitem.itemadmin%type, &#8211;ItemAdmin<br />
P_ItemCd in mfitem.itemcd%type, &#8211;ItemCode<br />
P_Return out number &#8211;输出参数<br />
) is<br />
exp exception;<br />
PRAGMA Exception_Init(exp, -2292);<br />
begin<br />
delete from mfitem t<br />
where t.itemcd = P_ItemCd<br />
and t.itemadmin = P_ItemAdmin; &#8211;这一句会引发-2292异常，有级连删除异常<br />
EXCEPTION<br />
WHEN EXP THEN<br />
P_Return := 9;<br />
ROLLBACK;<br />
WHEN OTHERS THEN<br />
ROLLBACK;<br />
end SP_Del_Test;　　</h5>
<h5>使用自定义的异常，自定我们自己的错误消息：过程RAISE_APPLICATION_ERROR</h5>
<h5>调用RAISE_APPLICATION_ERROR的语法如下：</h5>
<h5>raise_application_error(error_number, message[, {TRUE | FALSE}]);</h5>
<h5>error_number是一个范围在-20000至-20999之间的负整数，message是最大长度为2048字节的字符串。如果第三个可选参数为TRUE的话，错误就会被放到前面错误的栈顶。如果为FALSE(默认值)，错误就会替代前面所有的错误。</h5>
<h5>CREATE PROCEDURE raise_salary (emp_id NUMBER, amount NUMBER) AS<br />
curr_sal NUMBER;<br />
BEGIN<br />
SELECT sal<br />
INTO curr_sal<br />
FROM emp<br />
WHERE empno = emp_id;<br />
IF curr_sal IS NULL THEN<br />
/* Issue user-defined error message. */<br />
raise_application_error (-20101, &#8216;Salary is missing&#8217;);<br />
ELSE<br />
UPDATE emp<br />
SET sal = curr_sal + amount<br />
WHERE empno = emp_id;<br />
END IF;<br />
END raise_salary;</h5>
<h5>如何抛出PL/SQL异常</h5>
<h5>DECLARE<br />
out_of_stock EXCEPTION;<br />
number_on_hand NUMBER (4);<br />
BEGIN<br />
&#8230;<br />
IF number_on_hand &lt; 1 THEN<br />
RAISE out_of_stock;<br />
END IF;<br />
EXCEPTION<br />
WHEN out_of_stock THEN<br />
&#8211; handle the error<br />
END;</h5>
<h5> </h5>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2011/09/pragma-exception_init/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ORACLE PL/SQL异常处理(Exception)学习笔记</title>
		<link>http://www.orablogger.com/2011/09/oracle-plsql-exception/</link>
		<comments>http://www.orablogger.com/2011/09/oracle-plsql-exception/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 03:08:50 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[Exception]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=474</guid>
		<description><![CDATA[1、PL/SQL错误类型 错误类型 报告者 处理方法 编译时错误 PL/SQL编译器 交互式地处理：编译器报告错误，你必须更正这些错误 运行时错误 PL/SQL运行时引擎 程序化地处理：异常由异常处理子程序引发并进行捕获 2、异常的声明 有两种异常：用户自定义异常和预定义异常 用户自定义异常就是由程序员自己定义的一个错误。该错误还不是非常重要，所以并没有将整个错误包含在Oracle的错误中。例如，它可能是一个与数据有关的错误。而预定义异常则对应于一般的SQL和PL/SQL错误。 用户自定义异常是在PL/SQL块的声明部分声明的。像变量一样，异常也有一个类型（EXCEPTION）和有效范围。例如：  DECLARE Exception_name EXCEPTION; …    3、异常的引发 与异常相关联的错误发生的时候，就会引发相应的异常。用户自定义异常是通过RAISE语句显式引发的，而预定义异常则是在它们关联的ORACLE错误发生的时候隐式引发的。如果发生了一个还没有和异常进行关联的ORACLE错误的时候，也会引发一个异常。该异常可以使用OTHERS子程序进行捕获。预定义的异常也可以使用RAISE进行显式地引发，如果需要这样做的话。 … RAISE exception_name; …      4、异常的处理 发生异常的时候，程序的控制就会转移到代码块的异常处理部分。异常处理部分是由异常处理子程序组成的，这些异常处理子程序可以是针对某些异常的，也可以是针对所有异常的。与该异常相关联的错误发生，并引发了该异常的时候，就会执行异常处理部分的代码。 异常处理部分的语法如下：  EXCEPTION WHEN exception_name THEN Sequence_of_statements1; WHEN exception_name THEN Sequence_of_statements2; WHEN OTHERS THEN Sequence_of_statements3; END;  每一个异常处理部分都是由WHEN子句和引发异常以后要执行的语句组成的。WHEN标识这个处理子程序是针对哪个异常的。 OTHERS异常处理子程序 PL/SQL定义了一个异常处理子程序，即OTHERS。当前异常处理部分定义的所有WHEN语句都没有处理的任意一个已引发的异常，都会导致执行这个OTHERS异常处理子程序。该异常处理子程序应该总是作为代码块的最后一个异常处理子程序，这样就会首先扫描前面的异常处理子程序。WHEN OTHERS会捕获所有异常，不管这些异常是预定义的，还是用户自定义的。 检查错误堆栈—SQLCODE和SQLERRM PL/SQL使用两个内置函数SQLCODE和SQLERRM提供错误信息。SQLCODE返回的是当前的错误代号，而SQLERRM返回的是当前的错误信息文本。如果是用户自定义的异常，SQLCODE就会返回值1，SQLERRM就会返回“ User-defined Exception”。  下面是一个使用SQLCODE和SQLERRM的例子 DECLARE   &#8212; [...]]]></description>
			<content:encoded><![CDATA[<div>
<h5><strong>1、PL/SQL错误类型</strong></h5>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="108">
<h5>错误类型</h5>
</td>
<td valign="top" width="156">
<h5>报告者</h5>
</td>
<td valign="top" width="265">
<h5>处理方法</h5>
</td>
</tr>
<tr>
<td valign="top" width="108">
<h5>编译时错误</h5>
</td>
<td valign="top" width="156">
<h5>PL/SQL编译器</h5>
</td>
<td valign="top" width="265">
<h5>交互式地处理：编译器报告错误，你必须更正这些错误</h5>
</td>
</tr>
<tr>
<td valign="top" width="108">
<h5>运行时错误</h5>
</td>
<td valign="top" width="156">
<h5>PL/SQL运行时引擎</h5>
</td>
<td valign="top" width="265">
<h5>程序化地处理：异常由异常处理子程序引发并进行捕获</h5>
</td>
</tr>
</tbody>
</table>
<h5><span id="more-474"></span></h5>
<h5><strong>2、异常的声明</strong></h5>
<h5>有两种异常：用户自定义异常和预定义异常</h5>
<h5>用户自定义异常就是由程序员自己定义的一个错误。该错误还不是非常重要，所以并没有将整个错误包含在Oracle的错误中。例如，它可能是一个与数据有关的错误。而预定义异常则对应于一般的SQL和PL/SQL错误。</h5>
<h5>用户自定义异常是在PL/SQL块的声明部分声明的。像变量一样，异常也有一个类型（EXCEPTION）和有效范围。例如： </h5>
<h5>DECLARE Exception_name EXCEPTION; …</h5>
<h5> </h5>
<h5> <strong>3、异常的引发</strong></h5>
<h5>与异常相关联的错误发生的时候，就会引发相应的异常。用户自定义异常是通过RAISE语句显式引发的，而预定义异常则是在它们关联的ORACLE错误发生的时候隐式引发的。如果发生了一个还没有和异常进行关联的ORACLE错误的时候，也会引发一个异常。该异常可以使用OTHERS子程序进行捕获。预定义的异常也可以使用RAISE进行显式地引发，如果需要这样做的话。</h5>
<h5>…<br />
RAISE exception_name;<br />
…</h5>
<h5>   </h5>
<h5> <strong>4、异常的处理</strong></h5>
<h5>发生异常的时候，程序的控制就会转移到代码块的异常处理部分。异常处理部分是由异常处理子程序组成的，这些异常处理子程序可以是针对某些异常的，也可以是针对所有异常的。与该异常相关联的错误发生，并引发了该异常的时候，就会执行异常处理部分的代码。</h5>
<h5>异常处理部分的语法如下：</h5>
<h5> EXCEPTION<br />
WHEN exception_name THEN<br />
Sequence_of_statements1;<br />
WHEN exception_name THEN<br />
Sequence_of_statements2;<br />
WHEN OTHERS THEN<br />
Sequence_of_statements3;<br />
END;</h5>
<h5> 每一个异常处理部分都是由WHEN子句和引发异常以后要执行的语句组成的。WHEN标识这个处理子程序是针对哪个异常的。</h5>
<h5>OTHERS异常处理子程序</h5>
<h5>PL/SQL定义了一个异常处理子程序，即OTHERS。当前异常处理部分定义的所有WHEN语句都没有处理的任意一个已引发的异常，都会导致执行这个OTHERS异常处理子程序。该异常处理子程序应该总是作为代码块的最后一个异常处理子程序，这样就会首先扫描前面的异常处理子程序。WHEN OTHERS会捕获所有异常，不管这些异常是预定义的，还是用户自定义的。</h5>
<h5>检查错误堆栈—SQLCODE和SQLERRM</h5>
<h5>PL/SQL使用两个内置函数<strong>SQLCODE</strong>和<strong>SQLERRM</strong>提供错误信息。SQLCODE返回的是当前的错误代号，而SQLERRM返回的是当前的错误信息文本。如果是用户自定义的异常，SQLCODE就会返回值1，SQLERRM就会返回“ User-defined Exception”。</h5>
<h5> 下面是一个使用SQLCODE和SQLERRM的例子</h5>
<h5>DECLARE<br />
  &#8212; Exception to indicate an error condition  </h5>
<h5>  e_DuplicateAuthors EXCEPTION;</h5>
<h5>  &#8212; IDs for three authors  </h5>
<h5>  v_Author1 books.author1%TYPE;</h5>
<h5>  v_Author2 books.author2%TYPE;</h5>
<h5>  v_Author3 books.author3%TYPE;</h5>
<h5>  &#8212; Code and text of other runtime errors  </h5>
<h5>  v_ErrorCode log_table.code%TYPE;</h5>
<h5>  v_ErrorText log_table.message%TYPE;</h5>
<h5>BEGIN</h5>
<h5>  /* Find the IDs for the 3 authors of &#8216;Oracle9i DBA 101&#8242; */</h5>
<h5>  SELECT author1, author2, author3<br />
 <br />
    INTO v_Author1, v_Author2, v_Author3<br />
 <br />
    FROM books<br />
 <br />
   WHERE title = &#8216;Oracle9i DBA 101&#8242;;</h5>
<h5>  /* Ensure that there are no duplicates */</h5>
<h5>  IF (v_Author1 = v_Author2) OR (v_Author1 = v_Author3) OR<br />
   <br />
     (v_Author2 = v_Author3) THEN<br />
 <br />
    RAISE e_DuplicateAuthors;<br />
 <br />
  END IF;</h5>
<h5>EXCEPTION</h5>
<h5>  WHEN e_DuplicateAuthors THEN<br />
 <br />
    /* Handler which executes when there are duplicate authors for <br />
   <br />
    Oracle9i DBA 101.  We will insert a log message recording  <br />
   <br />
    what has happened. */<br />
 <br />
    INSERT INTO log_table<br />
      (info)<br />
   <br />
    VALUES<br />
      (&#8216;Oracle9i DBA 101 has duplicate authors&#8217;);<br />
 <br />
  WHEN OTHERS THEN<br />
 <br />
    /* Handler which executes for all other errors. */<br />
 <br />
    v_ErrorCode := SQLCODE;<br />
 <br />
    &#8212; Note the use of SUBSTR here.  <br />
 <br />
    v_ErrorText := SUBSTR(SQLERRM, 1, 200);<br />
 <br />
    INSERT INTO log_table<br />
      (code, message, info)<br />
    VALUES<br />
   <br />
      (v_ErrorCode, v_ErrorText, &#8216;Oracle error occurred&#8217;);<br />
 <br />
END;</h5>
<h5>/</h5>
<h5>由于该堆栈上每一条错误消息文本的最大长度均为512个字节，但是堆栈中可能会有多条消息文本。在上面的例子中，v_ErrorText只有200个字符。如果该错误消息文本长度大于200个字符，那么赋值语句</h5>
<h5> v_ErrorText := SQLERRM;</h5>
<h5> 就会引发预定义的异常VALUE_ERROR。为了防止发生这种异常，我们使用了内置函数SUBSTR。</h5>
<h5> </h5>
<h5>注意，SQLCODE和SQLERRM的返回值首先会被分配给局部变量，然后再在SQL语句中使用这些局部变量。因为这些函数都是过程化的函数，所以不能直接在SQL语句中使用它们。</h5>
<h5> </h5>
<h5>通过下面这个例子我们看看错误号和相应的错误消息文本之间的关系</h5>
<h5> <br />
set serveroutput on  <br />
 <br />
BEGIN  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM(0): &#8216; || SQLERRM(0));  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM(100): &#8216; || SQLERRM(100));  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM(10): &#8216; || SQLERRM(10));  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM: &#8216; || SQLERRM);  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM(-1): &#8216; || SQLERRM(-1));  <br />
 <br />
  DBMS_OUTPUT.PUT_LINE(&#8216;SQLERRM(-54): &#8216; || SQLERRM(-54));  <br />
 <br />
END;  <br />
 <br />
/  <br />
 <br />
&#8211;运行结果如下  <br />
 <br />
SQL&gt; @SQLERRM.sql  <br />
 <br />
SQLERRM(0): ORA-0000: normal, successful completion  <br />
 <br />
SQLERRM(100): ORA-01403: no data found  <br />
 <br />
SQLERRM(10):  -10: non-ORACLE exception  <br />
 <br />
SQLERRM: ORA-0000: normal, successful completion  <br />
 <br />
SQLERRM(-1): ORA-00001: unique constraint (.) violated  <br />
 <br />
SQLERRM(-54): ORA-00054: resource busy and acquire with NOWAIT specified  <br />
 <br />
   <br />
 <br />
PL/SQL procedure successfully completed.  <br />
 </h5>
<h5>EXCEPTION_INIT pragma</h5>
<h5>你可以将一个经过命名的异常和一个特别的ORACLE错误相关联。这会<strong>使你专门能够捕获<em>此</em>错误，而不是通过</strong><strong>WHEN OTHERS</strong><strong>处理器来进行捕获</strong>。EXCEPTION_INIT pragma的语法如下：</h5>
<h5>PRAGMA       EXCEPTION_INIT(exception_name, <strong>-</strong><strong>Oracle_error_number</strong>);</h5>
<h5>这里，exception_name是在PRAGMA前面声明的异常的名字，而Oracle_error_number是与此命名异常相关的所需错误代码。这个PRAGMA必须在声明部分。</h5>
<h5>下面这个例子在运行时刻如果遇到“ORA-1400:mandatory NOT NULL column missing or NULL during insert”错误时将引发e_MissingNull&#8211;用户定义的异常。</h5>
<h5>DECLARE  <br />
 <br />
  e_MissingNull EXCEPTION;  <br />
 <br />
  PRAGMA EXCEPTION_INIT(e_MissingNull, -1400);  <br />
 <br />
BEGIN  <br />
 <br />
  INSERT INTO students (id) VALUES (NULL);  <br />
 <br />
EXCEPTION   s<br />
 <br />
  WHEN e_MissingNull then  <br />
 <br />
    INSERT INTO log_table (info) VALUES (&#8216;ORA-1400 occurred&#8217;);  <br />
 <br />
END;  <br />
 <br />
/ <br />
 <br />
 </h5>
<h5>每次发生PRAGMA EXCEPTION_INIT时，一个Oracle错误只能和一个用户自定义异常相关联。在异常处理内部，SQLCODE和SQLERRM将会返回发生Oracle错误的代码和错误消息，但是不会返回用户定义的消息。</h5>
<h5> </h5>
<h5>使用RAISE_APPLICATION_ERROR</h5>
<h5>你可以使用内置函数<strong>RAISE_APPLICATION_ERROR</strong>以创建自己的错误消息，这可能要比已命名的异常更具说明性。用户定义消息从块中传递到调用环境中的方式和ORACLE错误是一样的。语法如下：</h5>
<h5>RAISE_APPLICATION_ERROR(error_number,error_message,[keep_errors]);</h5>
<h5> </h5>
<h5>error_number是从-200000到-20999之间的参数，error_message是与此错误相关的正文，不能多于512个字节。而<strong>keep_errors</strong>是一个布尔值，是可选的，如果为TRUE，那么新的错误将被添加到已经引发的错误列表中（如果有的话）。如果为FALSE（这是缺省的设置），那么新的错误将替换错误的当前列表。</h5>
<h5> </h5>
<h5>例如下面的这个例子将在为一个新的学生注册以前检查是否在班级中有足够的地方容纳他。</h5>
<h5>CREATE OR REPLACE PROCEDURE Register(<br />
                                    <br />
                                     /* Registers the student identified by the p_StudentID parameter in the class <br />
                                     <br />
                                          identified by the p_Department and p_Course parameters. Before calling <br />
                                     <br />
                                          ClassPackage.AddStudent, which actually adds the student to the class, this <br />
                                     <br />
                                          procedure verifies that there is room in the class, and that the class <br />
                                     <br />
                                          exists. */<br />
                                    <br />
                                     p_StudentID IN students.id%TYPE,<br />
                                    <br />
                                     p_Department IN classes.department%TYPE,<br />
                                    <br />
                                     p_Course IN classes.course%TYPE) AS</h5>
<h5>  v_CurrentStudents NUMBER; &#8212; Current number of students in the class </h5>
<h5>  v_MaxStudents NUMBER; &#8212; Maximum number of students in the class </h5>
<h5>BEGIN</h5>
<h5>  /* Determine the current number of students registered, and the maximum <br />
 <br />
  number of students allowed to register. */</h5>
<h5>  SELECT current_students, max_students<br />
 <br />
    INTO v_CurrentStudents, v_MaxStudents<br />
 <br />
    FROM classes<br />
 <br />
   WHERE course = p_Course<br />
       <br />
     AND department = p_Department;</h5>
<h5>  /* Make sure there is enough room for this additional student. */</h5>
<h5>  IF v_CurrentStudents + 1 &gt; v_MaxStudents THEN<br />
 <br />
    RAISE_APPLICATION_ERROR(-20000,<br />
                            &#8216;Can&#8221;t add more students to &#8216; ||<br />
                           <br />
                            p_Department || &#8216; &#8216; || p_Course);<br />
 <br />
  END IF;</h5>
<h5>  /* Add the student to the class. */</h5>
<h5>  ClassPackage.AddStudent(p_StudentID, p_Department, p_Course);</h5>
<h5>EXCEPTION</h5>
<h5>  WHEN NO_DATA_FOUND THEN<br />
 <br />
    /* Class information passed to this procedure doesn&#8217;t exist. Raise an error <br />
   <br />
    to let the calling program know of this. */<br />
 <br />
    RAISE_APPLICATION_ERROR(-20001,<br />
                            p_Department || &#8216; &#8216; || p_Course ||<br />
                           <br />
                            &#8216; doesn&#8221;t exist!&#8217;);<br />
 <br />
END Register;</h5>
<h5>/</h5>
<h5> </h5>
<h5><strong>5、异常的传播</strong></h5>
<h5> </h5>
<h5>1）在执行部分引发的异常</h5>
<h5>当一个异常是在块的执行部分引发的，PL/SQL使用下面的方法决定要激活哪个异常处理器：</h5>
<h5>如果当前块对该异常设置了处理器，那么执行它并成功完成该块的执行，然后控制会转给包含块。</h5>
<h5>如果当前块没有对当前异常定义处理器，那么通过在包含块中引发它来传播异常。然后对包含块执行步骤一。</h5>
<h5> </h5>
<h5>2）在声明部分引发的异常</h5>
<h5>如果在声明部分的赋值操作引发了一个异常，那么该异常将立即传播给包含块。发生这种情况以后，在前面给出的法则将进一步被应用到异常的传播上。尽管在当前块中有一个处理器，它也不会被执行。</h5>
<h5> </h5>
<h5>3）在异常处理部分引发的异常</h5>
<h5>在异常处理器中也可能引发异常，这可以是通过RAISE语句显式引发的，也可以是由运行时刻错误隐含引发的。无论怎样，异常都立即被传播给包含块，这和声明部分引发的异常相类似。</h5>
<h5> </h5>
<h5> </h5>
<h5><strong>6、使用异常的准则</strong></h5>
<h5> </h5>
<h5>1）异常的范围</h5>
<h5>异常像变量一样，也是有一定范围的。如果用户自定义异常传播到它的范围之外，就不能再通过名称引用它。</h5>
<h5> </h5>
<h5>BEGIN<br />
  DECLARE<br />
 <br />
    e_UserDefinedException EXCEPTION;<br />
 <br />
  BEGIN<br />
 <br />
    RAISE e_UserDefinedException;<br />
 <br />
  END;</h5>
<h5>EXCEPTION</h5>
<h5>  /* e_UserDefinedException is out of scope here &#8211; can only be <br />
 <br />
  handled by an OTHERS handler */</h5>
<h5>  WHEN OTHERS THEN<br />
 <br />
    /* Just re-raise the exception, which will be propagated to the <br />
   <br />
    calling environment */<br />
 <br />
    RAISE;<br />
 <br />
END;</h5>
<h5>/</h5>
<h5> </h5>
<h5>一般而言，如果打算将用户自定义的错误传播到代码块之外，最好的方法就是在包中定义该异常，以使其在该代码块之外仍可见，或使用RAISE_APPLICATION_ERROR引发该异常。如果创建一个成为GLOBALS的包，并在其中定义了一个e_UserDefinedException异常，那么这个异常在外部块中仍然可见。</h5>
<h5> </h5>
<h5>如下例所示</h5>
<h5>  <br />
/* This package contains global declarations. Objects declared here will  <br />
 <br />
   be visible via qualified references for any other blocks or procedures. <br />
 <br />
   Note that this package does not have a package body. */ <br />
 <br />
   <br />
 <br />
  /* A user-defined exception. */ <br />
 <br />
  e_UserDefinedException EXCEPTION;  <br />
 <br />
END Globals;  <br />
 <br />
/  <br />
 <br />
   <br />
 <br />
&#8211;有了这个和GLOBALS包以后，就可以重写前面的代码：  <br />
 <br />
   <br />
 <br />
BEGIN  <br />
 <br />
  BEGIN  <br />
 <br />
    RAISE Globals.e_UserDefinedException;  <br />
 <br />
  END;  <br />
 <br />
EXCEPTION  <br />
 <br />
  /* Since e_UserDefinedException is still visible, we can handle it  <br />
 <br />
     explicitly */ <br />
 <br />
  WHEN Globals.e_UserDefinedException THEN           &#8211;引用包中定义异常  <br />
 <br />
    /* Just re-raise the exception, which will be propagated to the <br />
 <br />
       calling environment */ <br />
 <br />
    RAISE;  <br />
 <br />
END;  <br />
 <br />
/ <br />
 <br />
 </h5>
<h5>2）避免未处理的异常</h5>
<h5>优秀的编程经验是在整个程序中避免出现任何未经过处理的异常。这可以通过在程序的最顶层使用一个OTHERS子程序来实现。该处理子程序可以只登记错误并登记错误发生的位置，通过这种方法，就可以保证每个错误都会得到检查。</h5>
<h5> </h5>
<h5>如下例所示</h5>
<h5> </h5>
<h5>CREATE OR REPLACE PACKAGE Globals AS</h5>
<h5>  v_errortext varchar2(200);</h5>
<h5>Begin</h5>
<h5>  …<br />
 <br />
  EXCEPTION<br />
 <br />
  WHEN OTHERS THEN<br />
 <br />
  v_errornumber := SQLCODE;</h5>
<h5>  v_errortext := SUBSTR(SQLERRM, 1, 200);</h5>
<h5>  INSERT INTO log_table<br />
    (code, message, info)<br />
 <br />
  VALUES<br />
 <br />
    (v_errornumber,<br />
     v_errortext,<br />
     ’Oracle error occurred<br />
     at’ || TO_CHAR(SYSDATE, ’DD &#8211; MON &#8211; YY HH24 :MI :SS’));</h5>
<h5>END;</h5>
<h5>3）标识错误发生的位置</h5>
<h5>由于整个代码块都使用同一个异常处理部分检查并处理异常，所以很难确定引发这个错误的是哪一条SQL语句。考虑下面示例</h5>
<h5> <br />
BEGIN<br />
SELECT…  <br />
 <br />
SELECT..  <br />
 <br />
SELECT…  <br />
 <br />
EXCEPTION  <br />
 <br />
WHEN NO_DATA_FOUND THEN  <br />
 <br />
&#8211;which select statement raised the exception?  <br />
 <br />
END;  <br />
 <br />
   <br />
 <br />
&#8211;解决上述问题的方法有两种。第一种是添加一个标识该SQL语句的计数器：  <br />
 <br />
   <br />
 <br />
DECLARE  <br />
 <br />
V_selectcounter NUMBER:=1;  <br />
 <br />
BEGIN  <br />
 <br />
SELECT…  <br />
 <br />
V_selectcounter NUMBER:=2;  <br />
 <br />
SELECT…  <br />
 <br />
V_selectcounter NUMBER:=3;  <br />
 <br />
SELECT…  <br />
 <br />
EXCEPTION  <br />
 <br />
WHEN NO_DATA_FOUND THEN  <br />
 <br />
INSERT INTO log_table(info) VALUES(‘NO DATA FOUND IN SELECT’||v_selectcounter);  <br />
 <br />
END;  <br />
 <br />
   <br />
 <br />
&#8211;另一种方法是将每一条语句都放置在它自己的子块中：  <br />
 <br />
   <br />
 <br />
BEGIN  <br />
 <br />
BEGIN  <br />
 <br />
              SELECT…  <br />
 <br />
       EXCEPTION  <br />
 <br />
              WHEN NO_DATA_FOUND THEN  <br />
 <br />
                     INSERT INTO log_table(info) VALUES(‘NO DATA FOUND IN SELECT 1’);  <br />
 <br />
       END;  <br />
 <br />
BEGIN  <br />
 <br />
              SELECT…  <br />
 <br />
       EXCEPTION  <br />
 <br />
              WHEN NO_DATA_FOUND THEN  <br />
 <br />
                     INSERT INTO log_table(info) VALUES(‘NO DATA FOUND IN SELECT 2’);  <br />
 <br />
       END;  <br />
 <br />
BEGIN  <br />
 <br />
              SELECT…  <br />
 <br />
       EXCEPTION  <br />
 <br />
              WHEN NO_DATA_FOUND THEN  <br />
 <br />
                     INSERT INTO log_table(info) VALUES(‘NO DATA FOUND IN SELECT 3’);  <br />
 <br />
       END;  <br />
 <br />
END;  <br />
  <br />
  </h5>
<h5><strong>7、异常代码的编写风格</strong></h5>
<h5> </h5>
<h5>1）RAISE_APPLICATION_ERROR和RAISE的比较</h5>
<h5> </h5>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="237">
<h5>RAISE_APPLICATION_ERROR</h5>
</td>
<td valign="top">
<h5>RAISE</h5>
</td>
</tr>
<tr>
<td valign="top" width="237">
<h5>允许我们填写自己的错误消息文本，该文本可以包含应用程序专用的数据</h5>
</td>
<td valign="top">
<h5>不允许包含消息文本</h5>
</td>
</tr>
<tr>
<td valign="top" width="237">
<h5>不能使用已命名的异常处理子程序进行捕获，只能使用OTHERS处理子程序进行捕获</h5>
</td>
<td valign="top">
<h5>可以使用已命名的处理子程序捕获该异常，只要该异常在它自己的异常范围内即可</h5>
</td>
</tr>
</tbody>
</table>
<h5> </h5>
<h5>通常而言，推荐对设计给终端用户看的错误，使用RAISE_APPLICATION_ERROR。因为对于他们而言，具体的错误编号和描述性文本非常有用。而另一方面，对设计为由程序直接进行处理的异常，推荐使用RAISE。</h5>
<h5> </h5>
<h5>2）将异常作为控制语句</h5>
<h5>因为引发异常会将程序的控制逻辑转移到代码块的异常处理部分，所以可以将RAISE语句用作控制语句，就像GOTO语句一样。例如，如果我们有很深的嵌套循环，并需要立即从中退出的时候，这可能会非常有用。</h5>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2011/09/oracle-plsql-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle中的格式化函数</title>
		<link>http://www.orablogger.com/2011/08/oracle%e4%b8%ad%e7%9a%84%e6%a0%bc%e5%bc%8f%e5%8c%96%e5%87%bd%e6%95%b0/</link>
		<comments>http://www.orablogger.com/2011/08/oracle%e4%b8%ad%e7%9a%84%e6%a0%bc%e5%bc%8f%e5%8c%96%e5%87%bd%e6%95%b0/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 01:18:02 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=470</guid>
		<description><![CDATA[  格式化函数提供一套有效的工具用于把各种数据类型（日期/时间，int，float，numeric）转换成格式化的字符串以及反过来从格式化的字符串转换成原始的数据类型。 表 5-6. 格式化函数 函数 返回 描述 例子 to_char(datetime, text) text 把datetime 转换成 string to_char(&#8216;now&#8217;::datetime, &#8216;hh12:mi:ss&#8217;) to_char(timestamp, text) text 把 timestamp 转换成 string to_char( now(), &#8216;hh12:mi:ss&#8217;) to_char(int, text) text 把 int4/int8 转换成 string to_char(125, &#8217;999&#8242;) to_char(float, text) text 把 float4/float8 转换成 string to_char(125.8, &#8217;999d9&#8242;) to_char(numeric, text) text 把 numeric 转换成 string to_char(-125.8, &#8217;999d99s&#8217;) to_datetime(text, [...]]]></description>
			<content:encoded><![CDATA[<h5> </h5>
<p>格式化函数提供一套有效的工具用于把各种数据类型（日期/时间，int，float，numeric）转换成格式化的字符串以及反过来从格式化的字符串转换成原始的数据类型。</p>
<p><strong>表 5-6. 格式化函数</strong><br />
<span id="more-470"></span></p>
<table class="calstable" border="1">
<tbody>
<tr>
<th align="left" valign="top">函数</th>
<th align="left" valign="top">返回</th>
<th align="left" valign="top">描述</th>
<th align="left" valign="top">例子</th>
</tr>
<tr>
<td valign="top">to_char(datetime, text)</td>
<td valign="top">text</td>
<td valign="top">把datetime 转换成<br />
string</td>
<td valign="top">to_char(&#8216;now&#8217;::datetime,<br />
&#8216;hh12:mi:ss&#8217;)</td>
</tr>
<tr>
<td valign="top">to_char(timestamp, text)</td>
<td valign="top">text</td>
<td valign="top">把 timestamp 转换成<br />
string</td>
<td valign="top">to_char( now(),<br />
&#8216;hh12:mi:ss&#8217;)</td>
</tr>
<tr>
<td valign="top">to_char(int,<br />
text)</td>
<td valign="top">text</td>
<td valign="top">把 int4/int8 转换成<br />
string</td>
<td valign="top">to_char(125,<br />
&#8217;999&#8242;)</td>
</tr>
<tr>
<td valign="top">to_char(float,<br />
text)</td>
<td valign="top">text</td>
<td valign="top">把 float4/float8<br />
转换成 string</td>
<td valign="top">to_char(125.8,<br />
&#8217;999d9&#8242;)</td>
</tr>
<tr>
<td valign="top">to_char(numeric, text)</td>
<td valign="top">text</td>
<td valign="top">把 numeric 转换成<br />
string</td>
<td valign="top">to_char(-125.8,<br />
&#8217;999d99s&#8217;)</td>
</tr>
<tr>
<td valign="top">to_datetime(text, text)</td>
<td valign="top">datetime</td>
<td valign="top">把 string 转换成<br />
datetime</td>
<td valign="top">to_datetime(&#8217;05<br />
dec 2000 13&#8242;, &#8216;dd mon yyyy hh&#8217;)</td>
</tr>
<tr>
<td valign="top">to_date(text,<br />
text)</td>
<td valign="top">date</td>
<td valign="top">把 string 转换成<br />
date</td>
<td valign="top">to_date(&#8217;05 dec<br />
2000&#8242;, &#8216;dd mon yyyy&#8217;)</td>
</tr>
<tr>
<td valign="top">to_timestamp(text, text)</td>
<td valign="top">date</td>
<td valign="top">把 string 转换成<br />
timestamp</td>
<td valign="top">to_timestamp(&#8217;05 dec 2000&#8242;, &#8216;dd<br />
mon yyyy&#8217;)</td>
</tr>
<tr>
<td valign="top">to_number(text,<br />
text)</td>
<td valign="top">numeric</td>
<td valign="top">把 string 转换成<br />
numeric</td>
<td valign="top">to_number(&#8217;12,454.8-&#8217;,<br />
&#8217;99g999d9s&#8217;)</td>
</tr>
</tbody>
</table>
<p>所有格式化函数都是 format-picture （格式图）的第二个参数。</p>
<p><strong>表 5-7. 用于日期/时间 to_char() 版本的format-pictures。</strong></p>
<table class="calstable" border="1">
<tbody>
<tr>
<th align="left" valign="top">format-picture</th>
<th align="left" valign="top">描述</th>
</tr>
<tr>
<td valign="top">hh</td>
<td valign="top">一天中的小时 (01-12)</td>
</tr>
<tr>
<td valign="top">hh12</td>
<td valign="top">一天中的小时 (01-12)</td>
</tr>
<tr>
<td valign="top">mi</td>
<td valign="top">分钟 (00-59)</td>
</tr>
<tr>
<td valign="top">ss</td>
<td valign="top">秒 (00-59)</td>
</tr>
<tr>
<td valign="top">ssss</td>
<td valign="top">过了午夜的秒<br />
(0-86399)</td>
</tr>
<tr>
<td valign="top">y,yyy</td>
<td valign="top">带逗号的年 (4 或更多位)</td>
</tr>
<tr>
<td valign="top">yyyy</td>
<td valign="top">年 (4 或更多位)</td>
</tr>
<tr>
<td valign="top">yyy</td>
<td valign="top">年的最后三位</td>
</tr>
<tr>
<td valign="top">yy</td>
<td valign="top">年的最后两位</td>
</tr>
<tr>
<td valign="top">y</td>
<td valign="top">年的最后一位</td>
</tr>
<tr>
<td valign="top">month</td>
<td valign="top">完整的月份名（9字符）-所有字符大写</td>
</tr>
<tr>
<td valign="top">month</td>
<td valign="top">完整的月份名（9字符）-首字符大写</td>
</tr>
<tr>
<td valign="top">month</td>
<td valign="top">完整的月份名（9字符）-所有字符小写</td>
</tr>
<tr>
<td valign="top">mon</td>
<td valign="top">缩写的月份名（3字符）-所有字符大写</td>
</tr>
<tr>
<td valign="top">mon</td>
<td valign="top">缩写的月份名（3字符）-首字符大写</td>
</tr>
<tr>
<td valign="top">mon</td>
<td valign="top">缩写的月份名（3字符）-所有字符小写</td>
</tr>
<tr>
<td valign="top">mm</td>
<td valign="top">月份(01-12)</td>
</tr>
<tr>
<td valign="top">day</td>
<td valign="top">完整的日期名（9字符）-所有字符大写</td>
</tr>
<tr>
<td valign="top">day</td>
<td valign="top">完整的日期名（9字符）-首字符大写</td>
</tr>
<tr>
<td valign="top">day</td>
<td valign="top">完整的日期名（9字符）-所有字符小写</td>
</tr>
<tr>
<td valign="top">dy</td>
<td valign="top">缩写的日期名（3字符）-所有字符大写</td>
</tr>
<tr>
<td valign="top">dy</td>
<td valign="top">缩写的日期名（3字符）-首字符大写</td>
</tr>
<tr>
<td valign="top">dy</td>
<td valign="top">缩写的日期名（3字符）-所有字符小写</td>
</tr>
<tr>
<td valign="top">ddd</td>
<td valign="top">一年中的日子<br />
(001-366)</td>
</tr>
<tr>
<td valign="top">dd</td>
<td valign="top">一月中的日子 (01-31)</td>
</tr>
<tr>
<td valign="top">d</td>
<td valign="top">一周中的日子 (1-7;<br />
sun=1)</td>
</tr>
<tr>
<td valign="top">w</td>
<td valign="top">月中的周</td>
</tr>
<tr>
<td valign="top">ww</td>
<td valign="top">年中的周</td>
</tr>
<tr>
<td valign="top">cc</td>
<td valign="top">世纪（两位）</td>
</tr>
<tr>
<td valign="top">j</td>
<td valign="top">julian 日子（从4712<br />
bc 年一月一日以来的日子）</td>
</tr>
<tr>
<td valign="top">q</td>
<td valign="top">季度</td>
</tr>
<tr>
<td valign="top">rm</td>
<td valign="top">罗马数字的月份 (i-xii;<br />
i=jan)</td>
</tr>
</tbody>
</table>
<p>所有 format-pictures （格式图）允许使用后缀（后缀/前缀）。对于近似<br />
format-picture（格式图），后缀总是有效的。&#8217;fx&#8217;只是全局前缀。</p>
<p><strong>表 5-8. 用于日期/时间 to_char() 版本的 format-pictures （格式图）后缀。</strong></p>
<table class="calstable" border="1">
<tbody>
<tr>
<th align="left" valign="top">后缀</th>
<th align="left" valign="top">描述</th>
<th align="left" valign="top">例子</th>
</tr>
<tr>
<td valign="top">fm</td>
<td valign="top">填充模式-前缀</td>
<td valign="top">fmmonth</td>
</tr>
<tr>
<td valign="top">th</td>
<td valign="top">大写顺序数-前缀</td>
<td valign="top">ddth</td>
</tr>
<tr>
<td valign="top">th</td>
<td valign="top">小写顺序数-后缀</td>
<td valign="top">ddth</td>
</tr>
<tr>
<td valign="top">fx</td>
<td valign="top">fx &#8211; （固定模式）全局<br />
format-picture<br />
（格式图）开关。如果没有使用这个选项 to_datetime /<br />
to_date<br />
忽略空白。必须作为formt-picture（格式图）里的第一个项目使用。</td>
<td valign="top">fx month dd day</td>
</tr>
<tr>
<td valign="top">sp</td>
<td valign="top">拼写模式（目前未实现）</td>
<td valign="top">ddsp</td>
</tr>
</tbody>
</table>
<p>&#8216;/&#8217; &#8211; 必须用做双 //，例如 &#8216;//hh//mi//ss&#8217;</p>
<p>&#8216;&#8221;&#8216; &#8211; 双引号之间的字串被忽略并且不被分析。如果你想向输出写 &#8216;&#8221;&#8216; 你必须用 //&#8221;，例如 &#8216;//&#8221;yyyy<br />
month//&#8221;&#8216;。</p>
<p>text &#8211; postgresql 的 to_char() 支持不带 &#8216;&#8221;&#8216;<br />
的文本，但是带有双引号的字串会快些并且可以保证该文本不会被解释成关键字（format-picture，格式图），例如<br />
&#8216;&#8221;hello year: &#8220;yyyy&#8217;。</p>
<p><strong>表 5-9. 用于数字 (int/float/numeric) to_char()<br />
版本的format-pictures （格式图）。</strong></p>
<table class="calstable" border="1">
<tbody>
<tr>
<th align="left" valign="top">格式图</th>
<th align="left" valign="top">描述</th>
</tr>
<tr>
<td valign="top">9</td>
<td valign="top">返回指定位数的值，如果不够位数用空白代替</td>
</tr>
<tr>
<td valign="top">0</td>
<td valign="top">象 9<br />
一样，但是把空白替换成零</td>
</tr>
<tr>
<td valign="top">. (句点)</td>
<td valign="top">小数点</td>
</tr>
<tr>
<td valign="top">, (逗号)</td>
<td valign="top">分组（千进）分隔符</td>
</tr>
<tr>
<td valign="top">pr</td>
<td valign="top">在尖括号内返回负数</td>
</tr>
<tr>
<td valign="top">s</td>
<td valign="top">用负号返回负数（使用本地）</td>
</tr>
<tr>
<td valign="top">l</td>
<td valign="top">货币符号（使用本地）</td>
</tr>
<tr>
<td valign="top">d</td>
<td valign="top">小数点（使用本地）</td>
</tr>
<tr>
<td valign="top">g</td>
<td valign="top">分组符（使用本地）</td>
</tr>
<tr>
<td valign="top">mi</td>
<td valign="top">在指定位置返回负号（如果数字<br />
&lt; 0）</td>
</tr>
<tr>
<td valign="top">pl</td>
<td valign="top">在指定位置返回正号（如果数字<br />
&gt; 0） postgresql 扩展</td>
</tr>
<tr>
<td valign="top">sg</td>
<td valign="top">在指定位置返回正/负号（如果数字 &lt; 0） -<br />
postgresql 扩展</td>
</tr>
<tr>
<td valign="top">rn</td>
<td valign="top">返回数字的罗马数字（数字必须介于1 和 3999之间）</td>
</tr>
<tr>
<td valign="top">th 或th</td>
<td valign="top">把数字转换成自然数（如果是负数或小数不转换） -<br />
postgresql 扩展</td>
</tr>
<tr>
<td valign="top">v</td>
<td valign="top">arg1 * (10 ^<br />
n)；- 返回一个乘以 10^n （这里 &#8216;n&#8217;<br />
是&#8217;v'后面的数字 &#8217;9&#8242;）。to_char() 不支持同时使用<br />
&#8216;v&#8217; 和小数点，如 &#8220;99.9v99&#8243;。</td>
</tr>
<tr>
<td valign="top">eeee</td>
<td valign="top">科学记数，目前不支持。</td>
</tr>
</tbody>
</table>
<p>注意：通过a sign formatted via &#8216;sg&#8217;，&#8217;pl&#8217; 或 &#8216;mi&#8217;<br />
格式化的符号数不一定是数字；to_char(-12, &#8216;s9999&#8242;)生成：</p>
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' -12'</pre>
<p>，但是 to_char(-12, &#8216;mi9999&#8242;)生成：</p>
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'- 12'</pre>
<p>。oracle 不允许在 &#8217;9&#8242; 前面使用 &#8216;mi&#8217;，在 oracle 里，它总是在 &#8217;9&#8242; 后面。.</p>
<p><strong>表 5-10. to_char()的例子</strong></p>
<table class="calstable" border="1">
<tbody>
<tr>
<th align="left" valign="top">输入</th>
<th align="left" valign="top">输出</th>
</tr>
<tr>
<td valign="top">to_char(now(),<br />
&#8216;day, hh12:mi:ss&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'tuesday , 05:39:18'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char(now(),<br />
&#8216;fmday, hh12:mi:ss&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'tuesday, 05:39:18'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -0.1,<br />
&#8217;99.99&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' -.10'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -0.1,<br />
&#8216;fm9.99&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'-.1'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 0.1,<br />
&#8217;0.9&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 0.1'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 12,<br />
&#8217;9990999.9&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 0012.0'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 12,<br />
&#8216;fm9990999.9&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'0012'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8217;999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8217;999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'-485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8217;9 9 9&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 4 8 5'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 1485,<br />
&#8217;9,999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 1,485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 1485,<br />
&#8217;9g999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 1 485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 148.5,<br />
&#8217;999.999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 148.500'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 148.5,<br />
&#8217;999d999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 148,500'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char(<br />
3148.5,&#8217;9g999d999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 3 148,500'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8217;999s&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'485-'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8217;999mi&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'485-'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8217;999mi&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;pl999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'+485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;sg999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'+485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8216;sg999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'-485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8217;9sg99&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'4-85'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( -485,<br />
&#8217;999pr&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'&lt;485&gt;'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;l999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'dm 485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;rn&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' cdlxxxv'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;fmrn&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'cdlxxxv'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 5.2,<br />
&#8216;fmrn&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'v'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 482,<br />
&#8217;999th&#8217;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 482nd'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485,<br />
&#8216;&#8221;good number:&#8221;999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'good number: 485'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 485.8,<br />
&#8216;&#8221;pre-decimal:&#8221;999&#8243;<br />
post-decimal:&#8221; .999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">'pre-decimal: 485 post-decimal: .800'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 12,<br />
&#8217;99v999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 12000'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 12.4,<br />
&#8217;99v999&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 12400'</pre>
</td>
</tr>
<tr>
<td valign="top">to_char( 12.45,<br />
&#8217;99v9&#8242;)</td>
<td valign="top">
<pre class="programlisting" style="word-wrap: break-word; white-space: normal;">' 125'</pre>
</td>
</tr>
</tbody>
</table>
<h5> </h5>
<h5> </h5>
<h5> </h5>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2011/08/oracle%e4%b8%ad%e7%9a%84%e6%a0%bc%e5%bc%8f%e5%8c%96%e5%87%bd%e6%95%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle10GR2 中的RESTORE POINT</title>
		<link>http://www.orablogger.com/2010/07/oracle10gr2-%e4%b8%ad%e7%9a%84restore-point/</link>
		<comments>http://www.orablogger.com/2010/07/oracle10gr2-%e4%b8%ad%e7%9a%84restore-point/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 08:04:41 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[备份与恢复]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[RESTORE POINT]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=463</guid>
		<description><![CDATA[RESTORE POINT 还原点是10GR2新增加的一个功能,它是建立在数据库层面上的, 跟savepoint不同. 必须在数据库处于ARCHIVELOG模式下才可以使用,主题思想是在数据库的某个时间点创建一个restore point,在随后的某个时间点可以将表或数据库falshback 到这个restore point.那么能否真正的完成flashback,依赖于创建的restore point类型和flashback要操作的对象.flashback database需要SYSDBA权限,flashback table需要 FLASHBACK ANY TABLE的权限. guarantee restore point for flashback database guarantee restore point必须在数据库处于flashback on 的状态下，才可以定义的一中restore point,它的主题思想是保证数据库能够准确完整的flashback 到定义的 restore point. 操作依赖于flashback log和archivelog, 如果定义了guarantee restore point,那么flashback logs将不受db_recovery_retention_target参数的限制,oracle不会删除flashback log,只要flashback arae有足够的磁盘空间,oracle就会保存足够的flashback logs,满足flashback database to restore point. 如果数据库没有处于flashback on,那么定义一个guarantee restore point必须在database mount状态下进行.其实这个也可以理解,oracle根据定义的restore point,可以个保证database open后的归档可以不被删除.但有一点必须明确的是,guarantee restore point是针对flashback database而言的,不对flashback table起作用，为什么呢, 因为flashback table依赖于undo,如果在guarantee时间范围内,undo过期了, [...]]]></description>
			<content:encoded><![CDATA[<p>RESTORE POINT</p>
<p>还原点是10GR2新增加的一个功能,它是建立在数据库层面上的, 跟savepoint不同. 必须在数据库处于ARCHIVELOG模式下才可以使用,主题思想是在数据库的某个时间点创建一个restore point,在随后的某个时间点可以将表或数据库falshback 到这个restore point.那么能否真正的完成flashback,依赖于创建的restore point类型和flashback要操作的对象.flashback database需要SYSDBA权限,flashback table需要 FLASHBACK ANY TABLE的权限.<br />
<span id="more-463"></span><br />
guarantee restore point for flashback database</p>
<p>guarantee restore point必须在数据库处于flashback on 的状态下，才可以定义的一中restore point,它的主题思想是保证数据库能够准确完整的flashback 到定义的 restore point. 操作依赖于flashback log和archivelog, 如果定义了guarantee restore point,那么flashback logs将不受db_recovery_retention_target参数的限制,oracle不会删除flashback log,只要flashback arae有足够的磁盘空间,oracle就会保存足够的flashback logs,满足flashback database to restore point.</p>
<p>如果数据库没有处于flashback on,那么定义一个guarantee restore point必须在database mount状态下进行.其实这个也可以理解,oracle根据定义的restore point,可以个保证database open后的归档可以不被删除.但有一点必须明确的是,guarantee restore point是针对flashback database而言的,不对flashback table起作用，为什么呢, 因为flashback table依赖于undo,如果在guarantee时间范围内,undo过期了, 那么flatable table 还是不能还原到定义的guarantee restore point.</p>
<p>Normal restore point</p>
<p>普通的restore point 非常简单, 如果要flashback database,那么数据库必须处于flashback on 状态,但这个时候不一定可以flashback database到定义的restore point,oracle会根据db_recovery_retention_target自动维护创建的restore ponit和flashback logs,如果超过db_recovery_retention_target 定义的restore point,oracle会自动删除 , 无论是flashback table或者flashback database都不能完成.</p>
<p>简单的流水帐记录,为了试自己更加明确restore point的原理.</p>
<p>创建一个guarantee restore point</p>
<p>SQL&gt; create restore point a guarantee flashback database;<br />
创建一个普通的restore point</p>
<p>SQL&gt; create restore point b;<br />
flashback dtaase to restore point:(必须在guarantee restore point for flashback database的情况)</p>
<p>SQL&gt; startup mount<br />
ORACLE instance started.</p>
<p>Total System Global Area 209715200 bytes</p>
<p>Fixed Size 1266632 bytes</p>
<p>Variable Size 134220856 bytes</p>
<p>Database Buffers 71303168 bytes</p>
<p>Redo Buffers 2924544 bytes</p>
<p>Database mounted.</p>
<p>SQL&gt; flashback database to restore point a;</p>
<p>Flashback complete.</p>
<p>SQL&gt; alter database open resetlogs;</p>
<p>Database altered.</p>
<p>falshback table</p>
<p>SQL&gt; alter table test_histogram enable row movement;</p>
<p>Table altered.</p>
<p>SQL&gt; flashback table test_histogram to restore point a;</p>
<p>Flashback complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2010/07/oracle10gr2-%e4%b8%ad%e7%9a%84restore-point/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>man vmstat on HP-UX</title>
		<link>http://www.orablogger.com/2010/06/man-vmstat-on-hp-ux/</link>
		<comments>http://www.orablogger.com/2010/06/man-vmstat-on-hp-ux/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 14:25:35 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[hp-ux]]></category>
		<category><![CDATA[vmstat]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=461</guid>
		<description><![CDATA[        vmstat &#8211; report virtual memory statistics  SYNOPSIS       vmstat [-dnS] [interval [count]]       vmstat -f &#124; -s &#124; -z  DESCRIPTION       The vmstat command reports certain statistics kept about process,       virtual memory, trap, and CPU activity.  It also can clear the       accumulators in the kernel sum structure.]]></description>
			<content:encoded><![CDATA[<p> <br />
      vmstat &#8211; report virtual memory statistics</p>
<p><span id="more-461"></span><br />
 SYNOPSIS</p>
<p>      vmstat [-dnS] [interval [count]]</p>
<p>      vmstat -f | -s | -z</p>
<p> DESCRIPTION</p>
<p>      The vmstat command reports certain statistics kept about process,</p>
<p>      virtual memory, trap, and CPU activity.  It also can clear the</p>
<p>      accumulators in the kernel sum structure.<br />
<!--more><br />
    Options</p>
<p>      vmstat recognizes the following options:</p>
<p>           -d        Report disk transfer information as a separate section,</p>
<p>                     in the form of transfers per second. <strong>(</strong><strong>增加显示每个磁盘的每秒传输率)</strong></p>
<p>           -n        Provide an output format that is more easily viewed on</p>
<p>                     an 80-column display device.  This format separates the</p>
<p>                     default output into two groups: virtual memory</p>
<p>                     information and CPU data.  Each group is displayed as a</p>
<p>                     separate line of output.  On multiprocessor systems,</p>
<p>                     this display format also provides CPU utilization on a</p>
<p>                     per CPU basis for the active processors.</p>
<p>【<strong> -n </strong><strong>以80</strong><strong>列显示模式，分两部分显示：vm</strong><strong>信息和每个cpu</strong><strong>数据，如下：</strong></p>
<p>&gt;vmstat -n 3 2                                                                                                                                           </p>
<p><strong>VM</strong></p>
<p>       memory                     page                          faults</p>
<p>     avm    free   re   at    pi   po    fr   de    sr     in     sy    cs </p>
<p> 3178506  994304    0    0     3    0     0    0     0   6294  56247  2062</p>
<p><strong>CPU</strong></p>
<p>    cpu          procs</p>
<p> us sy id    r     b     w</p>
<p>  4  1 95    3     0     0</p>
<p>  4  1 95</p>
<p>  4  2 95</p>
<p>  4  2 95</p>
<p>】</p>
<p>           -S        Report the number of processes swapped in and out (si</p>
<p>                     and so) instead of page reclaims and address</p>
<p>                     translation faults (re and at).</p>
<p>【- <strong>S </strong><strong>报告si/so</strong><strong>信息，而不是re/at</strong><strong>信息</strong></p>
<p>&gt;vmstat -S</p>
<p>         procs           memory                   page                              faults       cpu</p>
<p>    r     b     w      avm    free   si   so    pi   po    fr   de    sr     in     sy    cs  us sy id</p>
<p>1     0     0  3159434  1005232    0    0     3    0     0    0     0   6294  56249  2063   2  1 97</p>
<p>】</p>
<p>           interval  Display successive lines which are summaries over the</p>
<p>                     last interval seconds.  The first line reported is for</p>
<p>                     the time since a reboot and each subsequent line is for</p>
<p>                     the last interval only.  If interval is zero, the</p>
<p>                     output is displayed once only.  If the -d option is</p>
<p>                     specified, the column headers are repeated.  If -d is</p>
<p>                     omitted, the column headers are not repeated.</p>
<p>                     The command vmstat 5 prints what the system is doing</p>
<p>                     every five seconds.  This is a good choice of printing</p>
<p>                     interval since this is how often some of the statistics</p>
<p>                     are sampled in the system; others vary every second.</p>
<p>           count     Repeat the summary statistics count times.  If count is</p>
<p>                     omitted or zero, the output is repeated until an</p>
<p>                     interrupt or quit signal is received.  From the</p>
<p>                     terminal, these are commonly ^C and ^\, respectively</p>
<p>                     (see stty(1)).</p>
<p>           -f        Report on the number of forks and the number of pages</p>
<p>                     of virtual memory involved since boot-up.</p>
<p>【&gt;vmstat -f</p>
<p>68092569 forks, 4170099806676 pages, average=  61241.63 】</p>
<p>           -s        Print the total number of several kinds of paging-</p>
<p>                     related events from the kernel sum structure that have</p>
<p>                     occurred since boot-up or since vmstat was last</p>
<p>                     executed with the -z option.</p>
<p>【&gt;vmstat <strong>–s </strong><strong>自系统启动以来的累积paging</strong><strong>信息，-z</strong><strong>是自上次vmstat</strong><strong>执行以来的累积信息</strong></p>
<p>0 swap ins</p>
<p>0 swap outs</p>
<p>0 pages swapped in</p>
<p>0 pages swapped out</p>
<p>6274277458 total address trans. faults taken</p>
<p>1829303083 page ins</p>
<p>334 page outs</p>
<p>29737060 pages paged in</p>
<p>231 pages paged out</p>
<p>4607410940 reclaims from free list</p>
<p>0 total page reclaims</p>
<p>98789 intransit blocking page faults</p>
<p>2838038078424 zero fill pages created</p>
<p>9126773909 zero fill page faults</p>
<p>82503219875 executable fill pages created</p>
<p>15320876 executable fill page faults</p>
<p>0 swap text pages found in free list</p>
<p>0 inode text pages found in free list</p>
<p>167 revolutions of the clock hand</p>
<p>4347065 pages scanned for page out</p>
<p>2708823 pages freed by the clock daemon</p>
<p>17034954764 cpu context switches</p>
<p>53631522710 device interrupts</p>
<p>8334721720 traps</p>
<p>464471608504 system calls</p>
<p>654638208 Page Select Size Successes for Page size 4K</p>
<p>722151587 Page Select Size Successes for Page size 8K</p>
<p>1500141225 Page Select Size Successes for Page size 16K</p>
<p>292213775 Page Select Size Successes for Page size 64K</p>
<p>8210386 Page Select Size Successes for Page size 256K</p>
<p>5504193 Page Select Size Successes for Page size 1M</p>
<p>1168360 Page Select Size Successes for Page size 4M</p>
<p>761 Page Select Size Successes for Page size 16M</p>
<p>135 Page Select Size Successes for Page size 64M</p>
<p>1056 Page Select Size Successes for Page size 128M</p>
<p>654638208 Page Select Size Failures for Page size 8K</p>
<p>1215788126 Page Select Size Failures for Page size 16K</p>
<p>119694774 Page Select Size Failures for Page size 64K</p>
<p>19010270 Page Select Size Failures for Page size 256K</p>
<p>6761292 Page Select Size Failures for Page size 1M</p>
<p>5947041 Page Select Size Failures for Page size 4M</p>
<p>2984011 Page Select Size Failures for Page size 16M</p>
<p>2966867 Page Select Size Failures for Page size 64M</p>
<p>5934286 Page Select Size Failures for Page size 128M</p>
<p>1666451549 Page Allocate Successes for Page size 4K</p>
<p>626532779 Page Allocate Successes for Page size 8K</p>
<p>1352517747 Page Allocate Successes for Page size 16K</p>
<p>867564268 Page Allocate Successes for Page size 64K</p>
<p>8130004 Page Allocate Successes for Page size 256K</p>
<p>6106471 Page Allocate Successes for Page size 1M</p>
<p>2027256 Page Allocate Successes for Page size 4M</p>
<p>594 Page Allocate Successes for Page size 16M</p>
<p>1484 Page Allocate Successes for Page size 64M</p>
<p>480 Page Allocate Successes for Page size 128M</p>
<p>2761002041 Page Allocate Failures for Page size 4K</p>
<p>2264697395 Page Allocate Failures for Page size 8K</p>
<p>6114689303 Page Allocate Failures for Page size 16K</p>
<p>2149876393 Page Allocate Failures for Page size 64K</p>
<p>64214019 Page Allocate Failures for Page size 256K</p>
<p>86494940 Page Allocate Failures for Page size 1M</p>
<p>34049285 Page Allocate Failures for Page size 4M</p>
<p>354294 Page Allocate Failures for Page size 16M</p>
<p>6991 Page Allocate Failures for Page size 64M</p>
<p>78130 Page Allocate Failures for Page size 128M</p>
<p>10885603 Page Demotions for Page size 8K</p>
<p>3901281 Page Demotions for Page size 16K</p>
<p>599439 Page Demotions for Page size 64K</p>
<p>3739984 Page Demotions for Page size 256K</p>
<p>324867 Page Demotions for Page size 1M</p>
<p>1465 Page Demotions for Page size 4M</p>
<p>6 Page Demotions for Page size 16M</p>
<p>1 Page Demotions for Page size 64M</p>
<p>】</p>
<p>           -z        Clear all accumulators in the kernel sum structure.</p>
<p>                     This option is restricted to the super user.</p>
<p>      If none of these options is given, vmstat displays a one-line summary</p>
<p>      of the virtual memory activity since boot-up or since the -z option</p>
<p>      was last executed.</p>
<p>【<strong>只显示一行汇总信息</strong>】</p>
<p>    Column Descriptions</p>
<p>      The column headings and the meaning of each column are:</p>
<p>           procs       Information about numbers of processes in various</p>
<p>                       states.</p>
<p>                            r      In run queue  （在运行队列中）</p>
<p>                            b      Blocked for resources (I/O, paging, etc.) （<strong>因资源阻塞中，如等待</strong><strong>io</strong><strong>或者paging</strong><strong>等）</strong></p>
<p>                            w      Runnable or short sleeper (&lt; 20 secs) but</p>
<p>                                   swapped <strong>（可运行的或者sleep</strong><strong>小于20</strong><strong>秒的，但是被swap</strong><strong>的）</strong></p>
<p>           memory      Information about the usage of virtual and real</p>
<p>                       memory.  Virtual pages are considered active if they</p>
<p>                       belong to processes that are running or have run in</p>
<p>                       the last 20 seconds.</p>
<p>（包括虚拟内存和真实内存的使用情况，虚拟page考虑运行中的进程或者在最后20秒内运行的进程使用情况）</p>
<p>                            avm     Active virtual pages <strong>（活动的虚拟内存页）</strong></p>
<p>                            free    Size of the free list <strong>（free list</strong><strong>的size</strong><strong>）</strong></p>
<p>           page        Information about page faults and paging activity.</p>
<p>                       These are averaged each five seconds, and given in</p>
<p>                       units per second. <strong>（五秒内的平均值，每秒给出）</strong></p>
<p>                            re      Page reclaims (without -S)</p>
<p>                            at      Address translation faults (without -S)</p>
<p>                            si      <strong>Processes</strong> swapped in (with -S)  <strong>（swap-in</strong><strong>的进程数）</strong></p>
<p>                            so      Processes swapped out (with -S) <strong>（swap-out</strong><strong>的进程数）</strong></p>
<p>                            pi      Pages paged in   <strong>（换入的页数）</strong></p>
<p>                            po      Pages paged out  <strong>（换出的页数）</strong></p>
<p>                            fr      Pages freed per second <strong>（每秒释放的页数）</strong></p>
<p>                            de      Anticipated short term memory shortfall  （预期的短期内存差额）</p>
<p>                            sr      Pages scanned by clock algorithm, per <strong>（每秒scan</strong><strong>的页数）</strong></p>
<p>                                    second</p>
<p>           faults      Trap/interrupt rate averages per second over last 5</p>
<p>                       seconds.</p>
<p>                            in      Device interrupts per second (nonclock)</p>
<p>                            sy      System calls per second</p>
<p>                            cs      CPU context switch rate (switches/sec)</p>
<p>           cpu         Breakdown of percentage usage of CPU time for the</p>
<p>                       active processors</p>
<p>                            us      User time for normal and low priority</p>
<p>                                    processes</p>
<p>                            sy      System time</p>
<p>                            id      CPU idle</p>
<p> EXAMPLES</p>
<p>      The following examples show the output for various command options.</p>
<p>      For formatting purposes, some leading blanks have been deleted.</p>
<p>      1.   Display the default output.</p>
<p>      vmstat</p>
<p>                procs           memory                   page</p>
<p>                       faults       cpu</p>
<p>           r     b     w      avm    free   re   at    pi   po    fr   de    sr</p>
<p>                in     sy    cs  us sy id</p>
<p>           0     0     0     1158     511    0    0     0    0     0    0     0</p>
<p>               111     18     7   0  0 100</p>
<p>      2.   Add the disk tranfer information to the default output.</p>
<p>      vmstat -d</p>
<p>                procs           memory                   page</p>
<p>                       faults       cpu</p>
<p>           r     b     w      avm    free   re   at    pi   po    fr   de    sr</p>
<p>                in     sy    cs  us sy id</p>
<p>           0     0     0     1158     511    0    0     0    0     0    0     0</p>
<p>               111     18     7   0  0 100</p>
<p>           Disk Transfers</p>
<p>             device    xfer/sec</p>
<p>             c0t6d0        0</p>
<p>             c0t1d0        0</p>
<p>             c0t3d0        0</p>
<p>             c0t5d0        0</p>
<p>      3.   Display the default output in 80-column format.</p>
<p>      vmstat -n</p>
<p>           VM</p>
<p>               memory                     page                          faults</p>
<p>             avm    free   re   at    pi   po    fr   de    sr     in     sy    cs</p>
<p>            1158     430    0    0     0    0     0    0     0    111     18     7</p>
<p>           CPU</p>
<p>               cpu          procs</p>
<p>            us sy id    r     b     w</p>
<p>             0  0 100    0     0     0</p>
<p>      4.   Replace the page reclaims and address translation faults with</p>
<p>           process swapping in the default output.</p>
<p>      vmstat -S</p>
<p>                procs           memory                   page</p>
<p>                       faults       cpu</p>
<p>           r     b     w      avm    free   si   so    pi   po    fr   de    sr</p>
<p>                in     sy    cs  us sy id</p>
<p>           0     0     0     1158     430    0    0     0    0     0    0     0</p>
<p>               111     18     7   0  0 100</p>
<p>      5.   Display the default output twice at five-second intervals.  Note</p>
<p>           that the headers are not repeated.</p>
<p>      vmstat 5 2</p>
<p>                procs           memory                   page</p>
<p>                       faults       cpu</p>
<p>           r     b     w      avm    free   re   at    pi   po    fr   de    sr</p>
<p>                in     sy    cs  us sy id</p>
<p>           0     0     0     1158     456    0    0     0    0     0    0     0</p>
<p>               111     18     7   0  0 100</p>
<p>           0     0     0     1221     436    5    0     5    0     0    0     0</p>
<p>               108     65    18   0  1 99</p>
<p>      6.   Display the default output twice in 80-column format at five-</p>
<p>           second intervals.  Note that the headers are not repeated.</p>
<p>      vmstat -n 5 2</p>
<p>           VM</p>
<p>              memory                     page                          faults</p>
<p>            avm    free   re   at    pi   po    fr   de    sr     in     sy    cs</p>
<p>           1221     436    0    0     0    0     0    0     0    111     18     7</p>
<p>           CPU</p>
<p>               cpu          procs</p>
<p>            us sy id    r     b     w</p>
<p>             0  0 100    0     0     0</p>
<p>           1221     435    2    0     2    0     0    0     0    109     35    17</p>
<p>             0  1 99    0     0     0</p>
<p>      7.   Display the default output and disk transfers twice in 80-column</p>
<p>           format at five-second intervals.  Note that the headers are</p>
<p>           repeated.</p>
<p>      vmstat -dn 5 2</p>
<p>           VM</p>
<p>              memory                     page                          faults</p>
<p>            avm    free   re   at    pi   po    fr   de    sr     in     sy    cs</p>
<p>           1221     435    0    0     0    0     0    0     0    111     18     7</p>
<p>           CPU</p>
<p>               cpu          procs</p>
<p>            us sy id    r     b     w</p>
<p>             0  0 100    0     0     0</p>
<p>           Disk Transfers</p>
<p>             device    xfer/sec</p>
<p>             c0t6d0        0</p>
<p>             c0t1d0        0</p>
<p>             c0t3d0        0</p>
<p>             c0t5d0        0</p>
<p>           VM</p>
<p>              memory                     page                          faults</p>
<p>            avm    free   re   at    pi   po    fr   de    sr     in     sy    cs</p>
<p>           1219     425    0    0     0    0     0    0     0    111     54    15</p>
<p>           CPU</p>
<p>               cpu          procs</p>
<p>            us sy id    r     b     w</p>
<p>             1  8 92    0     0     0</p>
<p>           Disk Transfers</p>
<p>             device    xfer/sec</p>
<p>             c0t6d0        0</p>
<p>             c0t1d0        0</p>
<p>             c0t3d0        0</p>
<p>             c0t5d0        0</p>
<p>      8.   Display the number of forks and pages of virtual memory since</p>
<p>           boot-up.</p>
<p>      vmstat -f</p>
<p>           24558 forks, 1471595 pages, average=  59.92</p>
<p>      9.   Display the counts of paging-related events.</p>
<p>      vmstat -s</p>
<p>           0 swap ins</p>
<p>           0 swap outs</p>
<p>           0 pages swapped in</p>
<p>           0 pages swapped out</p>
<p>           1344563 total address trans. faults taken</p>
<p>           542093 page ins</p>
<p>           2185 page outs</p>
<p>           602573 pages paged in</p>
<p>           4346 pages paged out</p>
<p>           482343 reclaims from free list</p>
<p>           504621 total page reclaims</p>
<p>           124 intransit blocking page faults</p>
<p>           1460755 zero fill pages created</p>
<p>           404137 zero fill page faults</p>
<p>           366022 executable fill pages created</p>
<p>           71578 executable fill page faults</p>
<p>           0 swap text pages found in free list</p>
<p>           162043 inode text pages found in free list</p>
<p>           196 revolutions of the clock hand</p>
<p>           45732 pages scanned for page out</p>
<p>           4859 pages freed by the clock daemon</p>
<p>           36680636 cpu context switches</p>
<p>           1497746186 device interrupts</p>
<p>           1835626 traps</p>
<p>           87434493 system calls</p>
<p> WARNINGS</p>
<p>      Users of vmstat must not rely on the exact field widths and spacing of</p>
<p>      its output, as these will vary depending on the system, the release of</p>
<p>      HP-UX, and the data to be displayed.</p>
<p> AUTHOR</p>
<p>      vmstat was developed by the University of California, Berkeley and HP.</p>
<p> SEE ALSO</p>
<p>      iostat(1).</p>
<p> Hewlett-Packard Company            &#8211; 6 -       HP-UX 11i Version 3 Feb 2007</p>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2010/06/man-vmstat-on-hp-ux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>man vmstat on AIX</title>
		<link>http://www.orablogger.com/2010/06/man-vmstat-on-aix/</link>
		<comments>http://www.orablogger.com/2010/06/man-vmstat-on-aix/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 14:16:41 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[ibm aix]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[vmstat]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=457</guid>
		<description><![CDATA[vmstat Command Purpose        Reports virtual memory statistics.   Syntax        vmstat [ -f ] [ -i ] [ -s  ] [ -I ] [ -t ] [ -v ] [ -w] [ -l ] [ PhysicalVolume ... ] [ Interval [ Count        ] ] Description        The vmstat command reports statistics about kernel [...]]]></description>
			<content:encoded><![CDATA[<h5>vmstat Command</h5>
<h5>Purpose</h5>
<h5>       Reports virtual memory statistics.</h5>
<p><span id="more-457"></span></p>
<h5> </h5>
<h5>Syntax</h5>
<h5>       vmstat [ -f ] [ -i ] [ -s  ] [ -I ] [ -t ] [ -v ] [ -w] [ -l ] [ PhysicalVolume ... ] [ Interval [ Count</h5>
<h5>       ] ]</h5>
<h5>Description</h5>
<h5>       The vmstat command reports statistics about kernel threads, virtual memory, disks, traps and CPU</h5>
<h5>       activity. Reports generated by the vmstat command can be used to balance system load activity. These</h5>
<h5>       system-wide statistics (among all processors) are calculated as averages for values expressed as</h5>
<h5>       percentages, and as sums otherwise.</h5>
<p>       If the vmstat command is invoked without flags, the report contains a summary of the virtual memory</p>
<h5>       activity since system startup. If the -f flag is specified, the vmstat command reports the number of</h5>
<h5>       forks since system startup. The PhysicalVolume parameter specifies the name of the physical volume.</h5>
<h5>       The Interval parameter specifies the amount of time in seconds between each report. If the Interval</h5>
<h5>       parameter is not specified, the vmstat command generates a single report that contains statistics for</h5>
<h5>       the time since system startup and then exits. The Count parameter can only be specified with the</h5>
<h5>       Interval parameter. If the Count parameter is specified, its value determines the number of reports</h5>
<h5>       generated and the number of seconds apart. If the Interval parameter is specified without the Count</h5>
<h5>       parameter, reports are continuously generated. A Count parameter of 0 is not allowed.</h5>
<h5>       AIX 4.3.3 and later contain enhancements to the method used to compute the percentage of CPU time spent</h5>
<h5>       waiting on disk I/O (wio time). The method used in AIX 4.3.2 and earlier versions of the operating</h5>
<h5>       system can, under certain circumstances, give an inflated view of wio time on SMPs.</h5>
<h5>       The method used in AIX 4.3.2 and earlier versions is as follows: At each clock interrupt on each</h5>
<h5>       processor (100 times a second per processor), a determination is made as to which of the four categories</h5>
<h5>       (usr/sys/wio/idle) to place the last 10 ms of time. If the CPU was busy in usr mode at the time of the</h5>
<h5>       clock interrupt, then usr gets the clock tick added into its category. If the CPU was busy in kernel</h5>
<h5>       mode at the time of the clock interrupt, then the sys category gets the tick. If the CPU was not busy, a</h5>
<h5>       check is made to see if any I/O to disk is in progress. If any disk I/O is in progress, the wio category</h5>
<h5>       is incremented. If no disk I/O is in progress and the CPU is not busy, the idle category gets the tick.</h5>
<h5>       The inflated view of wio time results from all idle CPUs being categorized as wio regardless of the</h5>
<h5>       number of threads waiting on I/O. For example, systems with just one thread doing I/O could report over</h5>
<h5>       90 percent wio time regardless of the number of CPUs it has. The wio time is reported by the commands</h5>
<h5>       sar (%wio), vmstat (wa) and iostat (% iowait).</h5>
<h5>       The method used in operating system AIX 4.3.3 and later is as follows: The change in operating system</h5>
<h5>       AIX 4.3.3 is to only mark an idle CPU as wio if an outstanding I/O was started on that CPU. This method</h5>
<h5>       can report much lower wio times when just a few threads are doing I/O and the system is otherwise idle.</h5>
<h5>       For example, a system with four CPUs and one thread doing I/O will report a maximum of 25 percent wio</h5>
<h5>       time. A system with 12 CPUs and one thread doing I/O will report a maximum of 8 percent wio time. NFS</h5>
<h5>       client reads/writes go through the VMM, and the time that biods spend in the VMM waiting for an I/O to</h5>
<h5>       complete is now reported as I/O wait time.</h5>
<h5>       The kernel maintains statistics for kernel threads, paging, and interrupt activity, which the vmstat</h5>
<h5>       command accesses through the use of the the perfstat kernel extension. The disk input/output statistics</h5>
<h5>       are maintained by device drivers. For disks, the average transfer rate is determined by using the active</h5>
<h5>       time and number of transfers information. The percent active time is computed from the amount of time</h5>
<h5>       the drive is busy during the report.</h5>
<h5>       Beginning with AIX 5.3, the vmstat command reports the number of physical processors consumed (pc), and</h5>
<h5>       the percentage of entitlement consumed (ec), in Micro-Partitioning environments. These metrics will only</h5>
<h5>       be displayed on Micro-Partitioning environments.</h5>
<h5>       Reports generated by the vmstat command contains the following column headings and their description:</h5>
<h5>       <strong>kthr: information about kernel thread states. (</strong><strong>内核线程状态)</strong></h5>
<h5>      <strong> r</strong></h5>
<h5>            Average number of runnable kernel threads over the sampling interval. <strong>Runnable refers to threads</strong></h5>
<h5><strong>            that are ready but waiting to run and to those threads already running.</strong><strong>（可运行的：准备好运行的和已经在运行的。）</strong></h5>
<h5>     <strong>  b</strong></h5>
<h5>            Average number of kernel threads placed in the VMM wait queue (awaiting resource, awaiting</h5>
<h5>            input/output) over the sampling interval.  <strong>（在vmm</strong><strong>等待队列中的）</strong></h5>
<h5>       Memory: information about the usage of virtual and real memory. Virtual pages are considered active if</h5>
<h5>       they have been accessed. A page is 4096 bytes.</h5>
<h5>       avm</h5>
<h5>            Active virtual pages. <strong>（活动的虚拟页数）</strong></h5>
<h5>       fre</h5>
<h5>            Size of the free list. Note: A large portion of real memory is utilized as a cache for file system</h5>
<h5>            data. It is not unusual for the size of the free list to remain small. <strong>（free list</strong><strong>的size</strong><strong>，由于文件系统的cache</strong><strong>使用，通常会使free list</strong><strong>保持较小的数值）</strong></h5>
<h5>       Page: information about page faults and paging activity. These are averaged over the interval and given</h5>
<h5>       in units per second.</h5>
<h5>       re</h5>
<h5>            Pager input/output list.</h5>
<h5>       pi</h5>
<h5>            Pages paged in from paging space.</h5>
<h5>       po</h5>
<h5>            Pages paged out to paging space.</h5>
<h5>       fr</h5>
<h5>            Pages freed (page replacement).</h5>
<h5>       sr</h5>
<h5>            Pages scanned by page-replacement algorithm.</h5>
<h5>       cy</h5>
<h5>            Clock cycles by page-replacement algorithm.</h5>
<h5>       Faults: trap and interrupt rate averages per second over the sampling interval.</h5>
<h5>       in</h5>
<h5>            Device interrupts.</h5>
<h5>       sy</h5>
<h5>            System calls.</h5>
<h5>       cs</h5>
<h5>            Kernel thread context switches.</h5>
<h5>       Cpu: breakdown of percentage usage of CPU time.</h5>
<h5>       us</h5>
<h5>            User time.</h5>
<h5>       sy</h5>
<h5>            System time.</h5>
<h5>       id</h5>
<h5>            CPU idle time.</h5>
<h5>       wa</h5>
<h5>            CPU idle time during which the system had outstanding disk/NFS I/O request(s). See detailed</h5>
<h5>            description above.</h5>
<h5>       <strong>pc</strong></h5>
<h5><strong> </strong></h5>
<h5><strong>            Number of physical processors consumed. Displayed only if the partition is running with shared</strong></h5>
<h5><strong>            processor.</strong></h5>
<h5>       ec</h5>
<h5>            The percentage of entitled capacity consumed. Displayed only if the partition is running with</h5>
<h5>            shared processor.</h5>
<h5>       Disk: Provides the number of transfers per second to the specified physical volumes that occurred in the</h5>
<h5>       sample interval. The PhysicalVolume parameter can be used to specify one to four names. Transfer</h5>
<h5>       statistics are given for each specified drive in the order specified. This count represents requests to</h5>
<h5>       the physical device. It does not imply an amount of data that was read or written. Several logical</h5>
<h5>       requests can be combined into one physical request. If the PhysicalVolume parameter is used, the</h5>
<h5>       physical volume names are printed at the beginning of command execution.</h5>
<h5>       If the -I flag is specified, an I/O oriented view is presented with the following column changes.</h5>
<h5>       <strong>kthr</strong></h5>
<h5>            The column p will also be displayed besides columns r and b.</h5>
<h5>            <strong>  P   </strong><strong>（每秒等待在raw</strong><strong>设备IO</strong><strong>的进程数，当使用 –I</strong><strong>参数时）</strong></h5>
<h5><strong>                   Number of threads waiting on I/O to raw devices per second.</strong></h5>
<h5>       <strong>Page      </strong><strong>（-I</strong><strong>）</strong></h5>
<h5>            New columns fi and fo will be displayed instead of re and cy columns.</h5>
<h5>              <strong>fi</strong></h5>
<h5>                   File page-ins per second.   （<strong>每秒文件的</strong><strong>page-ins</strong><strong>数）</strong></h5>
<h5>              <strong>fo</strong></h5>
<h5>                   File page-outs per second.  <strong>（每秒的文件page_outs</strong><strong>数）</strong></h5>
<h5>       If, while the vmstat command is running, there is a change in system configuration that will affect the</h5>
<h5>       output, <strong>vmstat prints a warning message about the configuration change.</strong> It then continues the output,</h5>
<h5>       after printing the updated system configuration information and the header.</h5>
<h5>       If the <strong>-l </strong>flag is specified, an additional &#8220;l<strong>arge-page</strong>&#8221; section is displayed with the following columns:</h5>
<h5>       alp</h5>
<h5>            Indicates the number of large pages currently in use.  （当前使用的大页数）</h5>
<h5>       flp</h5>
<h5>            Indicates the number of large pages on the large page freelist. （大页freelist上的大页数）</h5>
<h5>Flags</h5>
<h5>       Note: If the -f (or -s) flag is entered on the command line, then the system will only accept the -f (or</h5>
<h5>       -s) flag and will ignore other flags. If both -f and -s flags are specified, the system will accept only</h5>
<h5>       the first flag and ignore the second flag.</h5>
<h5>       -f</h5>
<h5>            Reports the number of forks since system startup.</h5>
<h5>       -i</h5>
<h5>            Displays the number of interrupts taken by each device since system startup.</h5>
<h5>       -I</h5>
<h5>            Displays <strong>I/O oriented view</strong> with the new columns of output, p under heading kthr,and columns fi and</h5>
<h5>            fo under heading page instead of the columns re and cy in the page heading.</h5>
<h5>       -l</h5>
<h5>            Displays an additional &#8220;large-page&#8221; section with the alp and flp columns.</h5>
<h5>       -s</h5>
<h5>            Writes to standard output the contents of the sum structure, which contains an absolute count of</h5>
<h5>            paging events since system initialization. The -s flag can only be used with the -v flag. These</h5>
<h5>            events are described as follows:</h5>
<h5>              address translation faults</h5>
<h5>                   Incremented for each occurrence of an address translation page fault. I/O may or may not be</h5>
<h5>                   required to resolve the page fault. Storage protection page faults (lock misses) are not</h5>
<h5>                   included in this count.</h5>
<h5>              page ins</h5>
<h5>                   Incremented for each page read in by the virtual memory manager. The count is incremented</h5>
<h5>                   for page ins from page space and file space. Along with the page out statistic, this</h5>
<h5>                   represents the total amount of real I/O initiated by the virtual memory manager.</h5>
<h5>              page outs</h5>
<h5>                   Incremented for each page written out by the virtual memory manager. The count is</h5>
<h5>                   incremented for page outs to page space and for page outs to file space. Along with the page</h5>
<h5>                   in statistic, this represents the total amount of real I/O initiated by the virtual memory</h5>
<h5>                   manager.</h5>
<h5>              paging space page ins</h5>
<h5>                   Incremented for VMM initiated page ins from paging space only.</h5>
<h5>              paging space page outs</h5>
<h5>                   Incremented for VMM initiated page outs to paging space only.</h5>
<h5>              total reclaims</h5>
<h5>                   Incremented when an address translation fault can be satisfied without initiating a new I/O</h5>
<h5>                   request. This can occur if the page has been previously requested by VMM, but the I/O has</h5>
<h5>                   not yet completed; or if the page was pre-fetched by VMM&#8217;s read-ahead algorithm, but was</h5>
<h5>                   hidden from the faulting segment; or if the page has been put on the free list and has not</h5>
<h5>                   yet been reused.</h5>
<h5>              zero-filled page faults</h5>
<h5>                   Incremented if the page fault is to working storage and can be satisfied by assigning a</h5>
<h5>                   frame and zero-filling it.</h5>
<h5>              executable-filled page faults</h5>
<h5>                   Incremented for each instruction page fault.</h5>
<h5>              pages examined by the clock</h5>
<h5>                   VMM uses a clock-algorithm to implement a pseudo least recently used (lru) page replacement</h5>
<h5>                   scheme. Pages are aged by being examined by the clock. This count is incremented for each</h5>
<h5>                   page examined by the clock.</h5>
<h5>              revolutions of the clock hand</h5>
<h5>                   Incremented for each VMM clock revolution (that is, after each complete scan of memory).</h5>
<h5>              pages freed by the clock</h5>
<h5>                   Incremented for each page the clock algorithm selects to free from real memory.</h5>
<h5>              backtracks</h5>
<h5>                   Incremented for each page fault that occurs while resolving a previous page fault. (The new</h5>
<h5>                   page fault must be resolved first and then initial page faults can be backtracked.)</h5>
<h5>              free frame waits</h5>
<h5>                   Incremented each time a process is waited by VMM while free frames are gathered.</h5>
<h5>              extend XPT waits</h5>
<h5>                   Incremented each time a process is waited by VMM due to a commit in progress for the segment</h5>
<h5>                   being accessed.</h5>
<h5>              pending I/O waits</h5>
<h5>                   Incremented each time a process is waited by VMM for a page-in I/O to complete.</h5>
<h5>              start I/Os</h5>
<h5>                   Incremented for each read or write I/O request initiated by VMM. This count should equal the</h5>
<h5>                   sum of page-ins and page-outs.</h5>
<h5>              iodones</h5>
<h5>                   Incremented at the completion of each VMM I/O request.</h5>
<h5>              CPU context switches</h5>
<h5>                   Incremented for each CPU context switch (dispatch of a new process).</h5>
<h5>              device interrupts</h5>
<h5>                   Incremented on each hardware interrupt.</h5>
<h5>              software interrupts</h5>
<h5>                   Incremented on each software interrupt. A software interrupt is a machine instruction</h5>
<h5>                   similar to a hardware interrupt that saves some state and branches to a service routine.</h5>
<h5>                   System calls are implemented with software interrupt instructions that branch to the system</h5>
<h5>                   call handler routine.</h5>
<h5>              decrementer interrupts</h5>
<h5>                   Incremented on each decrementer interrupt.</h5>
<h5>              mpc send interrupts</h5>
<h5>                   Incremented on each mpc send interrupt</h5>
<h5>              mpc receive interrupts</h5>
<h5>                   Incremented on each mpc receive interrupt</h5>
<h5>              phantom interrupts</h5>
<h5>                   Incremented on each phantom interrupt</h5>
<h5>              traps</h5>
<h5>                   Not maintained by the operating system.</h5>
<h5>              syscalls</h5>
<h5>                   Incremented for each system call.</h5>
<h5>       -t</h5>
<h5>            Prints the time-stamp next to each line of output of vmstat. The time-stamp is displayed in the</h5>
<h5>            HH:MM:SS format. Note: Time stamp will not be printed if -f, -s, or -i flags are specified.</h5>
<h5>     <strong>  -v</strong></h5>
<h5>            Writes to standard output various statistics maintained by the Virtual Memory Manager. The -v flag</h5>
<h5>            can only be used with the -s flag.</h5>
<h5>              memory pages</h5>
<h5>                   Size of real memory in number <strong>of 4 KB pages.   </strong><strong>（以4KB</strong><strong>页大小的真实内存页数）</strong></h5>
<h5>              lruable pages</h5>
<h5>                   Number of 4 KB pages considered for replacement. This number excludes the pages used for VMM</h5>
<h5>                   internal pages, and the pages used for the pinned part of the kernel text.</h5>
<h5>              free pages</h5>
<h5>                   Number of free 4 KB pages.</h5>
<h5>              memory pools</h5>
<h5>                   Tuning parameter (managed using vmo) specifying the number of memory pools.</h5>
<h5>              pinned pages</h5>
<h5>                   Number of pinned 4 KB pages.</h5>
<h5>              maxpin percentage</h5>
<h5>                   Tuning parameter (managed using vmo) specifying the percentage of real memory which can be</h5>
<h5>                   pinned.</h5>
<h5>              minperm percentage</h5>
<h5>                   Tuning parameter (managed using vmo) in percentage of real memory. This specifies the point</h5>
<h5>                   below which<strong> file pages</strong> are protected from the re-page algorithm.</h5>
<h5>              maxperm percentage</h5>
<h5>                   Tuning parameter (managed using vmo) in percentage of real memory. This specifies the point</h5>
<h5>                   above which the page stealing algorithm steals only file pages.</h5>
<h5>              numperm percentage</h5>
<h5>                   Percentage of memory currently used by the file cache.</h5>
<h5>              file pages</h5>
<h5>                   Number of 4 KB pages currently used by the file cache.</h5>
<h5>              compressed percentage</h5>
<h5>                   Percentage of memory used by compressed pages.</h5>
<h5>              compressed pages</h5>
<h5>                   Number of compressed memory pages.</h5>
<h5>              numclient percentage</h5>
<h5>                   Percentage of memory occupied by client pages.</h5>
<h5>              maxclient percentage</h5>
<h5>                   Tuning parameter (managed using vmo) specifying the maximum percentage of memory which can</h5>
<h5>                   be used for client pages.</h5>
<h5>              client pages</h5>
<h5>                   Number of client pages.</h5>
<h5>              remote pageouts scheduled</h5>
<h5>                   Number of pageouts scheduled for client filesystems.</h5>
<h5>              pending disk I/Os blocked with no pbuf</h5>
<h5>                   Number of pending disk I/O requests blocked because no pbuf was available. Pbufs are pinned</h5>
<h5>                   memory buffers used to hold I/O requests at the logical volume manager layer.</h5>
<h5>              paging space I/Os blocked with no psbuf</h5>
<h5>                   Number of paging space I/O requests blocked because no psbuf was available. Psbufs are</h5>
<h5>                   pinned memory buffers used to hold I/O requests at the virtual memory manager layer.</h5>
<h5>              filesystem I/Os blocked with no fsbuf</h5>
<h5>                   Number of filesystem I/O requests blocked because no fsbuf was available. Fsbuf are pinned</h5>
<h5>                   memory buffers used to hold I/O requests in the filesystem layer.</h5>
<h5>              client filesystem I/Os blocked with no fsbuf</h5>
<h5>                   Number of client filesystem I/O requests blocked because no fsbuf was available. NFS</h5>
<h5>                   (Network File System) and VxFS (Veritas) are client filesystems. Fsbuf are pinned memory</h5>
<h5>                   buffers used to hold I/O requests in the filesystem layer.</h5>
<h5>              external pager filesystem I/Os blocked with no fsbuf</h5>
<h5>                   Number of external pager client filesystem I/O requests blocked because no fsbuf was</h5>
<h5>                   available. JFS2 is an external pager client filesystem. Fsbuf are pinned memory buffers used</h5>
<h5>                   to hold I/O requests in the filesystem layer.</h5>
<h5>【&gt;vmstat -v 5 2</h5>
<h5>              5275647 memory pages</h5>
<h5>              4998806 lruable pages</h5>
<h5>              1667066 free pages</h5>
<h5>                    6 memory pools</h5>
<h5>               611164 pinned pages</h5>
<h5>                 80.0 maxpin percentage</h5>
<h5>                 10.0 minperm percentage</h5>
<h5>                 25.0 maxperm percentage</h5>
<h5>                 24.6 numperm percentage</h5>
<h5>              1230706 file pages</h5>
<h5>                  0.0 compressed percentage</h5>
<h5>                    0 compressed pages</h5>
<h5>                 24.8 numclient percentage</h5>
<h5>                 25.0 maxclient percentage</h5>
<h5>              1243884 client pages</h5>
<h5>                    0 remote pageouts scheduled</h5>
<h5>                    0 pending disk I/Os blocked with no pbuf</h5>
<h5>                    0 paging space I/Os blocked with no psbuf</h5>
<h5>                 2740 filesystem I/Os blocked with no fsbuf</h5>
<h5>                    7 client filesystem I/Os blocked with no fsbuf</h5>
<h5>                    0 external pager filesystem I/Os blocked with no fsbuf</h5>
<h5>】</h5>
<h5>       -w</h5>
<h5>            Display the report in wide mode  （宽模式显示）</h5>
<h5>&gt;vmstat -w -I</h5>
<h5>System configuration: lcpu=22 mem=20607MB</h5>
<h5>   kthr            memory                         page                       faults           cpu   </h5>
<h5>&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211;</h5>
<h5>  r   b   p        avm        fre    fi    fo    pi    po    fr     sr    in     sy    cs us sy id wa</h5>
<h5> 1   1   0    2369790    1666981    41    38     0     0    53    255   154   2599   814  2  0 95  3</h5>
<h5>Examples</h5>
<h5>       1    To display a summary of the statistics since boot, type:</h5>
<h5>            vmstat</h5>
<h5>       2    To display five summaries at 2-second intervals, type:</h5>
<h5>            vmstat 2 5</h5>
<h5>            The first summary contains statistics for the time since boot.</h5>
<h5>       3    To display a summary of the statistics since boot including statistics for <strong>logical</strong> disks scdisk13</h5>
<h5>            and scdisk14, type:</h5>
<h5>            vmstat scdisk13 scdisk14</h5>
<h5>       4    To display fork statistics, type:</h5>
<h5>            vmstat  -f</h5>
<h5>       5    To display the count of various events, type:</h5>
<h5>            vmstat -s</h5>
<h5>       6    To display time-stamp next to each column of output of vmstat, type:</h5>
<h5>            vmstat -t</h5>
<h5>       7    To display the I/O oriented view with an alternative set of columns, type:</h5>
<h5>            vmstat -I</h5>
<h5>       8    To display all the VMM statistics available, type:</h5>
<h5>            vmstat -vs</h5>
<h5>       9    To display the large-page section with the alp and flp columns at 8-second intervals, type:</h5>
<h5>            vmstat -l 8</h5>
<h5>Files</h5>
<h5>       /usr/bin/vmstat</h5>
<h5>            Contains the vmstat command.</h5>
<h5>Related Information</h5>
<h5>       The iostat and vmo command.</h5>
<h5>       Monitoring and Tuning Memory Use in AIX 5L Version 5.3 Performance Management Guide.</h5>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2010/06/man-vmstat-on-aix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>远程图形界面工具&#8211;全面替代VNC和XMANAGER</title>
		<link>http://www.orablogger.com/2010/05/nomachine/</link>
		<comments>http://www.orablogger.com/2010/05/nomachine/#comments</comments>
		<pubDate>Mon, 17 May 2010 12:38:21 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[远程]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=454</guid>
		<description><![CDATA[一个替代VNC的好工具NOMACHINE,它的官方网址是：http://www.nomachine.com/ 这里面有各种操作系统的安装包,有server端的也有client端的。 server端我们一般用linux版本的,主要下3个文件 nxserver-3.4.0-12.i386.rpm nxnode-3.4.0-11.i386.rpm nxclient-3.4.0-7.i386.rpm 安装如下: &#160; 后面的安装结束介绍就不贴了。安装完了服务就启动了。啥也不用配~~ 在win端安装客户端，运行并进行配置：     取个名字，并输入IP地址     选择系统，我们用的是LINUX 就选UNIX，图形界面按实际情况来，KDE就选KDE，GONE就下拉选GONE     配置完了就能按下面界面登陆啦~~    ]]></description>
			<content:encoded><![CDATA[<div>
<div>
<div>一个替代VNC的好工具NOMACHINE,它的官方网址是：<a href="http://www.nomachine.com/" target="_blank">http://www.nomachine.com/</a></div>
</div>
<div>这里面有各种操作系统的安装包,有server端的也有client端的。</div>
<p><span id="more-454"></span></p>
<div>server端我们一般用linux版本的,主要下3个文件</div>
<div>nxserver-3.4.0-12.i386.rpm</div>
<div>nxnode-3.4.0-11.i386.rpm</div>
<div>nxclient-3.4.0-7.i386.rpm</div>
<div>安装如下:</div>
<p>&nbsp;</p>
<div>后面的安装结束介绍就不贴了。安装完了服务就启动了。啥也不用配~~</div>
<div>在win端安装客户端，运行并进行配置：</div>
<div> </div>
<div> </div>
<div>取个名字，并输入IP地址</div>
<div> </div>
<div> </div>
<div>选择系统，我们用的是LINUX 就选UNIX，图形界面按实际情况来，KDE就选KDE，GONE就下拉选GONE</div>
<div> </div>
<div> </div>
<div>配置完了就能按下面界面登陆啦~~</div>
<div> </div>
<div> </div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2010/05/nomachine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>F5与Oracle联袂推出优化解决方案</title>
		<link>http://www.orablogger.com/2010/04/f5-oracle-solution/</link>
		<comments>http://www.orablogger.com/2010/04/f5-oracle-solution/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 01:52:48 +0000</pubDate>
		<dc:creator>happydba</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[f5]]></category>
		<category><![CDATA[gridcontrol]]></category>

		<guid isPermaLink="false">http://www.orablogger.com/?p=452</guid>
		<description><![CDATA[2010年3月2日，全球领先的应用交付网络厂商及Oracle金牌认证合作伙伴宣布推出一款与Oracle合作开发的解决方案。 该方案集成了Oracle企业管理器，对F5® BIG-IP®应用交付控制器的使用进行了优化。 F5和Oracle共同为BIG-IP开发了Oracle ®企业管理器插件。 该插件在F5 DevCentral及Oracle技术网提供给用户下载。 此外，用户可在Oracle网站获得《Oracle最高可用性架构白皮书》，在F5网站获得《F5 部署指南》。　　 2010年3月2日，全球领先的应用交付网络厂商及Oracle金牌认证合作伙伴宣布推出一款与Oracle合作开发的解决方案。 该方案集成了Oracle企业管理器，对F5® BIG-IP®应用交付控制器的使用进行了优化。 F5和Oracle共同为BIG-IP开发了Oracle ®企业管理器插件。该插件在F5 DevCentral及Oracle技术网提供给用户下载。 此外，用户可在Oracle网站获得《Oracle最高可用性架构白皮书》，在F5网站获得《F5 部署指南》。 　　 Oracle公司业务发展部高级总监Will Scelzo表示：“支持F5 BIG-IP的Oracle企业管理器插件是Oracle合作伙伴对Oracle企业管理器进行扩展的良好范例。 借助这个插件，我们共同的用户可以通过在一个中心位置管理其全部环境来提高应用的可用性。 我们与F5的长期合作不仅丰富了Oracle企业管理器，还将继续为双方共同的用户带来切实利益。” 　　 Oracle企业管理器为用户部署Oracle应用提供一个全面统一的监测和管理控制平台。 这款联合开发的解决方案为用户通过F5 BIG-IP解决方案部署Oracle企业管理器，以获得高可用性、性能和安全性提供了详细、规范的指南。 通过支持直接由Oracle企业管理器监控F5 BIG-IP解决方案，该插件将Oracle软件(如数据库、中间件、应用等)和F5应用交付网络都纳入其管理范围内，扩展了管理Oracle部署的能力。 　　 该联合管理解决方案为客户提供以下功能： 　　 通过集中监控功能降低总拥有成本–该插件为Oracle系统和BIG-IP解决方案管理员提供整个企业的统一视图，使他们能够从一个中心位置监控和管理所有组成部分。该集成解决方案使用户无需人工编译来自几种不同工具的重要信息，并更容易识别基础架构的可用性和性能问题，从而能够降低总拥有成本。 　　通过自动追踪配置更改节省时间 &#8211; 追踪配置是管理员日常工作中最费时耗力的任务之一。能够快速查看详细的配置快照，分析历史变化并实施系统之间的标准化是执行诊断、审计和合规任务，做出明智的业务决策的关键。 　　 通过预设阈值警报简化操作 &#8211; 该插件能够自动收集一套完整的预定义阈值的可用性和性能指标，并即时提醒管理员潜在的问题。这使得管理员能够根据具体业务需求灵活调整阈值，实现其工作价值。 　　 通过便捷的即时可用的报告提升管理可视性 – 该插件提供八份即时可用的报告，以进一步帮助管理员处理问题诊断、趋势分析和容量规划等关键任务。这些报告总结了有关 BIG-IP 本地流量管理器™可用性、性能和配置的关键信息，管理员可以从 Oracle ® 企业管理器网格控件控制台轻松获取、计划、共享并定制报告。 　　 F5公司应用合作伙伴计划副总裁Calvin Rowland表示：“我们很高兴与Oracle公司合作开发这一款颇具价值的解决方案，帮助用户管理、整合和优化Oracle企业管理器和BIG-IP系统的部署。以前，用户只能使用不同的工具管理Oracle应用和BIG &#8211; IP系统。我们的新产品为用户提供Oracle软件的整体可视性和F5应用交付基础架构以提高运营效率并简化管理。” 　　 [...]]]></description>
			<content:encoded><![CDATA[<h5>2010年3月2日，全球领先的应用交付网络厂商及Oracle金牌认证合作伙伴宣布推出一款与Oracle合作开发的解决方案。</h5>
<h5>该方案集成了Oracle企业管理器，对F5® BIG-IP®应用交付控制器的使用进行了优化。<br />
F5和Oracle共同为BIG-IP开发了Oracle ®企业管理器插件。<br />
<span id="more-452"></span><br />
该插件在F5 DevCentral及Oracle技术网提供给用户下载。<br />
此外，用户可在Oracle网站获得《Oracle最高可用性架构白皮书》，在F5网站获得《F5 部署指南》。　　</h5>
<h5>2010年3月2日，全球领先的应用交付网络厂商及Oracle金牌认证合作伙伴宣布推出一款与Oracle合作开发的解决方案。<br />
该方案集成了Oracle企业管理器，对F5® BIG-IP®应用交付控制器的使用进行了优化。<br />
F5和Oracle共同为BIG-IP开发了Oracle ®企业管理器插件。该插件在F5 DevCentral及Oracle技术网提供给用户下载。<br />
此外，用户可在Oracle网站获得《Oracle最高可用性架构白皮书》，在F5网站获得《F5 部署指南》。 　　</h5>
<h5>Oracle公司业务发展部高级总监Will Scelzo表示：“支持F5 BIG-IP的Oracle企业管理器插件是Oracle合作伙伴对Oracle企业管理器进行扩展的良好范例。<br />
借助这个插件，我们共同的用户可以通过在一个中心位置管理其全部环境来提高应用的可用性。<br />
我们与F5的长期合作不仅丰富了Oracle企业管理器，还将继续为双方共同的用户带来切实利益。” 　　<br />
Oracle企业管理器为用户部署Oracle应用提供一个全面统一的监测和管理控制平台。<br />
这款联合开发的解决方案为用户通过F5 BIG-IP解决方案部署Oracle企业管理器，以获得高可用性、性能和安全性提供了详细、规范的指南。<br />
通过支持直接由Oracle企业管理器监控F5 BIG-IP解决方案，该插件将Oracle软件(如数据库、中间件、应用等)和F5应用交付网络都纳入其管理范围内，扩展了管理Oracle部署的能力。 　　</h5>
<h5>该联合管理解决方案为客户提供以下功能： 　　</h5>
<h5>通过集中监控功能降低总拥有成本–该插件为Oracle系统和BIG-IP解决方案管理员提供整个企业的统一视图，使他们能够从一个中心位置监控和管理所有组成部分。该集成解决方案使用户无需人工编译来自几种不同工具的重要信息，并更容易识别基础架构的可用性和性能问题，从而能够降低总拥有成本。 　　通过自动追踪配置更改节省时间 &#8211; 追踪配置是管理员日常工作中最费时耗力的任务之一。能够快速查看详细的配置快照，分析历史变化并实施系统之间的标准化是执行诊断、审计和合规任务，做出明智的业务决策的关键。 　　</h5>
<h5>通过预设阈值警报简化操作 &#8211; 该插件能够自动收集一套完整的预定义阈值的可用性和性能指标，并即时提醒管理员潜在的问题。这使得管理员能够根据具体业务需求灵活调整阈值，实现其工作价值。 　　</h5>
<h5>通过便捷的即时可用的报告提升管理可视性 – 该插件提供八份即时可用的报告，以进一步帮助管理员处理问题诊断、趋势分析和容量规划等关键任务。这些报告总结了有关 BIG-IP 本地流量管理器™可用性、性能和配置的关键信息，管理员可以从 Oracle ® 企业管理器网格控件控制台轻松获取、计划、共享并定制报告。 　　</h5>
<h5>F5公司应用合作伙伴计划副总裁Calvin Rowland表示：“我们很高兴与Oracle公司合作开发这一款颇具价值的解决方案，帮助用户管理、整合和优化Oracle企业管理器和BIG-IP系统的部署。以前，用户只能使用不同的工具管理Oracle应用和BIG &#8211; IP系统。我们的新产品为用户提供Oracle软件的整体可视性和F5应用交付基础架构以提高运营效率并简化管理。” 　　</h5>
<h5>企业战略集团首席分析师Jon Oltsik表示：“F5和Oracle之间的合作表明当今业务应用和网络之间的紧密整合。此次合作将使IT组织能够更好地应对变化管理、问题隔离和应用性能等问题，最终能提高企业的生产力和IT效率。”</h5>
]]></content:encoded>
			<wfw:commentRss>http://www.orablogger.com/2010/04/f5-oracle-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.807 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-23 05:22:24 -->

