Thomas Zhang的杂货铺
30 06, 2008
强悍的SQLTXPLAIN
作者 tomszrp 23:08 | Permalink 静态链接网址 | Comments 最新回复 (2) | Trackback 引用 (0) | PUB论剑

今天下载了SQLTXPLAIN的最新版本,并在自己的本子上做了一个体验,这个工具最早我在使用8i的时候用过一次,后来在因为绝大部分情况下用不着她,就慢慢的遗忘了,今天下载了最新的针对9i,10g,11g的新版本,在更新自己的资料库的时候才发现,很前就玩过了,没想到她也一直在"成长"。

这是一个全面的、强大的分析和调优SQL语句的有力工具

工具需要到metalink上download
SQLTXPLAIN Directory Structure
sqlt/
install/
run/
sample/
在zip文件里包含详细的说明和demo.说明写的很详细

工具的安装和卸载类似statspack这样的工具
conn /as sysdba
start sqcreate.sql
然后按照提示输入密码、表空间和临时表空间就OK了。

conn /as sysdba
start sqdrop.sql

需要注意的是:
1)在安装sqltxplain之前,你必须要确保你的系统中已经安装了如下4个package.
sys.dbms_metadata
sys.dbms_random
sys.utl_file
sys.dbms_shared_pool
2)在安装的过程中会提示你输入一个Host String (TNS Alias),记得一定要加上@
比如我的Host String为ora10g,那么要输入@ora10g
3)如果你的temp 表空间比较小的话,记得一定要将tempfile resize一下,比如到200M,因为这个工具中使用了很多的
临时表。如果你希望永久保存的话,那么就需要手工修改一下sqctab.sql这个脚本了。
4)有一些bug会影响到SQLTXPLAIN的,所以你需要自己的阅读一下instructions.txt

SQLTXPLAIN的调用有三种方式:
XPLAIN - Given one SQL, it generates its explain plan without executing the SQL
XTRACT - Given an id for a known SQL, it extracts the SQL and its actual execution plan from memory
XECUTE - Given a script that contains one SQL and its bind variables (declaration and values),
it executes the SQL and extracts its execution plan form memory

使用起来比较简单,但输出的结果太完美了,不罗嗦了。大家赶紧去体验一下就知道了。

31 08, 2007
dbms_metadata获取的表结构和desc出来的不一致的一个demo
作者 tomszrp 13:06 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
这个问题源至一位puber的问题。

实际上不能说是一个问题, 只是因为该表采用了基于rowid的方式做过
在线重定义而多出来的一个隐藏列。这个隐藏列通过desc是看不到的。
而metadata.get_ddl可以读取到,下面再现一下:

目的:把一个普通表在线重定义为hash partition table.

测试环境:xp+10.2.0.1


SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE	10.2.0.1.0	Production

TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> 
SQL> create table zrp
  2  (oid number,
  3   dealdate date default sysdate
  4  );

Table created

SQL> begin
  2   for i in 1..100 loop
  3       insert into zrp (oid) values(i);
  4   end loop;
  5   commit;
  6  end;
  7  /

PL/SQL procedure successfully completed

SQL> 
SQL> create table ZRP_MID
  2  (
  3    OID      NUMBER,
  4    DEALDATE DATE default sysdate
  5  )
  6  partition by hash (OID)
  7  ( partition p1 tablespace STUDY,
  8    partition p2 tablespace STUDY,
  9    partition p3 tablespace STUDY,
 10    partition p4 tablespace STUDY
 11  );

Table created

SQL> exec dbms_redefinition.can_redef_table(
       'STUDY',
       'ZRP',
       dbms_redefinition.cons_use_rowid);

PL/SQL procedure successfully completed

SQL> exec dbms_redefinition.start_redef_table(
      'study',
      'ZRP',
      'ZRP_MID',
      'oid oid,dealdate dealdate',
      dbms_redefinition.cons_use_rowid);

PL/SQL procedure successfully completed

SQL> exec dbms_redefinition.finish_redef_table('STUDY','ZRP','ZRP_MID');

PL/SQL procedure successfully completed

SQL> desc zrp
Name     Type   Nullable Default Comments 
-------- ------ -------- ------- -------- 
OID      NUMBER Y                         
DEALDATE DATE   Y        sysdate          

SQL> desc zrp_mid
Name     Type   Nullable Default Comments 
-------- ------ -------- ------- -------- 
OID      NUMBER Y                         
DEALDATE DATE   Y        sysdate          

SQL> 
SQL> select dbms_metadata.get_ddl('TABLE','ZRP') from dual;

DBMS_METADATA.GET_DDL('TABLE',
------------------------------------------------------
CREATE TABLE "STUDY"."ZRP"
(	"SYS_C00003_07083112:38:30$" VARCHAR2(255),
	"OID" NUMBER,
	"DEALDATE" DATE DEFAULT sysdate
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  STORAGE(BUFFER_POOL DEFAULT)
  TABLESPACE "STUDY"
  PARTITION BY HASH ("OID")
  (PARTITION "P1"  TABLESPACE "STUDY",
   PARTITION "P2"  TABLESPACE "STUDY",
   PARTITION "P3"  TABLESPACE "STUDY",
   PARTITION "P4"  TABLESPACE "STUDY")
SQL> 

这个时候我们看到,多出了一列,其实这一列是因为我们采用基于rowid的
方式在线重定义而增加的一个隐藏列。在9i中这个列名为M_ROW$$,在10g中
采用了新的命名机制:
  SYS_C<5位的数字>_yymmddhh24:mi:ss$
  比如:SYS_C00003_07083112:38:30$
  这个格式的官方doc我还不曾看到(没来得及学习),是我猜出来的,其中5位
  数字编码应该是列的序号,不知道是否这样。   

SQL> select col#,name,type#
  2  from SYS.COL$
  3  WHERE OBJ#=(select object_id
  4              from dba_objects
  5              where owner='STUDY' and
  6                    object_name='ZRP' And
  7                    object_type='TABLE');

      COL# NAME                                TYPE#
---------- ------------------------------ ----------
         1 OID                                     2
         2 DEALDATE                               12
         0 SYS_C00003_07083112:38:30$              1

SQL> 

SQL> alter table zrp set unused column "SYS_C00003_07083112:38:30$";

Table altered

SQL> alter table zrp drop unused columns;

Table altered

SQL> desc zrp
Name     Type   Nullable Default Comments 
-------- ------ -------- ------- -------- 
OID      NUMBER Y                         
DEALDATE DATE   Y        sysdate          

SQL> 
SQL> select col#,name,type#
  2  from SYS.COL$
  3  WHERE OBJ#=(select object_id
  4              from dba_objects
  5              where owner='STUDY' and
  6                    object_name='ZRP' And
  7                    object_type='TABLE');

      COL# NAME                                TYPE#
---------- ------------------------------ ----------
         1 OID                                     2
         2 DEALDATE                               12

SQL> insert into zrp values(2000,sysdate);

1 row inserted

SQL> commit;

Commit complete

SQL> 

再看一下通过metadata.get_ddl得到的结果:

SQL> Select dbms_metadata.get_ddl('TABLE','ZRP') From dual;

DBMS_METADATA.GET_DDL('TABLE',
----------------------------------------
CREATE TABLE "STUDY"."ZRP"
(	"OID" NUMBER,
	"DEALDATE" DATE DEFAULT sysdate
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
  STORAGE(BUFFER_POOL DEFAULT)
  TABLESPACE "STUDY"
  PARTITION BY HASH ("OID")
  (PARTITION "P1"   TABLESPACE "STUDY",
   PARTITION "P2"   TABLESPACE "STUDY",
   PARTITION "P3"   TABLESPACE "STUDY",
   PARTITION "P4"   TABLESPACE "STUDY")
SQL> 
这个就和我们期望的一样了。

进一步测试发现,如果直接drop这个隐藏列,这个版本上将导致
insert/update操作异常,下面再现一下:

SQL> alter table zrp drop column "SYS_C00003_07083113:30:37$";

Table altered

SQL> insert into zrp values(2000,sysdate);

insert into zrp values(2000,sysdate)

ORA-00600:内部错误代码,参数:[kghGetHpSz1],[0x64F0A8D4],
[],[],[],[],[],[]

SQL> delete from zrp where oid=1;

1 row deleted

SQL> desc zrp;
Name     Type   Nullable Default Comments 
-------- ------ -------- ------- -------- 
OID      NUMBER Y                         
DEALDATE DATE   Y        sysdate          

SQL> update zrp set dealdate =sysdate where oid=2;

update zrp set dealdate =sysdate where oid=2

ORA-00957: 重复的列名

SQL> update zrp set oid=20000 where oid=2;

update zrp set oid=20000 where oid=2

ORA-00600:内部错误代码,参数:[13013],[5001],[54641],[25166861],
[0],[25166861],[17],[]

SQL> 

22 08, 2007
使用dbms_metadata遇到ORA-31603的一种情况
作者 tomszrp 19:31 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

使用dbms_metadata获取object的ddl语句时,有时会遇到ORA-31603这样的错误,大部分情况是因为使用者写错了object_type或忘记了schema参数.

但也有这样的情况,如下的情况的是在9206上遇到的,其他版本我还没测试过.

场景:对分区表存在unused column的时候,使用dbms_metadata.gete_ddl返回ORA-31603

下面再现一下:

SQL> select *from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production

TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production

SQL>
SQL> create table zrp(
2 areacode number(3),
3 name varchar2(32),
4 oid number,
5 recdate date
6 )
7 partition by range(areacode)
8 (partition p_1 values less than(100),
9 partition p_2 values less than(200),
10 partition p_3 values less than(300)
11 );

Table created

SQL> set long 20000
SQL> Select dbms_metadata.get_ddl('TABLE','ZRP') From dual;

DBMS_METADATA.GET_DDL('TABLE',
-------------------------------------------------------------
CREATE TABLE "STUDY"."ZRP"
( "AREACODE" NUMBER(3,0),
"NAME" VARCHAR2(32),
"OID" NUMBER,
"RECDATE" DATE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE
(
BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000"
PARTITION BY RANGE ("AREACODE")
(PARTITION "P_1" VALUES LESS THAN (100)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS ,
PARTITION "P_2" VALUES LESS THAN (200)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS ,
PARTITION "P_3" VALUES LESS THAN (300)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS )


SQL> alter table zrp set unused column recdate;

Table altered

SQL>
SQL> Select dbms_metadata.get_ddl('TABLE','ZRP') From dual;

Select dbms_metadata.get_ddl('TABLE','ZRP') From dual

ORA-31603: object "ZRP" of type TABLE not found in schema "STUDY"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 628
ORA-06512: at "SYS.DBMS_METADATA", line 1222
ORA-06512: at line 1

SQL> Select obj#,Name From Sys.col$ Where obj#=
2 (Select object_id
3 From dba_objects
4 Where object_name='ZRP' And
5 owner=STUDYAnd
6 object_type='TABLE');

OBJ# NAME
---------- ------------------------------
352622 AREACODE
352622 NAME
352622 OID
352622 SYS_C00004_07082213:34:03$

SQL>
SQL> Select obj#,Name From Sys.col$ Where obj#=
2 (Select object_id
3 From dba_objects
4 Where object_name='ZRP' And
5 owner='STUDY' And
6 object_type='TABLE');

OBJ# NAME
---------- ------------------------------
352622 AREACODE
352622 NAME
352622 OID
352622 SYS_C00004_07082213:34:03$

SQL> alter table zrp drop unused columns;

Table altered

SQL>
SQL> Select obj#,Name From Sys.col$ Where obj#=
2 (Select object_id
3 From dba_objects
4 Where object_name='ZRP' And
5 owner='STUDY' And
6 object_type='TABLE');

OBJ# NAME
---------- ------------------------------
352622 AREACODE
352622 NAME
352622 OID

SQL>
SQL> Select dbms_metadata.get_ddl('TABLE','ZRP') From dual;

DBMS_METADATA.GET_DDL('TABLE',
-------------------------------------------------------------------
CREATE TABLE "STUDY"."ZRP"
( "AREACODE" NUMBER(3,0),
"NAME" VARCHAR2(32),
"OID" NUMBER
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(
BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000"
PARTITION BY RANGE ("AREACODE")
(PARTITION "P_1" VALUES LESS THAN (100)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS ,
PARTITION "P_2" VALUES LESS THAN (200)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS ,
PARTITION "P_3" VALUES LESS THAN (300)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "D_DATA_000" NOCOMPRESS )


SQL>


26 07, 2007
如何让SPOOL出来的文件不含执行的SQL语句
作者 tomszrp 20:57 | Permalink 静态链接网址 | Comments 最新回复 (2) | Trackback 引用 (0) | PUB论剑

今天看到这么一个问题,其实这个问题我在平时工作也经常遇到,只不过aix下的shell太强大了,

根本不需要考虑的这么复杂。

比如aix下可以通过sed来进行删除,很方便的
$ sed /SQL/d source_file >target_file

当然了, 这个问题,也可以通过sqlplus自身来完成这个动作。只不过就是罗嗦一点。

一般分为2个SQL文件
1)执行SQL的文件
2)调用1)中的sql完成spool的文件


比如我下面的这个例子中,data.sql是用来真正取数据的SQL文件,do.sql是用来完成spool

动作的SQL文件。
 

data.sql内容如下:

select * from zrp;

do.sql 是完成spool的SQL文件,在do.sql中调用了data.sql,内容如下:
set heading off feedback off term off pagesize 0
spool e:info.txt
@e:data.sql
spool off
exit


然后测试看看:

E:>sqlplus study/study @do.sql

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 7月 26 12:46:42 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开

E:>more info.txt
1
2
3
4
5
6
7
8


E:>

另外也可以使用类似如下的bat文件完成(unix的shell scripts就更简单了,不再多说).

 

edit test.bat

sqlplus -s /nolog @e:data.sql

 

data.sql的内容如下:

conn study/study
set heading off feedback off term off pagesize 0
spool e:info.txt
select * from zrp;
spool off
exit


13 07, 2007
Oracle OS Watcher使用说明(7)
作者 tomszrp 21:24 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

使用OSWg的注意事项

 

如果我们需要分析的文件很多,那么java需要更多memory,否则可能会遇到类似如下的错误:

java.lang.OutOfMemoryError

 

这个时候,我们就不得不增加java heap的大小。如果要增加java heap的大小,可以通过使用-Xmx 参数来设置,比如:

java -jar -Xmx10M OSWg.jar -i /oracle/osw/archive

 

[cs1] /oracle/osw> java -jar -Xmx10M OSWg.jar -i /oracle/osw/archive

Starting OSWg V2.0.4
OSWatcher Graph Written by Oracle Center of Expertise
Copyright (c) 2007 by Oracle Corporation

Parsing Data. Please Wait...

Parsing file cs1_vmstat_07.13.07.1000.dat ...
Parsing file cs1_vmstat_07.13.07.1100.dat ...

Parsing Completed.


Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs

Enter 6 to Generate All CPU Gif Files
Enter 7 to Generate All Memory Gif Files

Enter L to Specify Alternate Location of Gif Directory
Enter T to Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program

Please Select an Option:


13 07, 2007
Oracle OS Watcher使用说明(6)
作者 tomszrp 21:22 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

[cs1] /oracle/osw> java -jar OSWg.jar -i /oracle/osw/archive

Starting OSWg V2.0.4
OSWatcher Graph Written by Oracle Center of Expertise
Copyright (c) 2007 by Oracle Corporation

Parsing Data. Please Wait...

Parsing file cs1_vmstat_07.13.07.1000.dat ...
Parsing file cs1_vmstat_07.13.07.1100.dat ...

Parsing Completed.


Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs

Enter 6 to Generate All CPU Gif Files
Enter 7 to Generate All Memory Gif Files

Enter L to Specify Alternate Location of Gif Directory
Enter T to Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program

Please Select an Option:6

OSWG_RunQueue.gif
OSWG_BlockQueue.gif
OSWG_CpuIdle.gif
OSWG_CpuSystem.gif
OSWG_CpuUser.gif
OSWG_Interrupts.gif
OSWG_CS.gif


Enter 1 to Display CPU Process Queue Graphs
Enter 2 to Display CPU Utilization Graphs
Enter 3 to Display CPU Other Graphs
Enter 4 to Display Memory Graphs

Enter 6 to Generate All CPU Gif Files
Enter 7 to Generate All Memory Gif Files

Enter L to Specify Alternate Location of Gif Directory
Enter T to Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program

Please Select an Option:q

[cs1] /oracle/osw>

如果要查看输出结果,可以直接在上面的菜单中选择你要查看的信息。

说明:图片上传比较麻烦,我就不上传了,大家测试一下就可以看到效果了


13 07, 2007
Oracle OS Watcher使用说明(5)
作者 tomszrp 21:20 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

OSW的诊断信息字段含义说明

 

 

字段

描述
oswiostat
tinShows the total number of characters read by the system for all ttys
toutShows the total number of characters written by the system to all ttys.
kpsindicates the amount of data transferred (read or written) to the drive in KB per second
tpsIndicates the number of transfers per second that were issued to the physical disk. A transfer is an I/O request to the physical disk. Multiple logical requests can be combined into a single I/O request to the disk.
servaverage response time of transactions, in milliseconds
usPercentage of CPU cycles spent on user processes
syPercentage of CPU cycles spent on system processes wt
wtShows the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request
id
 
Percentage of unused CPU cycles or idle time when the CPU is basically doing nothing .
oswmpstat
cpuProcessor ID
minfMinor faults
mifMajor Faults
xcalProcessor cross-calls (when one CPU wakes up another by interrupting it).
intrInterrupts
ithr
 
Interrupts as threads (except clock)
cswContext switches
icswInvoluntary context switches
migrThread migrations to another processor
smtxNumber of times a CPU failed to obtain a mutex
srwNumber of times a CPU failed to obtain a read/write lock on the first try
sysclNumber of system calls
usrPercentage of CPU cycles spent on user processes
sysPercentage of CPU cycles spent on system processes
wtPercentage of CPU cycles spent waiting on event
idlPercentage of unused CPU cycles or idle time when the CPU is basically doing nothing
oswnetstat
nameDevice name of interface
MtuMaximum transmission unit
NetNetwork Segment Address
addressNetwork address of the device
ipktsInput packets
IerrsInput errors
opktsOutput Packets
OerrsOutput errors
collisCollisions
queueNumber in the Queue
oswps
fFlags s State of the process
uidThe effective user ID number of the process
pidThe process ID of the process
ppidThe process ID of the parent process.
dProcessor utilization for scheduling (obsolete).
priThe priority of the process.
niNice value, used in priority computation.
addrThe memory address of the process.
szThe total size of the process in virtual memory, including all mapped files and devices, in pages.
wchanThe address of an event for which the process is sleeping (if blank, the process is running).
stimeThe starting time of the process, given in hours, minutes, and seconds.
ttyThe controlling terminal for the process (the message ?, is printed when there is no controlling terminal).
timeThe cumulative execution time for the process.
cmdThe command name process is executing.
oswtop
PID Process ID of process
USERNAMEUsername of process
THRProcess thread PRI Priority of process
NICENice value of process
SIZETotal size of a process, including code and data, plus the stack space in kilobytes
RESAmount of physical memory used by the process
STATECurrent CPU state of process. The states can be S for sleeping, D for uninterrupted, R for running, T for stopped/traced, and Z for zombied
TIMEThe CPU time that a process has used since it started
%CPUThe CPU time that a process has used since the last update
COMMANDThe task's command name
oswvmstat
PROCS
rNumber of processes that are in a wait state and basically not doing anything but waiting to run
bNumber of processes that were in sleep mode and were interrupted since the last update
wNumber of processes that have been swapped out by mm and vm subsystems and have yet to run
MEMORY
swapThe amount of swap space currently available free The size of the free list
PAGE
repage reclaims
mfminor faults
pikilobytes paged in
pokilobytes paged out
frkilobytes freed
deanticipated short-term memory shortfall (Kbytes)
srpages scanned by clock algorithm
DISK
BiDisk blocks sent to disk devices in blocks per second
FAULTS
InInterrupts per second, including the CPU clocks
SySystem calls
CsContext switches per second within the kernel
CPU
UsPercentage of CPU cycles spent on user processes
SyPercentage of CPU cycles spent on system processes
IdPercentage of unused CPU cycles or idle time when the CPU is basically doing nothing


13 07, 2007
Oracle OS Watcher使用说明(3)
作者 tomszrp 21:18 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

OSW的启动

 

启动OSW非常简单。只要运行startOSW.sh就可以了。该shell 需要2个参数,第一个参数指定采样时间间隔,第二个指定存储数据的时间。缺省情况下(如果不输入参数),OSW采样以30秒为间隔,存储24小时的数据.

 

对于超过保留期限的数据,File Manager 会自动清理(File Manager 每隔一个小时调度一次)

 

下面是我在cs1上运行的启动过程:

[cs1] /oracle/osw> startOSW.sh 60 1
Testing for discovery of OS Utilities...
VMSTAT found on your system.IOSTAT found on your system.MPSTAT found on your system.NETSTAT found on your system.

Discovery completed.

Starting OSWatcher V2.0.2 on Fri Jul 13 10:24:43 BEIST 2007
With SnapshotInterval = 60
With ArchiveInterval = 1
OSWatcher - Written by Carl Davis, Center of Expertise, Oracle Corporation

Starting Data Collection...
osw heartbeat:Fri Jul 13 10:24:43 BEIST 2007

[cs1] /oracle/osw>

 

OSW的停止

 

停止OSW 服务,通过stopOSW.sh来完成

 

./stopOSW.sh


13 07, 2007
Oracle OS Watcher使用说明(4)
作者 tomszrp 21:18 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

OSW的诊断输出

 

运行osw后,收集的信息被放在archive下的对应的7个子目录下,以ascii格式存放。文件命名格式如下:

<node_name>_<OS_utility>_MM.DD.YY.HH24.dat

 

比如我测试收集到的文件如下:

[cs1] /oracle/osw/archive> ls -ltrR
total 0
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswprvtnet
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswvmstat
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswtop
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswps
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswnetstat
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswmpstat
drwxr-xr-x 2 oracle dba 256 Jul 13 11:00 oswiostat
./oswprvtnet:
total 0

./oswvmstat:
total 48
-rw-r--r-- 1 oracle dba 18199 Jul 13 10:59 cs1_vmstat_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 3024 Jul 13 11:05 cs1_vmstat_07.13.07.1100.dat

./oswtop:total 1704
-rw-r--r-- 1 oracle dba 741040 Jul 13 10:59 cs1_top_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 122988 Jul 13 11:05 cs1_top_07.13.07.1100.dat

./oswps:
total 1696
-rw-r--r-- 1 oracle dba 739085 Jul 13 10:59 cs1_ps_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 121733 Jul 13 11:05 cs1_ps_07.13.07.1100.dat

./oswnetstat:
total 696
-rw-r--r-- 1 oracle dba 297692 Jul 13 10:59 cs1_netstat_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 49644 Jul 13 11:05 cs1_netstat_07.13.07.1100.dat

./oswmpstat:
total 208
-rw-r--r-- 1 oracle dba 82064 Jul 13 10:59 cs1_mpstat_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 13714 Jul 13 11:05 cs1_mpstat_07.13.07.1100.dat

./oswiostat:
total 920
-rw-r--r-- 1 oracle dba 393502 Jul 13 10:59 cs1_iostat_07.13.07.1000.dat
-rw-r--r-- 1 oracle dba 65568 Jul 13 11:05 cs1_iostat_07.13.07.1100.dat
[cs1] /oracle/osw/archive>


13 07, 2007
Oracle OS Watcher使用说明(2)
作者 tomszrp 21:16 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

OSW的卸载

 

如果想卸载OSW,直接将osw的工作目录删除即可。

rm -fr ./osw

 

OSW的设置

 

当OSW安装完毕后,OSW的解压缩脚本里就提供了管理osw的启动和停止的scripts。当第一次运行OSW的时候,系统会自动在osw的目录下创建一个子目录archive,并在archive目录下再创建7个子目录。

[cs1] /oracle/osw> cd archive
[cs1] /oracle/osw/archive> ls -ltr
total 0
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswprvtnet
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswvmstat
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswtop
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswps
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswnetstat
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswmpstat
drwxr-xr-x 2 oracle dba 256 Jul 13 10:24 oswiostat
[cs1] /oracle/osw/archive>

 

如果要收集private networks 信息,必须要手工创建一个可执行文件在osw目录下,并且命名为private.net。这个文件的设置可以参考osw目录下提供的Exampleprivate.net.这个文件中包含了用来检查RAC private networks 运行traceroute的命令.

比如:

traceroute -r -F node1
traceroute -r -F node2


13 07, 2007
Oracle OS Watcher使用说明(1)
作者 tomszrp 21:14 | Permalink 静态链接网址 | Comments 最新回复 (2) | Trackback 引用 (0) | PUB论剑

一直在AIX平台下工作,从来没听说过这个osw utility,因为NMON在收集os的信息方面比这个强大多了。今天在eygle的site上看到了这个说明,到metalik上下载并在测试环境上实验了一把,觉得还不错,留个纪念吧。

 

OSW是Oracle提供的一个用于操作系统监控的工具包,这个工具包可以从Metalink下载。Metalink Note:301137.1

 

OSW支持的平台

OSW is certified to run on the following platforms:
AIX
Tru64
Solaris
HP-UX
Linux

 

OSW的安装

从metalink上下载后(并ftp 到unix server上),直接tar开就可以使用了。如果是compress格式的,先解压缩,比如:

uncompress osw.tar.Z

tar xvf osw.tar

 

[cs1] /oracle> tar xvf osw.tar
x .
x ./osw
x ./osw/Exampleprivate.net, 1731 bytes, 4 media blocks.
x ./osw/OSWatcher.sh, 11784 bytes, 24 media blocks.
x ./osw/OSWatcherFM.sh, 4451 bytes, 9 media blocks.
x ./osw/OSWg.jar, 722088 bytes, 1411 media blocks.
x ./osw/oswnet.sh, 334 bytes, 1 media blocks.
x ./osw/oswsub.sh, 401 bytes, 1 media blocks.
x ./osw/startOSW.sh, 1101 bytes, 3 media blocks.
x ./osw/stopOSW.sh, 560 bytes, 2 media blocks.
x ./osw/tarupfiles.sh, 127 bytes, 1 media blocks.
x ./osw/topaix.sh, 409 bytes, 1 media blocks.
x ./osw/README, 4997 bytes, 10 media blocks.
x ./osw/OSWgREADME, 3426 bytes, 7 media blocks.

...

续:Oracle OS Watcher使用说明(2)


08 07, 2007
如期完成toms_tools的编写工作
作者 tomszrp 20:43 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

经过一下午对index/part index部分的增加,到现在终于完成了近几天整理的这个小工具

凡事有始有终,今天为toms_tools先划个句号吧。


06 07, 2007
The Invisiable Index in 11g
作者 tomszrp 18:15 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

在Oracle 11g版本中,我们可以设置一个index的状态为Invisiable或visible
,也可以直接创建一个Invisiable的index
alter index index_name invisible;
alter index index_name visible;
create index inix_name ... invisible;

当我们在一个生产系统中分析认为一个index没有什么意义或想在某个SQL中不
使用该索引,但不想立即将其drop或无法直接修改SQL的时候,我们可以考虑将
该索引置为Invisible状态。

当然了,我们也可以使用hint提示去强制不使用 (但这个需要你去调整SQL,很
多情况下,修改这个SQL特别麻烦)

备注:置为Invisible的index在进行DML操作的时候,仍然对其进行维护。


SQL> create table test as select * from dba_objects;

Table created.

SQL> create index inx_test_object_id on test(object_id) invisible;

Index created.

--这个时候将看不到索引inx_test_object_id

SQL> select count(*) from test where object_id=100;

执行计划
----------------------------------------------------------
Plan hash value: 1357081020

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 7 | 1239 | 144 (3)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| TEST | 7 | 1239 | 144 (3)| 00:00:02 |
--------------------------------------------------------------------------


下面我们通过hint来强制使用这个索引

SQL> select /*+ index(test inx_test_object_id) */count(*) from test where object_id=100;

执行计划
----------------------------------------------
Plan hash value: 3278524694

----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| INX_TEST_OBJECT_ID | 1 | 13 | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------

SQL>

再来看将这个index置为visible的情况
SQL> alter index inx_test_object_id visible;

Index altered.

SQL>
SQL> select count(*) from test where object_id=100;
执行计划
----------------------------------------------
Plan hash value: 3278524694

----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| INX_TEST_OBJECT_ID | 1 | 13 | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------

SQL>

可以看到,这个索引系统又能看到了。

当然了,如果不想使用该索引,通过no_index hint我们一样可以屏蔽掉。这个大家太熟悉了,不再
多罗嗦了。


同样的,在11g中,我们可以通过dba_indexes视图可以查看一个index的visible属性。

select index_name,visibility
from dba_indexes
where index_name='INX_TEST_OBJECT_ID';

INDEX_NAME VISIBILITY
------------------- -----------
INX_TEST_OBJECT_ID VISIBILE


06 07, 2007
Read -Only Tables in 11g
作者 tomszrp 13:38 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

在11g中,对table上又增加了一项新的功能,我们终于可以轻松的设置一张表为read only状态了:

设置表为只读或读写和设置tablespace的语法相似,比如

alter table table_name read only;

--

alter table table_name read write;

在这之前,我们需要考虑通过一系列的权限了、安全控制Triggler了、只读表空间了、访问控制policy了等方法才能达到我们的read only目的.现在好了,一切变的如此轻松!


06 07, 2007
11g中对PL/SQL访问sequence的一个改进
作者 tomszrp 13:22 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

在Oracle 11g之前,熟悉pl/sql编程的朋友都知道,当在pl/sql 代码中访问
一个sequence的时候,一般的做法是,比如:
DECLARE v_n number;
BEGIN
SELECT Seq.Nextval INTO v_n FROM Dual;
....
END;

所以大家都觉得很烦琐,而且这么写有一定的性能上的开销,但是没办法,
那么好了,到了11g,这个问题Oracle开发者为你排忧了。

在11g中,重新修改了访问方法,不仅仅提高了运行效率而且在pl/sql中
的调用方法也变的非常简单,在11g中,你可以简单的这样处理:
DECLARE v_n NUMBER:=Seq.Nextval;
BEGIN
....
END;

当然了,对于访问Currval也是一样的.


03 07, 2007
这个也单独收费
作者 tomszrp 22:24 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

原文来至Kamus的BLOG

如果不是今天看到Fenng的给 Larry Ellison 的公开信,事关 AWR 与 ASH文章中提到Mark Brinsmead的这封公开信,我也不知道AWR/ADDM/ASH这样几乎完全内置在数据库中的功能也是需要额外收费的。

仔细查了一下Oracle® Database Licensing Information,果然如此,汗。

Command-Line APIs

Diagnostics Pack features can also be accessed by way of database server APIs and command-line interfaces:

* The DBMS_WORKLOAD_REPOSITORY package is part of this pack.
* The DBMS_ADVISOR package is part of this pack if you specify ADDM as the value of the advisor_name parameter, or if you specify for the value of the task_name parameter any value starting with the ADDM prefix.
* The V$ACTIVE_SESSION_HISTORY dynamic performance view is part of this pack.
* All data dictionary views beginning with the prefix DBA_HIST_ are part of this pack, along with their underlying tables.
* All data dictionary views with the prefix DBA_ADVISOR_ are part of this pack if queries to these views return rows with the value ADDM in the ADVISOR_NAME column or a value of ADDM* in the TASK_NAME column or the corresponding TASK_ID.
* The following reports found in the /rdbms/admin/ directory of the Oracle home directory are part of this pack: awrrpt.sql, awrrpti.sql, addmrtp.sql, addmrpti.sql, awrrpt.sql, awrrpti.sql, addmrpt.sql, addmrpti.sql, ashrpt.sql, ashrpti.sql, awrddrpt.sql, awrddrpi.sql, awrsqrpi.sql, awrsqrpt.sql.

即使作为Oracle的员工,恐怕我也得私下里支持一下这位DBA的提议。在公开信中回复的comment中包含“SIGNATORY”字样就表示电子签名了。 )

如果说awrrpt.sql这样的脚本在不购买Oracle Diagnostic Pack的license情况下不允许使用,倒也还能控制,但是连内置在数据库里面的毫无限制的性能视图都不允许去查询,这样的license确实有些离奇,我想没有人能控制住自己不敲下select …. from V$ACTIVE_SESSION_HISTORY吧。


03 07, 2007
如期完成第一部分功能
作者 tomszrp 22:07 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

到今天下午下班前,toms_tools 包完成了表空间自适应随机动态平衡分布功能(还不是特别如意,需要稍加修饰).

同时一并完成了相应的技术白皮书,算是没有虚度光阴,下班的同时,也让同事用上了,算上的够及时.^|^

好久不写pl/sql的东西了,在10g下写出来的东西,部署到9i上居然出了点小问题,还好只是一点小的瑕疵!

明天顺利的话,补充一下对index的处理部分!告一个段落!(找点时间灌点水,总想偷懒!^|^)

对了,好象效率上有点问题,明天优化优化(哈哈,优化,又是优化...,似乎玩Oracle永远会面对这个问题,这不,自己设计,设计开发的,再自己优化喽)

...


03 07, 2007
小有进度(toms_tools)
作者 tomszrp 20:15 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

到昨天下午下班,toms_tools 可以支持目前系统(应用)中涉及到的所有系统分区和应用分区类型了.

今天如果不出意外的话,完成表空间自适应部分.


01 07, 2007
稍做调整,支持基本的分区表(range)
作者 tomszrp 18:58 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

上午写出了基本结构,下午让铿锵在MSN因为undo出现坏块的问题耽误了一会儿,对base frame稍做改动,可以支持基本的分区表了(range)

支持分区表
1)按地区分区
SQL> create table test(
  2  region number(4) not null,
  3  oid    number(12) primary key,
  4  deal_date date default sysdate,
  5  flag   char(1) check(flag in('0','1','2'))
  6  )
  7  /

表已创建。

SQL> desc test
 名称           是否为空? 类型
 -------------- -------- -------------
 REGION         NOT NULL NUMBER(4)
 OID            NOT NULL NUMBER(12)
 DEAL_DATE               DATE
 FLAG                    CHAR(1)

SQL> 
SQL> exec toms_tool.get_create_tabl_sql;

PL/SQL procedure successfully completed

SQL> 
SQL> select sql 
     from source_sql 
     where name='TEST' 
     order by seq;

prompt create table study.test
create table study.test
(
  region number not null,
  oid number primary key,
  deal_date date default sysdate,
  flag char(1)  check(flag in('0','1','2')) 
)
partition by range(region)
( 
  partition p_530 values less than(531),
  partition p_531 values less than(532),
  partition p_532 values less than(533),
  partition p_533 values less than(534),
  partition p_534 values less than(535),
  partition p_535 values less than(536),
  partition p_536 values less than(537),
  partition p_537 values less than(538),
  partition p_538 values less than(539),
  partition p_539 values less than(540),
  partition p_543 values less than(544),
  partition p_546 values less than(547),
  partition p_631 values less than(632),
  partition p_632 values less than(633),
  partition p_633 values less than(634),
  partition p_634 values less than(635),
  partition p_635 values less than(636),
  partition p_999 values less than(1000)
) 

2)按月分区(date)
SQL> create table test(
  2  rec_date date);

表已创建。

SQL> 
SQL> exec toms_tool.get_create_tabl_sql;

PL/SQL procedure successfully completed

SQL> 
SQL> select sql 
     from source_sql 
     where name='TEST' 
     order by seq;

prompt create table study.test
create table study.test
(
  rec_date date 
)
partition by range(rec_date)
( 
  partition p_200707 values less than(to_date('20070801','yyyymmdd')),
  partition p_max    values less than(to_date('20370101','yyyymmdd'))
) 

01 07, 2007
toms_tools小试牛刀
作者 tomszrp 16:45 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天上午调试好了toms_tools的基本功能,可以读取建表的基本信息了。下面测试一下(我在家测试了很多种情况,脚本太多,就列举一个相对典型的情况)

SQL> create table test(
  2  a int not null,
  3  b number,
  4  c number(8,2),
  5  d char(1) check(d in ('0','1')),
  6  e varchar2(32),
  7  f date
  8  ,
  9  constraint pk_test primary key(b));

表已创建。

SQL> desc test
 名称      是否为空? 类型
 --------- -------- ---------------
 A         NOT NULL NUMBER(38)
 B         NOT NULL NUMBER
 C                  NUMBER(8,2)
 D                  CHAR(1)
 E                  VARCHAR2(32)
 F                  DATE


SQL> exec toms_tool.get_create_tabl_sql;

PL/SQL procedure successfully completed

SQL> 
SQL> select sql 
     from source_sql 
     where name='TEST' 
     order by seq;

SQL
-----------------------------------------
prompt create table study.test
create table study.test
(
  a number not null,
  b number primary key,
  c number(8,2),
  d char(1) check(d in ('0','1')) ,
  e varchar2(32),
  f date
)

10 rows selected

SQL> 

01 07, 2007
开发toms_tools维护工具包计划
作者 tomszrp 15:13 | Permalink 静态链接网址 | Comments 最新回复 (3) | Trackback 引用 (0) | PUB论剑

因工作需要,需要经常在多个系统中间同步/重构数据库对象结构,至少目前在几十多个生产库,N个培训库、N个测试、N个压力测试库、若干开发库中经常需要同步应用对象结构。

因为各个系统中的需要不完全一样,且目标对象多达几万/几十万个,所以传统的exp/imp,dbms_metadata工具等不能完全满足需要。

为了减轻维护工作压力,提高工作效率,提供可操作、可读性强、可编辑、傻瓜型的维护工具,特决定开发一个维护package,以生产或开发DB为baseline,根据预定义的规则(参照目标环境需要),自动生成目标环境需要的全部/部分数据库对象(应用)创建脚本

初步设想可以实现如下功能:

1)自动生成需要的建表/索引脚本

根据目标环境中的需要,可以建成分区或非分去的表(只参考baseline DB中的表基本结构即可)

2)自动生成分区表/索引的split脚本

3)自动生成所有的应用pl/sql 对象建立脚本

4)自动从开发baseline 中生成目标生产上需要发布的对象脚本!

可以直接提交维护DBA执行的脚本

其他功能想到了再说。

以上功能,计划采用Oracle的PL/SQL编写实现。

第一版本表结构支持的数据类型

char/nchar/varchar/varchar2/nvarchar2
number/integer
raw/long raw/blob
long
date
float
rowid/wrowid
timestamp/timestamp with time zone/timestamp with local time zone

目前应用中主要使用了上述几种数据类型,后续补充对其他数据类型的支持。


10 12, 2006
Data Pump Import速度问题之解决过程
作者 tomszrp 13:12 | Permalink 静态链接网址 | Comments 最新回复 (3) | Trackback 引用 (0) | PUB论剑

最初由Kamus发布

 查看全文
12 11, 2006
是福还是祸
作者 tomszrp 19:20 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天到eygle的站点(www.eygle.co)]上溜达,看到了他关于

Oracle11g已知的将要推出的新特性之一是-自动内存管理的简单介绍.

 查看全文

18 06, 2006
系统时间不正确导致Oracle无法OPEN
作者 tomszrp 21:22 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

iamagoodmaster:

突然停电,再开机,启动数据库就出现ORA-00600错误,详细如下:
——————————————————————
SQL*Plus: Release 9.2.0.6.0 - Production on Tue Jan 1 00:44:10 2002

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.
ORACLE instance started.

Total System Global Area 581506668 bytes
Fixed Size 452204 bytes
Variable Size 402653184 bytes
Database Buffers 167772160 bytes
Redo Buffers 10629120 bytes
Database mounted.
ORA-00600: internal error code, arguments: [2252], [1903], [579459841], [], [],
[], [], []
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
——————————————————————————

 查看全文
09 06, 2006
遭遇ORA-22856+BUG[2421054]
作者 tomszrp 14:02 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

昨天晚上系统优化,尝试修改一个已经compress的分区表,结果系统提示:

ORA-22856: cannot add columns to object tables

这个问题从来没遇过[只能说以前从没修改过压缩表的结构而已],开始以为自己连续工作了N个小时头大了。后来在自己本子上的库上测试也是这个问题,但在我本子上的另外一个10g的库中,测试是没有问题。因为工作的地方没有网络可上,所以当时猜测难道在9i的版本中不支持这么操作:不允许修改压缩对象的结构?

早上回家,在网上咨询了朋友,hrb_qiuyb告诉说是9i的一个bug[2421054]

刚才到metalink上查了一下,果然是这么回事:

 查看全文

30 05, 2006
在过程中动态使用临时表的问题
作者 tomszrp 12:33 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

这两天在论坛里,有不少人咨询在存储过程中创建、访问temporary 表的问题。

下面简单的写一个DEMO,供大家参考。

需要说明的是:如果在PL/SQL中动态创建表,并在后续的脚本中使用前面创建的表,那么要使用动态SQL来实现,否则系统编译时会报告ORA-00942:table or view does not exist的错误。

 查看全文
15 04, 2006
关于在触发器中操作便异表[最近咨询变异表的人很多]
作者 tomszrp 13:01 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
变异表就是当前被DML语句修改的表,对trigger来说,变异表就是trigger在其上
定义的表。需要明确的是trigger中SQL语句不能进行如下操作:
1)读或修改触发语句的任何变异表,其中包括触发表本身
2)读或修改触发表的约束表中的主关键字,唯一关键字和外部关键字列。除此之外的其他列都可以修改。

以上2条限制适合所有的行级trigger.
 查看全文
14 04, 2006
ORA-12704: 字符集不匹配
作者 tomszrp 16:22 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

前两天在PUB里看到的。在此收集[谢过wenaini]

 查看全文
11 04, 2006
调用dbms_system发生PLS-00201错误解决
作者 tomszrp 12:58 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天在论坛里看到这样一个问题
SQL> exec dbms_system.set_sql_trace_in_session(11,3352,true);
BEGIN dbms_system.set_sql_trace_in_session(11,3352,true); END;

 查看全文
10 04, 2006
巧用随机数解决数学问题
作者 tomszrp 20:46 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天看到有朋友问如何用pl/sql解决如下怪异的问题

T=5a+7b-2c-4d+1
a的范围:40到60
b.......:10到35
c........:8到24
d........:6到20
且a+b+c+d=100

求T:提示用SQL相关语句查询,谢谢

 查看全文
09 04, 2006
IBM UNIX服务器的逻辑分区
作者 tomszrp 18:19 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

关键词:
IBM AIX UNIX LPAR PPAR 分区 HMC
摘 要:
本文介绍了IBM UNIX服务器物理分区和逻辑分区的概念以及LPAR的实现。内容包括:
1、 为什么服务器需要分区
2、 什么是物理分区(PPAR)和逻辑分区(LPAR)
3、 IBM pSeries的逻辑分区和动态逻辑分区

原文连接:http://www.itpub.net/473989.html


09 04, 2006
如何挂起一个进程
作者 tomszrp 10:51 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

Have you ever had to kill a long-running batch process because it had overrun its window and was
affecting online performance? Well, next time, think again, because there may be a better solution.
You may be able to suspend such a process instead of killing it.

 查看全文
01 04, 2006
windows下如何用批处理脚本访问Oracle
作者 tomszrp 11:36 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

给大家提供一个最简单的样例吧:

 查看全文
05 03, 2006
关于复合分区索引状态的研究
作者 tomszrp 12:52 | Permalink 静态链接网址 | Comments 最新回复 (2) | Trackback 引用 (0) | PUB论剑

今天看到有网友问了关于符复合区索引状态的探索,引起了兴趣,因为到目前为止,
我用到的复合分区的情况还是比较少。将来说不定哪天就用上了,正好今天休息,就
测试了一把。欢迎大家扔砖头

 查看全文
05 03, 2006
因为违反主键约束而导致表发生行级锁
作者 tomszrp 09:54 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

因为违反主键约束而导致表发生行级锁

这是一个很普通的现象,一般人可能都不大以为然,然而在一些并发操作很高的OLTP应用系统中,当多个session 操作同一个表时[仅针对INSERT来说],如果其中一个session在insert 完毕,但
缺迟迟不能COMMIT或ROLLBACK。而另外的进程因为重处理或业务的需要,需要插入的同样的记录到该表时,就会产生row lock锁等待,一般人看上去就象系统HANG在那里一样,呵呵。

先面是测试过程

 查看全文
03 03, 2006
再论 Oracle 保留字
作者 tomszrp 22:57 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

昨天晚上,在网上看到有人写了段PL/SQL程序,但死活编译不过,怀疑是使用了Oracle的保留字的缘故,我到数据库一查,果然是个保留字,难怪编译不过了。

呵呵。

今天闲着没事干,就对这个问题进行了研究,发现Oracle也不是多么的坚强。

测试过程如下:
SQL> create table log
( region number(3),
cycle number(6),
nettype char(1),
fee number(8,2)
);

 查看全文
02 03, 2006
还是数据类型转换的问题
作者 tomszrp 22:59 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天早上同事问了我一个问题:
“为什么我的程序除了XXX和XXX 2个地市,其他的都能正确处理,手工执行可以,一放到过程里就不行了”

我说:报什么错误
他说:ORA-01722: invalid number

 查看全文
02 03, 2006
我改过的数据为什么不见了
作者 tomszrp 18:03 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

案例场景:

领导A:"小B,你今天下午帮忙把某些用户的状态和部分属性给修改一下"
小B: "哦,好的"
。。。
于是小B开始干活了。

这时,员工小C因为另外的BUG需要,也要调整一些数据,因为C要修改的数据涉及的业务广,
其中就包含了领导交代给小B修改的这个表,只不过正好包含了小B要改的一个字段。

过了30分钟。领导来了。

领导A:"小B,你怎么干活的,这么点小事,到现在还没改好,用户又投诉了"
小B:(很吃惊的样子)”我已经改了啊。不信看看“

于是小B开始查数据库,select出来一看,真的还是没变。
小B有点紧张了:”奇怪,我明明做了,为什么没变啊“

领导:(生气了)没做就是没做,别给我找理由了,这个月考核你是D了。小样,
不信我收拾不了你。

小B: 呜~~~~

那么到底是领导错了还是小B错了。想知道答案吗?请继续往下看

 查看全文
12 02, 2006
将您的 Access 数据库移植到 Oracle(转至Oracle.com)
作者 tomszrp 18:47 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

将您的 Access 数据库移植到 Oracle


从现有系统向 Oracle 数据库的移植过程可能令人畏惧,尤其是现有数据库与 Oracle 数据库结构具有很少的相似性或者没有相似性的时。在本技术说明中,我将对比从 Microsoft Access 移植到 Oracle 的两种技术:使用 Microsoft Access 中的实用程序以及某些 DOS 专用批处理文件的“原始”方法,以及使用 Oracle Migration Workbench (OMW) 工具的“改进”方法。

手动方法

第一种技术包括两个阶段。第一阶段是将 Access 数据库转换为 Oracle 数据库。只有当 Access 作为前端(如表单和报表) — 并且 Oracle 数据库继续作为后端的时候才使用第二阶段。后者提供了一种在即席查询基础上将 Access 数据库备份到 Oracle 的策略。还可以建立一个服务,使这一过程定期自动地运行。

 查看全文
05 02, 2006
一条奇妙的SQL语句,解决了我多日苦思的难题
作者 tomszrp 18:52 | Permalink 静态链接网址 | Comments 最新回复 (1) | Trackback 引用 (0) | PUB论剑

前段时间,用户问了我一个SQL语句,要求实现如下功能:

1)表结构信息
SQL> desc get_info
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
SEQNO NUMBER
DATE_STR VARCHAR2(8)
TIME_STR VARCHAR2(8)
VALUE NUMBER

 查看全文
22 01, 2006
delete 和 truncate的异同总结
作者 tomszrp 18:53 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

一、共同点
都可以清除一个表中的数据记录。

二、不同点

1)delete是DML操作,而truncate是DDL操。也就是说delete产生undo信息,而truncate不产生或产生很少的的undo信息。
这样就决定了在删除记录时的速度truncate要比delete快的多

2)delete可以带条件删除部分记录,而truncate只能删除整个表或整个分区

3)delete 并不调整HWM,而truncate调整,这个对以后全表查询有影响

4)delete操作可以通过rollback命令恢复,而truncate操作一出错就只有作recover。

备注:以上观点针对Oracle 10g以前版本。在Oracle 10g中,恢复操作可以参阅flashback部分的介绍。


18 12, 2005
ORACLE 9I FOR AIX 5L 的安装
作者 tomszrp 22:01 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

第一节:安装
注意:因为ORACLE 9I为64位,所以安装的AIX平台也必须是64位。如果不是必须要重新安装或使用连接库函数将其改为64位
To change to 64 bit multi-processor mode:
# ln -sf /usr/lib/boot/unix_64 /unix
# ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix
# bosboot -ad /dev/ipldevice
# shutdown -r
一、确认系统环境
1、主机环境
??机型:IBM P630
??CPU :1000MHz
??MEM :1G (MIN 512M)
$ /usr/sbin/lsattr -E -l sys0 -a realmem
realmem 12582912 Amount of usable physical memory in Kbytes False
??/tmp:1000M (MIN 500M)
$df -k /tmp
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd3 655360 603088 8% 69 1% /tmp
??SWAP:6G (一般是2倍于MEM,但因为我们的内存已经很大了,所以没有按一般规
则)
$ /usr/sbin/lsps -a
Page Space Physical Volume Volume
Group Size %Used Active Auto Type
hd6 hdisk0 rootvg 6144MB 1 yes yes
lv
??/oracle:38G (MIN 3.5G,本目录用于安装软件、存放source以及oracle9用户
的根目录所在)
$ df -k /oracle

 查看全文
17 12, 2005
在触发器中调用JAVA存储过程
作者 tomszrp 19:21 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
This tip comes from Jeffrey Tarnok and Sai Casulas of Technical Resource Connection/Perot Systems in Tampa, Florida.
Triggers are often employed to handle pre and post-data manipulation language (DML) processing and can be used to facilitate complex constraint requirements. Oracle supports the use of Java in the database as a non-proprietary, powerful programming language. Coupling triggers and Java-stored procedures can satisfy platform-independent database programming policies and often-complicated application-related DML processing requirements.
The example below contains a trigger that utilizes a call to a Java-stored procedure to enforce a primary key constraint. The sample is a simplified example of how Java-stored procedures can be employed by triggers to facilitate constraint or application requirements. An insert before trigger calls the Java-stored procedure to verify the record being inserted is unique. The Java-stored procedure returns the verification result. If the record already exists, the trigger raises and outputs the exception.
Included in the example is the Java program source, the DDL to create and populate a customer table, the DDL to create the call spec required to access the class, and the DDL to create the trigger. Also included is a UNIX korn shell script that can be used to load the class into the database and call the DDL script.
An Oracle 8.1.7 database running on Solaris 2.6 was used for the example but it should work in any Oracle 8i-version database running on Unix or NT platforms.
Steps:
1) Compile CustTr.java
2) Execute the deploy_jproc_samp.ksh script: deploy_jproc_samp.ksh user/password
3) Test the example by selecting the call spec function from dual:
Select jproc.InsFun(1,'Test') from dual;
You can also test the trigger by inserting a duplicate record:
Insert into customer values(1,'Test');
This is the CustTr.java source:
 查看全文
17 12, 2005
生成权限授予层次关系的脚本
作者 tomszrp 19:20 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
This tip comes from Kirill Richine, DBA in Richmond, VA.
Oftentimes a DBA needs to list all system, object, and role privileges granted to a certain grantee. Privileges are granted recursively, via multiple layers of roles. Such privilege grants can be visualized as a grant tree.
Conversely, a privilege may be granted to multiple grantees, also via multiple layers of roles. This too can be seen as a tree-like structure.
The script below provides a mechanism to depth-first traverse and list the contents of these trees. The first block takes a grantee as argument and lists the grant tree for it. The second block takes a privilege as argument and lists the grantee tree for it.
The script works in sql*plus for Oracle 7.3.4 and up.
The script can be modified to handle any hierarchical structures to provide efficient traversal tool.
 查看全文
