`

oracle知识

 
阅读更多
spfile排错小tip
有时候我们会不小心修改了spfile的某些参些参数导致数据库不能启动,这时候改怎么让数据库重新跑起来呢,oracle针对spfile还是提供了几种方法来修复的。

1.创建pfile

SQL> alter system set processes=10000 scope=spfile;
System altered.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORA-00064: object is too large to allocate on this O/S (1,9960000)
SQL> create pfile from spfile;
File created.
SQL> host notepad D:/oracle/ora92/database/INITtest.ORA

修改processes=150

SQL> startup pfile=D:/oracle/ora92/database/INITtest.ORA
ORACLE instance started.
Total System Global Area  101785428 bytes
Fixed Size                   454484 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.


2.创建pfile,再从pfile创建spfile

SQL> alter system set processes=10000 scope=spfile;
System altered.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORA-00064: object is too large to allocate on this O/S (1,9960000)
SQL> create pfile from spfile;
File created.
SQL> host notepad D:/oracle/ora92/database/INITtest.ORA

修改processes=150

SQL> create spfile from pfile;
File created.
SQL> startup
ORACLE instance started.
Total System Global Area  101785428 bytes
Fixed Size                   454484 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL>


3.修改pfile,覆盖参数

修改pfile

spfile=D:/oracle/ora92/database/SPFILETEST.ORA
processes=150

SQL> startup pfile=D:/oracle/ora92/database/INITtest.ORA
ORACLE instance started.
Total System Global Area  101785428 bytes
Fixed Size                   454484 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
oracle排序系列二
上一期讲了oracle在什么情况下需要排序,这次我们把注意力集中到与排序相关的几个内存组件

PGA:
The Process Global Area,它是属于私有内存段,段内的内容只对本进程可见,这不同于sga的共享内存段。
pga的内存结构不需要latch来保护,因为不会有其他进程同时访问。PGA包括两个部分,fixed pga,variable pga。
fixed pga保存一些数据结构和指向variable pga的指针。PGA也是通过freelist和bucket来分配和管理。

UGA:
User Global Area,它包含以下一些信息
The persistent and runtime areas for open cursors
State information for packages, in particular package variables
Java session state
The roles that are enabled
Any trace events that are enabled
The NLS parameters that are in effect
Any database links that are open
The session's mandatory access control (MAC) label for Trusted Oracle

和PGA一样,它也分为fixed,variable两个部分,同样通过freelist和bucket分配和管理内存。

CGA:
Call Global Area,跟PGA不一样,CGA只是短暂存在的,它只存在于每一次调用周期,当
Parse an SQL statement
Execute an SQL statement
Fetch the outputs of a SELECT statement
的时候它会被使用到
在分析语句的时候产生的递规调用将会使用到CGA,包括用于检查语义,生成执行计划,PL/SQL中的递规调用也会用到它,DML的触发器递规
调用同样会需要它。Java Call Memory也是在CGA中,这也是ORACLE内存管理中唯一一个用到垃圾收集(garbage collection)的内存区域。

关于PGA,UGA,CGA的详细解释请参考Steve Adamas的<<oracle8i internal services for waits, latches, locks>>


sort_area_size:
排序空间的最大限制,在完成排序阶段后,oracle将释放内存并保留sort_area_retained_size用于fetch阶段,当最后一条记录被fetch回
客户端后,oracle将会释放sort_area_retained_size。


sort_area_retained_size:
在UGA中分配的排序空间,当oracle发生排序时,先会从UGA中分配内存直到达到sort_area_retained_size的限制,然后会继续在PGA中分配
内存一直到sort_area_size限制,如上面所说的,sort_area_retained_size将会在fetch阶段被保留,在fetch完成后释放给OS或PGA(区别
在于是否UGA是PGA的subheap)


在9iR2版本以前,UGA,CGA一直是PGA的subheap,当它们被释放后将会释放给PGA而不是释放给OS,这是由于PGA的内存分配是通过malloc,brk
来实现的,但是从9iR2版本开始,我们有了选择,_use_realfree_heap参数给我们机会去改变PGA内存的分配方式,当_use_realfree_heap为
true时,PGA的内存分配将会通过mmap来实现,这样当调用munmap的时候将不必将内存返回给进程而直接返回给OS.下面我们来验证一下



alter system set "_use_realfree_heap"=true;

ALTER SESSION SET EVENTS
    'immediate trace name heapdump level 1';
   
HEAP DUMP heap name="pga heap"  desc=0xc6a6400
extent sz=0x206c alt=92 het=32767 rec=0 flg=2 opc=2
parent=(nil) owner=(nil) nex=(nil) xsz=0xfff8
EXTENT 0 addr=0xb72c0008
******************************************************
******************************************************
HEAP DUMP heap name="top call heap"  desc=0xc6a8c00
extent sz=0x206c alt=100 het=32767 rec=0 flg=2 opc=2
parent=(nil) owner=(nil) nex=(nil) xsz=0xfffc
EXTENT 0 addr=0xb72b0004
  Chunk b72b000c sz=    32780    perm      "perm           "  alo=40
  Chunk b72b8018 sz=    31672    free      "               "
  Chunk b72bfbd0 sz=     1072    recreate  "callheap       "  latch=(nil)
     ds  c6a8300 sz=     1072 ct=        1
Total heap size    =    65524
******************************************************
******************************************************
HEAP DUMP heap name="top uga heap"  desc=0xc6a8d20
extent sz=0xffdc alt=100 het=32767 rec=0 flg=3 opc=3
parent=(nil) owner=(nil) nex=(nil) xsz=0xfffc
EXTENT 0 addr=0xb72e0004
  Chunk b72e000c sz=    65524    free      "               "
EXTENT 1 addr=0xb72d0004
  Chunk b72d000c sz=       48    free      "               "
  Chunk b72d003c sz=    65476    recreate  "session heap   "  latch=(nil)
     ds b72c7628 sz=    65476 ct=        1
Total heap size    =   131048

当_use_realfree_heap为true时,pga,uga,cga为独立的heap

strace -p xxxx -o 1.txt

mmap2(0xb7271000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7271000
mmap2(0xb7281000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7281000
mmap2(0xb7291000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7291000
mmap2(NULL, 1048576, PROT_NONE, MAP_PRIVATE|MAP_NORESERVE, 7, 0xf1) = 0xb7121000
mmap2(0xb7121000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7121000
mmap2(0xb7131000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7131000
mmap2(0xb7141000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7141000
mmap2(0xb7151000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7151000
mmap2(0xb7161000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0xb7161000

同时可以看到内存分配是通过mmap来实现的





alter system set "_use_realfree_heap"=false;

ALTER SESSION SET EVENTS
    'immediate trace name heapdump level 1';   
   
HEAP DUMP heap name="pga heap"  desc=0xc6a6400
extent sz=0x206c alt=92 het=32767 rec=0 flg=3 opc=3
parent=(nil) owner=(nil) nex=(nil) xsz=0x206c
EXTENT 0 addr=0xc74a7b8
  Chunk  c74a7c0 sz=     8292    free      "               "
EXTENT 1 addr=0xc748740
  Chunk  c748748 sz=     4148    free      "               "
  Chunk  c74977c sz=     4144    freeable  "session heap   "  ds=0xc73332c


当_use_realfree_heap为true时,uga,cga为pga的subheap


strace -p xxxx -o 2.txt
 
brk(0xc7fb000)                          = 0xc7fb000
brk(0xc823000)                          = 0xc823000
brk(0xc852000)                          = 0xc852000
brk(0xc881000)                          = 0xc881000
brk(0xc8b1000)                          = 0xc8b1000
brk(0xc8e0000)                          = 0xc8e0000
brk(0xc90f000)                          = 0xc90f000
brk(0xc93f000)                          = 0xc93f000
brk(0xc96e000)                          = 0xc96e000
brk(0xc99d000)                          = 0xc99d000


同时可以看到内存分配是通过brk来实现的


我们再来看一下在_use_realfree_heap不同设置下uga,pga的内存使用情况


_use_realfree_heap=true


SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               1.8679962158203125M
session uga memory max                                           49.53220367431640625M
session pga memory                                               4.808185577392578125M
session pga memory max                                           62.308185577392578125M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               49.78192901611328125M
session uga memory max                                           49.78192901611328125M
session pga memory                                               52.808185577392578125M
session pga memory max                                           62.308185577392578125M


SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .898193359375M
session uga memory max                                           49.78192901611328125M
session pga memory                                               3.808185577392578125M
session pga memory max                                           62.308185577392578125M


可以看到排序结束后UGA,PGA都直接返回给OS



_use_realfree_heap=false


SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.



SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .699710845947265625M
session uga memory max                                           .91107177734375M
session pga memory                                               3.50872802734375M
session pga memory max                                           3.50872802734375M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               49.081577301025390625M
session uga memory max                                           49.081577301025390625M
session pga memory                                               51.68599700927734375M
session pga memory max                                           51.68599700927734375M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .61719512939453125M
session uga memory max                                           49.081577301025390625M
session pga memory                                               51.68599700927734375M
session pga memory max                                           51.68599700927734375M


可以看到排序结束后UGA将会释放给PGA,而PGA也不会释放给OS,直到OS内存不足时将会释放出来


再来看一下sort_area_retained_size,sort_area_size设置对排序的影响


_use_realfree_heap=false

SQL 10G>alter session set workarea_size_policy=manual;

Session altered.

SQL 10G>alter session set sort_area_size=102400000;

Session altered.

SQL 10G>alter session set sort_area_retained_size=1024;

Session altered.

SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.


SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .646923065185546875M
session uga memory max                                           49.081577301025390625M
session pga memory                                               60.620296478271484375M
session pga memory max                                           60.620296478271484375M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .62007904052734375M
session uga memory max                                           49.081577301025390625M
session pga memory                                               60.620296478271484375M
session pga memory max                                           60.620296478271484375M


可以看到当sort_area_retained_size设置为1024时(实际上sort_area_retained_size的最小值为2*blocksize,
设置成1024将会被置为2*blocksize),它从UGA中先分配2*blocksize(这里是16k)的内存,然后从PGA中分配。


SQL 10G>alter session set sort_area_retained_size=102400000;

Session altered.

SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.


SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               49.0844573974609375M
session uga memory max                                           49.0844573974609375M
session pga memory                                               60.620296478271484375M
session pga memory max                                           60.620296478271484375M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .61717987060546875M
session uga memory max                                           49.0844573974609375M
session pga memory                                               60.620296478271484375M
session pga memory max                                           60.620296478271484375M

如果设置sort_area_retained_size=102400000=sort_area_size时,那么可以看到UGA将会被一直使用


下面是_use_realfree_heap=true时的情况,情况一样,除了整个排序结束后内存是返回给OS而不是进程
_use_realfree_heap=true

SQL 10G>alter session set workarea_size_policy=manual;

Session altered.

SQL 10G>
SQL 10G>
SQL 10G>
SQL 10G>alter session set sort_area_size=102400000;

Session altered.

SQL 10G>
SQL 10G>
SQL 10G>
SQL 10G>alter session set sort_area_retained_size=1024;

Session altered.


SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.


SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .46117401123046875M
session uga memory max                                           .58603668212890625M
session pga memory                                               59.558185577392578125M
session pga memory max                                           59.558185577392578125M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .46117401123046875M
session uga memory max                                           .58603668212890625M
session pga memory                                               .870685577392578125M
session pga memory max                                           59.558185577392578125M


SQL 10G>alter session set sort_area_retained_size=102400000;

Session altered.

SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.


SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               49.78192901611328125M
session uga memory max                                           49.78192901611328125M
session pga memory                                               52.745685577392578125M
session pga memory max                                           59.558185577392578125M

SQL 10G>/

NAME                                                             MEM
---------------------------------------------------------------- -----------------------------------------
session uga memory                                               .898193359375M
session uga memory max                                           49.78192901611328125M
session pga memory                                               3.808185577392578125M
session pga memory max                                           59.558185577392578125M





sort_area_retained_size同时会对排序性能产生比较大的影响,不恰当的sort_area_retained_size设置将会导致排序性能严重下降。
当sort_area_size大于语句排序空间需求而sort_area_retained_size设置小于语句排序空间需求时就会产生initial run,导致使用
到临时表空间来存放initial run,这样会降低排序的性能。

SQL 10G>alter session set events'10032 trace name context forever,level 1';

Session altered.


SQL 10G>alter session set sort_area_retained_size=102400000;

Session altered.


SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.



SQL 10G>alter session set sort_area_retained_size=1024;

Session altered.


SQL 10G>select * from testsort order by 1,2,3;

398608 rows selected.



---- Sort Parameters ------------------------------
sort_area_size                    102400000
sort_area_retained_size           102400000
sort_multiblock_read_count        2
max intermediate merge width      2837
---- Sort Statistics ------------------------------
Input records                             398608
Output records                            398608
Total number of comparisons performed     4977796
  Comparisons performed by in-memory sort 4977796
Total amount of memory used               50689024
Uses version 2 sort
Does not use asynchronous IO
---- End of Sort Statistics -----------------------



sort_area_size                    102400000
sort_area_retained_size           16384
sort_multiblock_read_count        2
max intermediate merge width      2837
*** 2005-10-13 18:09:07.352
---- Sort Statistics ------------------------------
Initial runs                              1
Input records                             398608
Output records                            398608
Total disk blocks used                    5527
Total number of comparisons performed     4977796
  Comparisons performed by in-memory sort 4977796
Temp segments allocated                   1
Extents allocated                         44
Total amount of memory used               50689024
Uses version 2 sort
Does not use asynchronous IO


当使用自动管理PGA时,sort_area_retained_size将会被设置成等于sort_area_size

SQL 10G>show parameter work

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
fileio_network_adapters              string
workarea_size_policy                 string      AUTO

SQL 10G>show parameter pga

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 1G

SQL 10G>alter session set events'10032 trace name context forever,level 1';

Session altered.

SQL 10G>set autotrace trace;
SQL 10G>select * from testsort order by 1,2,3;
398608 rows selected.


---- Sort Parameters ------------------------------
sort_area_size                    50689024
sort_area_retained_size           50689024
sort_multiblock_read_count        1
max intermediate merge width      3092
---- Sort Statistics ------------------------------
Input records                             398608
Output records                            398608
Total number of comparisons performed     4977796
  Comparisons performed by in-memory sort 4977796
Total amount of memory used               50689024
Uses version 2 sort
Does not use asynchronous IO

下一次我们将分享自动管理PGA

set constraint,alter session set constraint,有条件的unique限制
set constraint 子句是用来设置deferrable constraint的状态的,可以设置constraint的状态为immediate或deferred,具体语法请看
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_104a.htm#2066962

它的作用域在事务级别,一旦事务结束constraint的状态恢复初始值

SQL 10G>create table t
( x int constraint check_x check ( x > 0 ) deferrable initially immediate,
  y int constraint check_y check ( y > 0 ) deferrable initially deferred
)
/


SQL 10G>conn test/test
Connected.
SQL 10G>desc user_constraints
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
OWNER                                     NOT NULL VARCHAR2(30)
CONSTRAINT_NAME                           NOT NULL VARCHAR2(30)
CONSTRAINT_TYPE                                    VARCHAR2(1)
TABLE_NAME                                NOT NULL VARCHAR2(30)
SEARCH_CONDITION                                   LONG
R_OWNER                                            VARCHAR2(30)
R_CONSTRAINT_NAME                                  VARCHAR2(30)
DELETE_RULE                                        VARCHAR2(9)
STATUS                                             VARCHAR2(8)
DEFERRABLE                                         VARCHAR2(14)
DEFERRED                                           VARCHAR2(9)
VALIDATED                                          VARCHAR2(13)
GENERATED                                          VARCHAR2(14)
BAD                                                VARCHAR2(3)
RELY                                               VARCHAR2(4)
LAST_CHANGE                                        DATE
INDEX_OWNER                                        VARCHAR2(30)
INDEX_NAME                                         VARCHAR2(30)
INVALID                                            VARCHAR2(7)
VIEW_RELATED                                       VARCHAR2(14

查看constraint的初始值

SQL 10G> select CONSTRAINT_NAME,CONSTRAINT_TYPE,STATUS,DEFERRABLE,DEFERRED from user_constraints where table_name='T';
CONSTRAINT_NAME                C STATUS   DEFERRABLE     DEFERRED
------------------------------ - -------- -------------- ---------
CHECK_X                        C ENABLED  DEFERRABLE     IMMEDIATE
CHECK_Y                        C ENABLED  DEFERRABLE     DEFERRED


由于x列的初始值为immediate,所以当发生insert的时候就直接报错了


SQL 10G>insert into t values(-1,1);
insert into t values(-1,1)
*
ERROR at line 1:
ORA-02290: check constraint (TEST.CHECK_X) violated


设定constraint为deferred

SQL 10G>set constraints all deferred;
Constraint set.
SQL 10G>insert into t values(-1,1);
1 row created.
SQL 10G>commit;
commit
*
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-02290: check constraint (TEST.CHECK_X) violated

可以看到constraint设置起作用了


再次insert又报错误,因为set constraint的作用域是事务级的,已经恢复到初始设置


SQL 10G>insert into t values(-1,1);
insert into t values(-1,1)
*
ERROR at line 1:
ORA-02290: check constraint (TEST.CHECK_X) violated


使用alter session 来进行session级别的constraint设置

SQL 10G>alter session set constraints=deferred;
Session altered.
SQL 10G>insert into t values(-1,1);
1 row created.
SQL 10G>commit;
commit
*
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-02290: check constraint (TEST.CHECK_X) violated

SQL 10G>insert into t values(-1,1);
1 row created.
SQL 10G>commit;
commit
*
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-02290: check constraint (TEST.CHECK_X) violated

可以发现在session级别内constraint的设置都保持有效


下面来演示一下有条件的unique限制

SQL 10G>drop table t;
Table dropped.

SQL 10G>create table t(a varchar2(10),b number);
Table created.
SQL 10G>create unique index uni_t
  2  on t( case when a = 'ACTIVE' then b end );
Index created.


SQL 10G>insert into t values('a',1);
1 row created.

SQL 10G>insert into t values('a',1);
1 row created.

SQL 10G>commit;
Commit complete.

SQL 10G>insert into t values('ACTIVE',1);
1 row created.

SQL 10G>insert into t values('ACTIVE',1);
insert into t values('ACTIVE',1)
*
ERROR at line 1:
ORA-00001: unique constraint (TEST.UNI_T) violated

通过函数索引就实现了有条件的unique限制,不考虑性能问题的话倒是一个好的方法
数据库打开情况下删除数据文件会发生什么(unix)
创建测试表空间及表


SQL 10G>create tablespace testearse datafile '/opt/oracle/oradata/dbtest/testearse.dbf' size 1m;
Tablespace created.

SQL 10G>create table testearse(a number) tablespace  testearse;
Table created.



看看有哪些进程关联到这个数据文件

SQL 10G>!
[oracle@csdba ~]$ lsof |grep testearse
oracle     4424  oracle   33uW     REG        8,9    1056768     852911 /opt/oracle/oradata/dbtest/testearse.dbf
oracle    25121  oracle   15u      REG        8,9    1056768     852911 /opt/oracle/oradata/dbtest/testearse.dbf


删除这个数据文件

[oracle@csdba ~]$ rm /opt/oracle/oradata/dbtest/testearse.dbf
[oracle@csdba ~]$

再观看lsof的结果,发现相关的状态已经变成deleted,但是文件还是保持打开状态

[oracle@csdba ~]$ lsof |grep testearse
oracle     4424  oracle   33uW     REG        8,9    1056768     852911 /opt/oracle/oradata/dbtest/testearse.dbf (deleted)
oracle    25121  oracle   15u      REG        8,9    1056768     852911 /opt/oracle/oradata/dbtest/testearse.dbf (deleted)


oracle    4424     1  0 Sep14 ?        00:00:35 ora_dbw0_dbtest
oracle   25121 25893  0 14:41 ?        00:00:00 oracledbtest (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))


SQL 10G>insert into testearse values(10);
1 row created.
SQL 10G>commit;
Commit complete.
SQL 10G>alter system checkpoint;
System altered.
SQL 10G>insert into testearse values(10);
1 row created.
SQL 10G>commit;
SQL 10G>select * from testearse;
         A
----------
        10
        10
        
SQL 10G>ALTER SESSION SET EVENTS 'immediate trace name flush_cache';
Session altered.
SQL 10G>select * from testearse;
         A
----------
        10
        10
由于本身sqlplus的process和testearse.dbf还建立连接,所以这时仍然可以对这个表进行操作



退出sqlplus,重新开启sqlplus

 
SQL 10G>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning and Data Mining Scoring Engine options

[oracle@csdba ~]$ lsof |grep testearse
oracle     4424  oracle   33uW     REG        8,9    1056768     852911 /opt/oracle/oradata/dbtest/testearse.dbf (deleted)

这时只剩下dbwr进程和testearse.dbf还建立连接

[oracle@csdba bdump]$  sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Oct 10 15:47:58 2005
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning and Data Mining Scoring Engine options
SQL 10G>conn test/test
Connected.
SQL 10G>select * from testearse;
         A
----------
         10
         10
SQL 10G>ALTER SESSION SET EVENTS 'immediate trace name flush_cache';
Session altered.

刷新buffer cache,写入数据文件

这时由于原来sqlplus和testearse.dbf的连接已经关闭,新连接由于数据文件被删除而无法建立
,所以这时候不能对testearse进行操作

SQL 10G>select * from testearse;
select * from testearse
*
ERROR at line 1:
ORA-01116: error in opening database file 13
ORA-01110: data file 13: '/opt/oracle/oradata/dbtest/testearse.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3



SQL 10G>alter system checkpoint;
System altered.

[oracle@csdba ~]$ lsof |grep testearse
限制subprogram传递null参数
如何限制procedure里传递null的参数呢,tom提供了一个简便的方法,使用subtype来实现

create or replace package my_pkg
as
        subtype mystring is varchar2(4000) NOT NULL;
        procedure p( p_input mystring );
end;
/


create or replace package body my_pkg
as
procedure p( p_input mystring )
is
begin
        null;
end;
end;
/

SQL 10G>exec my_pkg.p(null);
BEGIN my_pkg.p(null); END;
               *
ERROR at line 1:
ORA-06550: line 1, column 16:
PLS-00567: cannot pass NULL to a NOT NULL constrained formal parameter
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
分享到:
评论

相关推荐

    Oracle知识库(教程)

    Oracle知识库是一个全面涵盖Oracle数据库管理系统相关知识的资源集合,主要针对希望学习和掌握Oracle技术的用户。这个中文版的教程以CHM(Compiled Help Manual)格式提供,方便用户在无需互联网连接的情况下离线...

    Oracle知识库,手册

    这份"Oracle知识库,手册"集合提供了全面的Oracle学习和参考资源,特别适合DBA(数据库管理员)、开发人员以及对Oracle系统感兴趣的任何人。CHM版的手册意味着这些资料是以Windows帮助文件的格式存在,便于离线查阅...

    oracle知识体系结构

    oracle知识体系结构,

    oracle 知识库oracle 知识库oracle 知识库oracle 知识库

    Oracle数据库系统是全球广泛使用的大型关系型数据库...本Oracle知识库涵盖了上述各方面的内容,旨在帮助用户全面理解和掌握Oracle数据库系统,无论你是初学者还是经验丰富的DBA,都能从中获取宝贵的知识和实践经验。

    oracle 知识库 (整理的chm文档)

    虽然这些知识来源于2004年的资源,但Oracle的基本原理和最佳实践并未发生根本变化。因此,对于初学者和经验丰富的数据库管理员来说,这些内容仍然是宝贵的参考资料。通过深入学习和实践,你可以更好地理解和运用...

    oracle知识点总结.txt

    oracle知识点总结.txt 个人对oracle的一些总结

    oracle知识库

    本“Oracle知识库”包含了一系列关于Oracle的相关资料,旨在帮助用户深入理解和掌握Oracle的各个方面。 1. **Oracle体系结构** Oracle数据库的架构由多个组件构成,包括服务器进程、客户端进程、内存结构(如SGA和...

    Oracle知识大全PPT合集

    Oracle知识大全PPT合集是一份综合性的学习资源,涵盖了Oracle数据库从安装、配置到管理、优化等全方位的知识。这份合集特别适合Oracle初学者以及准备OCP(Oracle Certified Professional)考试的人员进行深入学习。 ...

    oracle数据库中文文档 包括oracle九阴真经,NET开发oracle,全面的oracle知识

    4. **全面的Oracle知识**:涵盖Oracle的安装与配置、数据库设计、SQL查询语言、存储过程和函数、触发器、视图、索引、分区、数据库性能调优、数据库复制技术(如GoldenGate)、数据库安全、备份与恢复策略、故障诊断...

    Oracle知识点整理笔记(二)Oracle学习进阶

    该资源是系统学习Oracle后做的整理,方便后来学者更好,更快的学习Oracle知识,资源里面有Oracle学习资料,以及学习期间整理辅助学习资料,此资源内容是Oracle知识点整理笔记的下篇,Oracle的初学篇知识学习可以查看...

    oracle知识库.zip

    Oracle的技术广泛应用于各行各业,其中电信、电力、金融、政府及大量制造业都需要Oracle技术人才,Oracle公司针对职业教育市场在全球推广的项目,其以低廉的成本给这部分人群提供Oracle技术培训,经过系统化的实训,...

    Oracle知识库

    Oracle知识库是一个全面涵盖Oracle数据库管理系统相关知识的资源集合,对于数据库管理员(DBA)、开发人员和IT专业人员来说,是提升技能和解决问题的重要参考资料。CHM文件是一种Microsoft编写的帮助文档格式,它将...

    oracle知识概览.rar

    "Oracle知识概览.rar"这个压缩包文件显然提供了一个全面的学习路线图,帮助初学者或有经验的用户更好地理解和掌握Oracle的相关知识。以下是Oracle学习的一些关键点: 1. **Oracle数据库基础**:首先要了解Oracle...

    割接常用Oracle知识

    割接 常用 Oracle 知识,主要是一些常用的技术,及ORACLE调优方面的知识,有利大家在平时工作中,使用到。

    Oracle知识

    总之,Oracle知识不仅包括数据库的基本架构、内存与进程结构、物理存储结构,还涉及到安装、管理、备份恢复以及性能监控等实际操作技能。对于那些希望深入学习Oracle数据库的朋友来说,了解这些知识点是不可或缺的,...

    Oracle知识点总结(吐血推荐).doc

    Oracle知识点总结 本文档旨在总结Oracle数据库的相关知识点,涵盖了Oracle数据库的安装和配置、开发工具、数据库设计、事务处理、函数和存储过程等方面的内容。 一、Oracle数据库的安装和配置 Oracle数据库的安装...

    常用ORACLE知识浅析1

    本文将对一些常见的Oracle知识进行浅析,主要包括数据库的概念、实例结构、环境变量、连接方式、以及一些基础的SQL函数。 首先,我们需要理解数据库和Oracle实例的区别。数据库是存储数据的物理结构,包括数据文件...

    oracle知识點滴

    "Oracle知识点滴"显然是一份汇聚了关于Oracle数据库关键概念和技术的资料,适合Oracle用户进行学习和参考。以下是根据标题、描述以及文件名所推测的一些关键知识点: 1. **Oracle数据库架构**:Oracle数据库采用...

    Oracle学习笔记(Oracle知识点总结)

    Oracle知识点总结,适合初学者,平时多联系,放在手机上,当做电子书来看。

Global site tag (gtag.js) - Google Analytics