plsql 编程经验---引用
平时在PL/SQL中的编程中遇到一些问题,这里以问答的形式来进行把它们总结下来,以供大家分享。 1、当需要向表中装载大量的数据流或者需要处理大量的数据流的时候,能否使用管道提高处理效率?[@more@] 管道函数对于改善并行查询的性能非常方便,它加快往表中加载数据的速度。管道函数的使用总结如下两点: 每当在查询里使用PL/SQL函数时,该查询将被序列化,即一个处理器只能运行一个查询实例,那么在这种情况下不可能使用并行查询(比如在数据仓库中要经常使用这项技术)。因此,为了使用并行查询就必须使用管道
READ CONSISTENCY IN A TRANSACTION
BEGINSET TRANSACTION READ ONLY ;SET TRANSACTION ISOLATION LEVEL SERIALIZABLE ;END; /[@more@]
苏格拉底--千年的哲学家
做一个不满足的人总比做一头满足的猪好。reference:http://www.doc88.com/p-16016253303.html[@more@]
nid 对RMAN备份的影响--- 控制文件中备份记录全部丢失
NID 操作要求:1, DB是MOUNT状态:d:oradata>nid target=/DBNEWID: Release 10.2.0.1.0 - Production on Tue Jun 29 09:56:31 2010Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to database ZR (DBID=3106537735)NID-00121: Database should not be open2, 操作完后使用RESETLOGS打开DBSQL> startupORACLE instance started.Total System Global Area 603979776 bytesFixed Size 1250380 bytesVariable Size 180358068 bytesDatabase Buffers 415236096 bytesRedo
wallet 使用出错解答
第一种错误:不能建立WALLET现象:15:11:53 SYS> alter system set encryption key authenticated by "topsecrect" ;alter system set encryption key authenticated by "topsecrect"*ERROR at line 1:ORA-28368: cannot auto-create wallet原因:缺少相关路径,默认位置是 $oracle_baseadmin$ora_SIDwallet,可能通过SQLNET.ORA 加入相关参数修改。ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=D:oradatawallet))) 第一种错误:不能打开WALLET现象:15:36:33 SYS> alter system s
configure ssh service in linux :
1, make sure the sshd service is installed on system.service sshd status2, create public/private key pairs:ssh-keygen # answer with default value.3, now private and public key pairs are created as OpenSSH format.if we use other client tool not ssh program (such as secureCRT,PUTTY)We must first have a clear concept about the public key format.In fact, Linux use OpenSSH format ,however Others (windows remote client tools)use SECSH file format. So if we want use other tool connect to Linux SSHD ser
standby database
practise and test following scenario:A table have a trigger, with column c3 are updated or inserted timestamp. the standby database delay apply redo/sql .compare the value of c3 between primary db and physical/logical db.[@more@]standby prerequisite:1, hardware: maby be different.2, OS ,the same classic, can be different release.3, Oracle, same version. Same compatible parameter.
use sed to replace text
# first declaration : the follow signs "()" should be prefixed by back-slash,but the blog doesn't support back-slash render . So here the command you see is just with a little flaw.[root@ibm-baoyuan jok]# sed -n '/MOBILE(.*)/p' emp46012 DULANEY EVAN MOBILE AL46013 DURHAM JEFF MOBILE AL46015 STEEN BILL MOBILE AL46017 FELDMAN EVAN MOBILE AL[root@ibm-baoyuan jok]# sed -n 's/MOBILE(.*)/MOBILE K_999/p' emp46012 DULANEY EVAN MOBILE K_99946013 DURHAM JEFF MOBILE K_99946015 STEEN BILL MOBILE
partition table update partition-key result in changing tablespace
create table pt1 partition by list (deptno)(partition p1 values ('10') tablespace ts_1,partition p2 values ('20') tablespace ts_2,partition p3 values ('30') tablespace ts_3,partition p4 values ('40') tablespace ts_4)as select * from emp ;[@more@]SQL> select * from pt1 partition (p1) ; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO----- ---------- --------- ----- ----------- --------- --------- ------ 7782 CLARK MANAGER 7839 1981-06-09 2450.00
Install oracle 10G in redhat 5.1
ORACLE 优化方案... 1方案宗旨... 1硬件环境:... 1软件环境:... 1磁盘优化... 1安装ORACLE之前的先决条件之软件包... 2操作系统优化... 2数据库优化... 4[@more@]方案宗旨1, 减少硬件故障造成的服务中断给企业造成的损失,实现高可用性服务。2, 充分利用系统硬件资源,使数据库系统运行在最佳状态。硬件环境:x3650 m2 cpu;5520(4核) * 2, disk:300G(10k)*4 memory:8G(ddr3)软件环境:操作系统:RedHat Linux Enterprise 5.1 x86-64数据库系统:Oracle Database 10g Enterprise for Linux x86-64磁盘优化1, 对四个磁盘做RAID10,这个
workaround with install oracle database 10G on redhat ES5
1, cd into the install CD directory ,and locate the oracle install parameter file , such as :database/install/oraparam.ini2, find and change the follwing section , add your os version to the certified version List.original:[Certified Versions]Linux=redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2patched:[Certified Versions]Linux=redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2,redhat-53, run "./runInstaller " again . Good luck![@more@]But the cheat will failure
autoTelnet within Linux
1, auto Telnet in linux assumption:host : localhostuser/passwd : oracle/oraclerun the following command at bash shell environment, you will see an interesting automatic output . So we have the Linux's amazing experience.( sleep 2; echo "oracle" ; sleep 2 ; echo "oracle" ;sleep 2; echo "echo hello I'm oracle person."; sleep 2; echo "ls " ;sleep 2)|telnet localhost2, use xargs , process only ONE parameter each time:As we all knows, xargs could convert the
virtualization tech of x86 platform
first generation , performance is poor second generation : nested paging technologyamd : RVI , Rapid virtualization indexing , from Phenomintel: EPT , Extended Page Table, from Core I7 .[@more@]first generation , performance is poor second generation : nested paging technologyamd : RVI , Rapid virtualization indexing , from Phenomintel: EPT , Extended Page Table, from Core I7 .some artical about virtualization reference link:http://blog.163.com/tesl5@126/blog/static/681790402010125945279/http://
raid1+0 and raid0+1
Some suspect about the crash probability of raid0+1 and raid1+0 ................ N............... N[@more@]Some suspect about the crash probability of raid0+1 and raid1+0 ................ N............... N0+1 crash probability :all = 2n*(2n-1)/2bad = n*ncrash rate = n*n/ (2n*n -n) = n/(2n-1) --> n/2*(n-1)4 4/68 8/1416 16/3032 32/62crash limit -> 50%............... N............... N1+0 crash probability :all = 2n*(2n-1)/2bad = ncrash rate =n/ (2n*n -n) = 1/(2n-1) --> 1/(n-1)4 1/3
索引使用优化的两个操作
analyze index t_test1_idx1 validate structure;会话视图 index_statsalter index pk_emp monitoring usage ;全局视图 v$object_usage [@more@]INDEX_STATS" stores information from the lastANALYZE INDEX ... VALIDATE STRUCTUREstatement.上面语句意思是说index_stats存储最后一次对索引分析结构的信息.判断一个所以是否需要重建,我们介绍一个简单的方法:对一个索引进行结构分析后,如果该索引占用超过了一个数据块,且满足以下条件之一:B-tree树的高度大于3;使用百分比低于75%;数据删除率大于15%,就需要考虑对索引重建:
IBM X SERVER 安装 WINDOWS
IBM X SERVER 安装 WINDOWS[@more@]安装 WINDOWS, 很简单,这里简述一下IBM X SERVER 上安装WINDOWS 与PC上的操作差异。1,首先插入并安装 驱动盘(引导盘)即:service guide(setup and installation).将IBM X SERVER Service Guide 插入光驱,系统会引导,进行一些初始化工作,包括:磁盘分区,配置WINDOWS 应答文件,时区,语言,拷贝驱动等选项,配置完之后,系统会提示插入WINDOWS 2003 安装盘, 接下来就会自动安装, 装好后进入 WINDOWS,所有的服务器驱动已经装好,避免了用户手工一个个安装驱动的麻烦。总结: IBM X SERVER 上
数据库移动路径一例。相同平台不同路径迁移
由于重装系统,新系统的路径和原系统不一致,造成ORACLE启动时找不到文件。通过以下操作可以解决。[@more@]由于重装系统,新系统的路径和原系统不一致,造成ORACLE启动时找不到文件。通过以下操作可以解决。平台:WINDOWS XP + ORACLE 10G1,启动 ORACLE 服务2,在Idle instance mode 下:create pfile='c:car.ini' from spfile ;3, 修改car.ini 中所有的文件路径4,create spfile from pfile='c:car.ini' ;5, startup mount6,由于FLASHBACK 文件路径不一致,提示错误,所以需要暂时关闭FLASHBACK。ALTER DATABASE FLASHBACK OFF ;7, 重命
存储过程中慎用 execute immediate
存储过程中慎用 execute immediate ,execute immediate 执行DDL语句一定要小心,否则会造成数据一至性问题。[@more@]1,create table t1( id1 number );2,begininsert into t1 values (101) ;execute immediate ' create table t2 (id1 number ) '; end;/PL/SQL procedure successfully completed数据已经被提交,无论你是否COMMIT。 如果一个过程中有多个DML语中,中间混杂了类似的DDL动态语句,就会造成DDL之前的语句提交,尽管DDL之后的语句失败了,最终也无法将整个事物回滚到一致性状态。3,begininsert into t1 values (101) ;execut
归档空间不足导致实例死锁
DB启用了归档,但是却没有指定归档路径,所以使用了默认的路径-----快速闪回恢复区。[@more@]DB启用了归档,但是却没有指定归档路径,所以使用了默认的路径-----快速闪回恢复区。db_recovery_file_dest string d:oracleproduct10.2.0/flash_recovery_areadb_recovery_file_dest_size big integer 2G由于指定了快速闪回恢复区的大小, 所以当该路径下的数据库文件达到这个数值时,数据库就不会再增加归档文件; 如果是闪回日志,那么会删除旧的日志再写入新的日志。相关错误信息:ORA-00257: archiver error. Connect internal only, until
deterministic function 函数索引
ORACLE 10g允许建立函数索引,默认情况下只能使用系统函数。如果要建立基于用户自定义函数的索引。那么就需要在函数里加上关键字“deterministic”。但是用户仍然可以在今后需要时修改函数。 但是并不会造成索引失效。经试验发现了一个有趣的现象,总结如下:[@more@]ORACLE 10g允许建立函数索引,默认情况下只能使用系统函数。如果要建立基于用户自定义函数的索引。那么就需要在函数里加上关键字“deterministic”。但是用户仍然可以在今后需要时修改函数。 但是并不会造成索引失效。经试验发现了一个有趣的现象,总结如下:create funct