13 11, 2005
Oracle性能调优:块尺寸和索引树的结构(转)
作者 tomszrp 19:29 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

关于Oracle索引树的结构以及它们对Oracle性能调优是否重要存在大量的、激烈的争论,而且已经有很多文章试图来描述这些重要的Oracle性能工具的内部工作机制。关于这个论题也出现了一些新书,例如由“国际Oracle用户组”(IOUG)主席Kim Floss所著的《Oracle索引管理秘诀》和《Oracle SQL 性能调优和“基于代价的优化器”内幕》。

 查看全文
01 07, 2005
索引的分类
作者 tomszrp 19:28 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

逻辑上:
Single column 单行索引
Concatenated 多行索引
Unique 唯一索引
NonUnique 非唯一索引
Function-based函数索引
Domain 域索引
物理上:
Partitioned 分区索引
NonPartitioned 非分区索引
B-tree:
Normal 正常型B树
Rever Key 反转型B树
Bitmap 位图索引
索引结构:
B-tree:
适合与大量的增、删、改(OLTP);
不能用包含OR操作符的查询;
适合高基数的列(唯一值多)
典型的树状结构;
每个结点都是数据块;
大多都是物理上一层、两层或三层不定,逻辑上三层;
叶子块数据是排序的,从左向右递增;
在分支块和根块中放的是索引的范围;
Bitmap:
适合与决策支持系统;
做UPDATE代价非常高;
非常适合OR操作符的查询;
基数比较少的时候才能建位图索引;
树型结构:
索引头
开始ROWID,结束ROWID(先列出索引的最大范围)
BITMAP
每一个BIT对应着一个ROWID,它的值是1还是0,如果是1,表示着BIT对应的ROWID有值;

01 07, 2005
AIX下如何查看内存信息
作者 tomszrp 12:34 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

方法一:查看物理内存的大小

    #bootinfo -r
方法二:

    使用命令# lsdev -Cc memory
    查看配置的物理内存设备,下面为其输出示例:
    yy1a /# lsdev -Cc memory
         L2cache0 Available L2 Cache
         mem0 Available Memory
    再使用命令# lsattr -El mem0
    输出如下
    yy1a /# lsattr -El mem0
    goodsize 32768 Amount of usable physical memory in Mbytes False
    size 32768 Total amount of physical memory in Mbytes False
    此例说明机器的物理内存为32G。如果前面lsdev的输出中有设备名 mem1,则使用同样的命令查看其对应的大小并依此类推。


方法三:

yy1a /# prtconf |grep "Memory Size"
Memory Size: 32768 MB
Good Memory Size: 32768 MB
方法四:

svmon -G
svmon">root@m2a/etc>svmon -G
size inuse free pin virtual
memory 4194304 1088794 3105510 274650 690272
pg space 2097152 3775

work pers clnt lpage
pin 274650 0 0 0
in use 690290 257951 140553 0
root@m2a/etc>

方法五: 使用 topas 、nmon


26 04, 2005
关于数据库管理员的验证小结
作者 tomszrp 19:27 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

今天做了一下整理,修正原来的部分错别字,并调整了版面!

 查看全文

25 04, 2005
Oracle9i中与日期有关知识的学习小结
作者 tomszrp 22:04 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

1)时区的设置和修改

2)缺省日期格式的说明

3)常用date函数的用法

4)datetime函数的用法

5)常见日期格式

下载阅读

http://blog.itpub.net/get/3378/Oracle_about_date_detail.pdf


23 04, 2005
Oracle树结构查询(引用)
作者 tomszrp 22:06 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

ORACLE是一个关系数据库管理系统,它用表的形式组织数据,在某些表中的数据还呈现出树型结构的联系。例如,我们现在讨论雇员信息表EMP,其中含有雇员编号(EMPNO和经理(MGR)两例,通过这两列反映出来的就是雇员之间领导和被领导的关系。有些雇员领导另一些雇员,有些雇员被领导,还有些雇员领导一些人又被别人领导,他们之间的这种关系就是一种树结构,图1.1表示了EMP表雇员间的这种树结构。

 查看全文
23 04, 2005
默认日期格式--Oracle9i
作者 tomszrp 22:05 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

ORACLE9I之前, 日期格式的数据类型默认格式为“DD-MON-YY”,而在ORACLE9I中变为“DD-MON-RR”。 那么这个“RR”究竟代表什么意思呢?

查阅了相关资料发现,原来Oracle为了解决千年问题, 而引入了RR日期型格式。

 查看全文
18 04, 2005
人民币与数字之间转换函数(Oracle)
作者 tomszrp 11:59 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

/*
函数名称: CONVERT_MONEY
用 于: 将以分为单位输入的数值转换为大写汉字形式
注 释: 当转换后的汉字以分结尾时,不加“整”,当以角或元结尾时加“整”,这符合银行的规定。
数字金额凡是中间出现0的,必须转为大写的“零”,连续多个0时只转为一个“零”字,
结尾出现0时要加“整”,结尾不是0时不加“整”,这与前面的规定是一致的。
由于圆是货币单位,所以在多于1元钱时,圆是必须出现的。但是,万佰等是数字单位,有
时可能不出现。

*/
CREATE OR REPLACE FUNCTION CONVERT_MONEY(INPUT_NBR IN NUMBER DEFAULT 0)

RETURN VARCHAR2 IS
INPUT_NBR_BAK NUMBER(20); /*用于接收输入参数 INPUT_NBR */
NUM_CHARACTER VARCHAR2(20) := '零壹贰叁肆伍陆柒捌玖';
UNIT_CHARACTER VARCHAR2(40) := '分角圆拾佰仟万拾佰仟亿拾佰仟万拾佰仟亿';
OUTPUT_STRING VARCHAR2(100):= '';
REMAIN_NBR NUMBER(20);
BIT_NUM NUMBER(20); /*每一位上的数字*/
BIT_UNIT VARCHAR2(2); /*每一位所对的单位*/
BIT_INDIC NUMBER(1) :=0; /*每一位的数字是否为0,0表示为0,1表示不为0*/
I NUMBER(2) :=0; /*循环次数,索引变量从0开始*/
SPE_UNIT VARCHAR2(2):='A';/*特殊位,包括万和亿,表示该亿汉字是否已写入结果字串*/
SIGN_INDIC VARCHAR2(1); /*用于标志数值符号:0为正,1为负*/

 查看全文
15 04, 2005
如何开启/关闭归档
作者 tomszrp 12:03 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
1)单机模式下

如果开启归档,请保证

log_archive_start=true开启自动归档,否则只能手工归档,如果是关闭了归档,则设置该参数为false.

log_archive_dest =archivelog存放路径---归档日志存放路径
log_archive_format =CX%TS%S.ARC ---归档日志文件名格式


注意:如果是OPS/RAC环境,需要先把parallel_server = true注释掉,然后执行如下步骤,最后用这个参数重新启动
1、开启归档
a. 关闭数据库shutdown immediate
b. startup mount
c. alter database archivelog
d. alter database opne
2、禁止归档
a. 关闭数据库shutdown immediate
b. startup mount
c. alter database noarchivelog
d. alter database open
归档信息可以通过如下语句查看
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination E:oracleora92databasearchive
Oldest online log sequence 131
Next log sequence to archive 133
Current log sequence 133

 

   2)RAC模式下

   1.关闭所有的instance
   2.在节点1上设置以下参数,如果使用spfile就先生成pfile再修改
    CLUSTER_DATABASE=FALSE.
    log_archive_dest=归档路径
    log_archive_start=true
    log_archive_format=归档文件格式
   3. 以exclusive模式启动数据库
    SQL> startup mount exclusive pfile=‘xxxxxx’.
   4. 启动归档模式
    SQL> Alter database archivelog
   5.打开数据库
    SQL> alter database open
   6.关闭数据库并修改初始化参数
    SQL> shutdown immediate
    CLUSTER_DATABASE=TRUE
   7.启动所有的instance,记得先生成spfile
   8.核对归档,模式是否启动
    SQL> archive log list

 

 

相关数据字典

V$ARCHIVED_LOG

V$ARCHIVE_DEST

V$LOG_HISTORY

V$DATABASE


14 04, 2005
aix常见问答
作者 tomszrp 12:07 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

用feprom_update升级Firmware 2002-07-24
CHRPSystems系统启动过程的LEDE1DC报错提示 2002-07-24
怎样在AIX5.1中建立热后备(hotspare)磁盘? 2002-07-24
如何让非root用户有权限执行sar命令 2002-07-24
使用errpt命令,产生0315-171错误 2002-07-24
普通用户执行su命令时产生错误:Authenticationdenied. 2002-07-24
查找文件或命令对应的文件集 2002-07-24
AIX5L新特性(一):如何确认CPU的主频? 2002-07-24
如何记录ftplog? 2002-07-24
目前哪些RS/6000支持逻辑分区(LPAR)? 2002-07-11
在移植安装(Migrationinstallation)中都有那些文件和数据保留下来? 2002-07-11
如何在保留安装(Preservationinstallation)方式下自定义需要保留的文件? 2002-07-11
PTF与APAR的区别? 2002-07-11
将man命令查看的内容转换成普通文本文件 2002-07-11
查看bootlog 2002-07-11
inetd.conf文件的恢复 2002-07-11
如何立刻断掉一个已经login的用户? 2002-07-11
使用errdemon客户化系统错误日志文件 2002-07-11
什么版本的Oracle数据库支持AIX5.1 2002-07-11
IBMpSeries和RS/6000哪些型号可以安装SuSElinux? 2002-07-11
如何监控裸设备I/O? 2002-07-11
在AIX上安装RPM格式软件包 2002-07-11
gated 进程介绍和应用 2002-03-25
如何处理 mountd 和 nfsd 无法正常启动 2002-03-25
如何在图形登录和命令行登录方式见切换? 2002-01-29
如何阻止某些用户远程登录,telnet,rlogin? 2002-01-29
如何拒绝某些用户的ftp访问? 2002-01-29
如何查看某用户共启动了多少进程? 2002-01-29
如何在清理/tmp文件系统时找到过大的文件? 2002-01-29
如何限制某用户在特定 pty 的访问。 2002-01-28
如何打开锁死的帐户 2002-01-28
.....

 查看全文
29 03, 2005
用多种方法实现表中重复字段的唯一查询
作者 tomszrp 12:14 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
http://blog.itpub.net/resource/3378/4647
31 01, 2005
请教distinct与unique的异同
作者 tomszrp 12:23 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

各位大虾们, 现在有一个疑惑,就不是不太清楚distinct和unique到底有什么不同,他们有什么各自的特殊性?

今有:

SQL> desc zrp
名称 是否为空? 类型
----------------------------------------- -------- ---------------
MSISDN NOT NULL CHAR(9)
USERTYPE CHAR(1)
AREACODE VARCHAR2(4)

SQL> select count(distinct(areacode)) from toms_zhang;

2

SQL> select count(distinct(areacode)) from toms_zhang;

2

他们得到的结果是一样,但我想知道他们有什么不同?

请各位发表高见.

 查看全文
31 01, 2005
dbms_job不能自动执行
作者 tomszrp 12:22 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

create or replace procedure test_p is
begin
insert into test values (9, 10, sysdate);
commit;
end test_p;

begin
sys.dbms_job.submit(job => :job,
what => 'gdwz.test_p;',
next_date => to_date('26-01-2005 16:56:26', 'dd-mm-yyyy hh24:mi:ss'),
interval => 'sysdate+(10/(24*60*60))');
commit;
end;
/
手工可以执行这个job。但系统始终不能自动执行。这是为什么呢?
版本是Enterprise Edition Release 9.0.1.1.1

 查看全文
31 01, 2005
merge的问题,太郁闷了,帮帮我
作者 tomszrp 12:21 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
merge的问题,太郁闷了,帮帮我

为什么总是报错

我的表结构为
create table mm(id number(10));
create table mn(id number(10));
insert into mm values(11);
insert into mn values(12);
merge into mn a
using mm b
on(a.id=b.id)
when matched then
update set a.id=b.id
when not matched then
insert values(b.id)

错误提示:ERROR 位于第 3 行:
ORA-00904: 无效列名
这是为什么?

 查看全文
27 01, 2005
一个DB link NAME的问题
作者 tomszrp 12:26 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

各位:

我的数据库(Oracle9.0.1)+WINxp

我创建了一个db_link以后,发现名字变了。请问是怎么回事?

-----------------------------------------------------------------------------------------
SQL>create public database link my_link connect to test identified by test using 'TESTDB';
数据库链接已创建。

SQL>
SQL>select * from test.oper_dict_dict@my_link;
.....
这个时候没有问题。
SQL>desc test.oper_dict_dict@my_link;
ERROR:
ORA-02084: 数据库名不全


这时,我通过查看
SQL> select * from all_db_links;
PUBLIC
MY_LINK.US.ORACLE.COM
TEST
TESTDB
25-1月 -05
发现DB LINK的名字后面多了些东西。然后再试
SQL>desc test.oper_dict_dict@MY_LINK.US.ORACLE.COM;
。。。。

就没有问题了。

-------------------------------------------------------------------------------------------------------

我的疑问: DB_LINK的名字怎么多了一部分出来,那部分东西是在哪里设置的,如何限制他们。

谢谢大家。

 查看全文
27 01, 2005
在LINUX数据库上修改了tnsnames.ora后,需要重启数据库吗?
作者 tomszrp 12:25 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

在LINUX数据库上修改了tnsnames.ora后,需要重启数据库吗?

在LINUX数据库上修改了tnsnames.ora,增加了一条TNS协议,但是建了数据库远程链接仍不起作用,需要重启数据库才能生效吗?

不需要重新启动

实验
1)启动数据库ora9.0.1

2)编辑tnsnames.ora,增加
testdblk =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.19.11.11)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora9)
)
)

保存退出。

3)在SQLPLUS中

sql>create public database link link_ora9 connect to testuser identified by testuser using testdblk;

数据库链接已创建
4)select * from testuser.oper_trace_file@link_ora9;
000000yw 20050120029260 I 20-1月 -05
000000yw 20080101000102 06 A 20-1月 -05
000000yw 20050120029260 O 20-1月 -05
000000yw 20050121029480 I 21-1月 -05
000000yw 20050121029480 O 21-1月 -05
....

 查看全文
23 12, 2004
关于表空间的问题
作者 tomszrp 12:27 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

各位版主、大侠们:

有个问题一直困饶着我,就是在Oracle9i中关于表空间的管理方式。

1)如果指定extent manangement local,而不指定uniform size 的话,那缺省的extent大小取决于什么?

注释 :我的数据库配置参数db_block_size=4k,查看user_tablespaces 发现:
initial_extent, next_extent分别如下
65536

2)如果指定extent manangement local,同时指定uniform size 的话,此时的initial_extent和next_extent都等于uniform size的大小。

3)如果指定extent manangement dictionary 不再指定default storage的话,那么缺省的initial_extent和next_extent分别为:

SQL> create tablespace user2 datafile 'd:oracleoradataora9 user2.dbf' size 10m extent management dictionary
表空间已创建。

SQL> select initial_extent,next_extent from user_tablespaces where tablespace_name='USER2';

INITIAL_EXTENT NEXT_EXTENT
-------------- -----------
20480 20480

4)如果指定extent manangement dictionary ,同时指定default storage(initial 128k next 128k)的话,就是用指定值。


5)还有一个问题,就是如果extent manangement local的话,就不能再指定default storage了?

SQL> l
1 create tablespace user2 datafile 'd:oracleoradataora9user2.dbf' size 10m
2* extent management local default storage(initial 128k next 128k)
SQL> /
create tablespace user2 datafile 'd:oracleoradataora9user2.dbf' size 10m
*
ERROR 位于第 1 行:
ORA-25143: 默认存储子句与分配策略不兼容


----------------------------------------------------------------------------------------

各位请发表高见,期待中~~~~~~~~~~~

 查看全文
18 12, 2004
急!oracle 9i里怎么修改init文件里的参数?
作者 tomszrp 12:28 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
Re: 急!oracle 9i里怎么修改init文件里的参数?

quote:
最初由 bengsui 发布
oracle 9i里怎么修改init文件里的参数?


1)如果没有创建spfile,则可以shutdown数据库后,编辑initSID.ora文件,设置你需要的参数。然后startup

2)如果已经创建了spfile,则可以在sql*plus中直接修改

alter system set parameter=valu scope=both|memory|spfile

如果不明白再聊 查看全文
15 12, 2004
isqlplus中不能运行pl/sql吗?
作者 tomszrp 12:29 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑
isqlplus中不能运行pl/sql吗?为什么运行就不错

写好的pl/sql块,在sql*plus中运行通过,但在isqlpls中却运行不出来,若是有则还带有乱码,难道isqlplus不能运行pl/sql块吗

 查看全文
13 12, 2004
关于开启归档的疑问
作者 tomszrp 12:30 | Permalink 静态链接网址 | Comments 最新回复 (0) | Trackback 引用 (0) | PUB论剑

在初始化参数文件中设置:
log_archive_start =TRUE
log_archive_dest =archivelog存放路径
log_archive_format =CX%TS%S.ARC

shutdown

startup pfile='完整路径的初始化参数文件名'

参阅:http://www.itpub.net/316574.html


博客日历
« 三月 2010 »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
搜索
最新发表
文章分类
文章归档
网站链接
新闻聚合