Additional Considerations for Direct-Path INSERT & NOtes added on

September 22nd, 2011 No comments

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 existing table, you have the choice of creating the new table and then inserting into it, or executing a CREATE TABLE … 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 … AS SELECT statement, in contrast, does not have any indexes defined on it; you must define them later.

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).

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.

Direct-path INSERT must be used if you want to store the data in compressed form using table compression.

Enabling Direct-Path INSERT

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.

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.

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:

You must have Oracle Enterprise Edition installed.

You must enable parallel DML in your session. To do this, run the following statement:

ALTER SESSION { ENABLE | FORCE } PARALLEL DML;

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.

To disable direct-path INSERT, specify the NOAPPEND hint in each INSERT statement. Doing so overrides parallel DML mode.

How Direct-Path INSERT Works

You can use direct-path INSERT on both partitioned and non-partitioned tables.

Serial Direct-Path INSERT into Partitioned or Non-partitioned Tables
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.

Parallel Direct-Path INSERT into Partitioned Tables
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.

Parallel Direct-Path INSERT into Non-partitioned Tables
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.

Specifying the Logging Mode for Direct-Path INSERT

Direct-path INSERT lets you choose whether to log redo and undo information during the insert operation.

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).

If you do not specify either LOGGING or NOLOGGING at these times:

The logging attribute of a partition defaults to the logging attribute of its table.

The logging attribute of a table or index defaults to the logging attribute of the tablespace in which it resides.

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.

You set the logging attribute of a tablespace in a CREATE TABLESPACE or ALTER TABLESPACE statements.

Note:
If the database or tablespace is in FORCE LOGGING mode, then direct path INSERT always logs, regardless of the logging setting.
Direct-Path INSERT with Logging
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.

Direct-Path INSERT without Logging
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.

Additional Considerations for Direct-Path INSERT

The following are some additional considerations when using direct-path INSERT.

Index Maintenance with Direct-Path INSERT
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.

Space Considerations with Direct-Path INSERT
Direct-path INSERT requires more space than conventional-path INSERT.

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.

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:

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.

The size of each extent is not so large that the parallel INSERT results in wasted space on segments that are larger than necessary.

After the direct-path INSERT operation is complete, you can reset these parameters to settings more appropriate for serial operations.

Locking Considerations with Direct-Path INSERT
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.

NOtes Added On
(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.

(2) On 11g Release 2, there is a new hint “APPEND_VALUES”, i.e. use direct path load only when the “APPEND_VALUES” hint is referenced. On 11g Release 2 the “APPEND” 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.

Categories: Internal, oracle Tags: , ,

Linux Tar安装oracle 10g

September 12th, 2011 No comments

链接: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 \r on an \m
root@testserver:[/root]uname -a
Linux testserver 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
以上二个系统版本是一样的。

1、在新服务器上添加用户
groupadd oinstall
useradd -g oinstall oracle

2、在新服务器上添加相关目录
mkdir -p /opt/oracle/product

3、设置核心参数
vi /etc/sysctl.conf,添加

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

使设置生效:
sysctl -p

4、修改oracle用户的环境变量
su – oracle
vi .bash_profile 添加:

# User specific environment and startup programs
PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
export PS1=”` /bin/hostname -s ` -> ”
export EDITOR=vi
export ORACLE_SID=nuage
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_CLIENT=$ORACLE_BASE/product/10.2.0/cleint
export LD_LIBRARY=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.ZHS16GBK”

5、在原服务器打包程序
把$ORACLE_HOME下的东西打包压缩:
cd $ORACLE_BASE/product
tar cfz oracle10203.tar 10.2

6、传送到新服务器并解压
scp 上传

cd $ORACLE_BASE/product
tar -xzfv oracle10203
7、修改解压后的文件属主

[root@testserver oracle]# chown -R oracle:oinstall /opt/
chown: changing ownership of `/opt/oracle/product/10.2/rdbms/filemap’: No such file or directory

这里出现一个错误,提示文件不存在,经检查这是一个软链接:

[root@testserver oracle]# ls -l /opt/oracle/product/10.2/rdbms/filemap
lrwxrwxrwx 1 root root 22 Jan 10 17:22 /opt/oracle/product/10.2/rdbms/filemap -> /opt/ORCLfmap/prot1_64
经检查,当前的系统确实不存在/opt/ORCLfmap目录,实际上/opt/ORCLfmap是有root.sh生成的,先删除这个软链接:
rm -f /opt/oracle/product/10.2/rdbms/filemap

重新执行root.sh:

[root@testserver opt]# /opt/oracle/product/10.2/root.sh
Running Oracle10 root.sh script…

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/10.2

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin …
Copying oraenv to /usr/local/bin …
Copying coraenv to /usr/local/bin …

Creating /etc/oratab file…
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
此时软连接和目录都已经存在:

[root@testserver opt]# ls /opt/oracle/product/10.2/rdbms/filemap
bin etc log
[root@testserver opt]# ls -l /opt/oracle/product/10.2/rdbms/filemap
lrwxrwxrwx 1 root root 22 Jan 10 17:40 /opt/oracle/product/10.2/rdbms/filemap -> /opt/ORCLfmap/prot1_64
8、创建数据库
运行dbca,一步一步设置好就可以。

9、清理原网络相关文件、原密码文件等。

一般会出现的问题:
1、chown: changing ownership of `/opt/oracle/product/10.2/rdbms/filemap’: No such file or directory
这个问题在上文已有描述,这里不再赘述。

2、Exception in thread “main” 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

执行dbca时报错:

testserver ->$ dbca
Exception in thread “main”
testserver ->$
这里报错信息非常少,无法判断是什么原因,再执行netca就可以看得更多的错误信息了:

[oracle@testserver bin]$ netca
Exception in thread “main” 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
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
at sun.awt.DebugHelper.(DebugHelper.java:29)
at java.awt.Component.(Component.java:506)

这个问题主要是缺少一个包xorg-x11-deprecated-libs导致的,把包安装上就可以:
[root@testserver soft]# rpm -ivh xorg-x11-deprecated-libs-6.8.2-1.EL.13.37.i386.rpm
warning: xorg-x11-deprecated-libs-6.8.2-1.EL.13.37.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing… ########################################### [100%]
1:xorg-x11-deprecated-lib########################################### [100%]

注意:虽然系统是64位的,但是这里要安装32位的包。

3、ORA-12547: TNS: 丢失连接
在创建数据库前,简单测试一下sqlplus是否正常,发现了这个问题:

testserver ->$ sqlplus “/as sysdba”

SQL*Plus: Release 10.2.0.3.0 – Production on 星期四 1月 10 17:51:35 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

oraclenewdemo: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
ERROR:
ORA-12547: TNS: 丢失连接

请输入用户名:

引起问题的原因是libaio系统包,把相关包安装即可:

[root@testserver soft]# ls
libaio-0.3.105-2.i386.rpm libaio-0.3.105-2.x86_64.rpm libaio-devel-0.3.105-2.x86_64.rpm
[root@testserver soft]# rpm -ivh *
warning: libaio-0.3.105-2.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing… ########################################### [100%]
1:libaio ########################################### [ 33%]
2:libaio ########################################### [ 67%]
3:libaio-devel ########################################### [100%]

同样,这里也需要安装两个32位的包。

4、ORA-01031: insufficient privileges
testserver ->$ sqlplus “/as sysdba”

SQL*Plus: Release 10.2.0.3.0 – Production on 星期五 1月 11 10:48:35 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

ERROR:
ORA-01031: insufficient privileges

请输入用户名:

这个问题是因为用户组不一致造成的。

原库:

[oracle@kfserver oraInventory]$ id -a
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba) context=user_u:system_r:unconfined_t
新库:

[oracle@testserver oraInventory]$ id -a
uid=500(oracle) gid=500(oinstall) groups=500(oinstall) context=user_u:system_r:unconfined_t
在新库上为oracle用户添加组就可以了:

[root@testserver ~]# usermod -G dba oracle

Categories: 排错 Tags:

PRAGMA EXCEPTION_INIT的用法

September 1st, 2011 No comments
 如果要处理未命名的内部异常,必须使用OTHERS异常处理器或PRAGMA EXCEPTION_INIT 。PRAGMA由编译器控制,或者是对于编译器的注释。PRAGMA在编译时处理,而不是在运行时处理。EXCEPTION_INIT告诉编译器将异常名与ORACLE错误码结合起来,这样可以通过名字引用任意的内部异常,并且可以通过名字为异常编写一适当的异常处理器。
  
  在子程序中使用EXCEPTION_INIT的语法如下:
  PRAGMA EXCEPTION_INIT(exception_name, -Oracle_error_number);
Read more…
Categories: PL/SQL Tags:

ORACLE PL/SQL异常处理(Exception)学习笔记

September 1st, 2011 No comments
1、PL/SQL错误类型
错误类型
报告者
处理方法
编译时错误
PL/SQL编译器
交互式地处理:编译器报告错误,你必须更正这些错误
运行时错误
PL/SQL运行时引擎
程序化地处理:异常由异常处理子程序引发并进行捕获
Read more…
Categories: PL/SQL Tags: , ,

Oracle中的格式化函数

August 16th, 2011 No comments
 

格式化函数提供一套有效的工具用于把各种数据类型(日期/时间,int,float,numeric)转换成格式化的字符串以及反过来从格式化的字符串转换成原始的数据类型。

表 5-6. 格式化函数
Read more…

Categories: Uncategorized Tags:

Oracle10GR2 中的RESTORE POINT

July 2nd, 2010 1 comment

RESTORE POINT

还原点是10GR2新增加的一个功能,它是建立在数据库层面上的, 跟savepoint不同. 必须在数据库处于ARCHIVELOG模式下才可以使用,主题思想是在数据库的某个时间点创建一个restore point,在随后的某个时间点可以将表或数据库falshback 到这个restore point.那么能否真正的完成flashback,依赖于创建的restore point类型和flashback要操作的对象.flashback database需要SYSDBA权限,flashback table需要 FLASHBACK ANY TABLE的权限.
Read more…

Categories: 备份与恢复, oracle Tags:

man vmstat on HP-UX

June 22nd, 2010 No comments

 
      vmstat – report virtual memory statistics

Read more…

Categories: hp-ux Tags: ,

man vmstat on AIX

June 22nd, 2010 No comments
vmstat Command
Purpose
       Reports virtual memory statistics.

Read more…

Categories: ibm aix Tags: ,

远程图形界面工具–全面替代VNC和XMANAGER

May 17th, 2010 1 comment
一个替代VNC的好工具NOMACHINE,它的官方网址是:http://www.nomachine.com/
这里面有各种操作系统的安装包,有server端的也有client端的。

Read more…

Categories: Uncategorized Tags:

F5与Oracle联袂推出优化解决方案

April 11th, 2010 No comments
2010年3月2日,全球领先的应用交付网络厂商及Oracle金牌认证合作伙伴宣布推出一款与Oracle合作开发的解决方案。
该方案集成了Oracle企业管理器,对F5® BIG-IP®应用交付控制器的使用进行了优化。
F5和Oracle共同为BIG-IP开发了Oracle ®企业管理器插件。
Read more…
Categories: Uncategorized Tags: ,

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin