Make table readonly in Oracle11g

一直以来总有人问,能够将Oracle数据库中的表设置成只读吗?在Oracle11g之前回答是,不能。HJR甚至写过一篇完整的文章来阐述这个问题。

Oracle11g终于带来了这个新特性,设置表为Readonly,简单的一个命令而已。

SQL> CREATE TABLE “KAMUS”.”T1″ ( “N” NUMBER);

Table created

Executed in 0.047 seconds

SQL> alter table t1 read only;

Table altered

Executed in 0.125 seconds

SQL> insert into t1 values(1);

insert into t1 values(1)

ORA-12081: update operation not allowed on table “KAMUS”.”T1″

SQL> alter table t1 read write;

Table altered

Executed in 0.015 seconds

SQL> insert into t1 values(1);

1 row inserted

Executed in 0 seconds

Oracle一直在各个细节上不断地改善着,这是个值得信赖和继续投入热爱的产品。

Oracle11g for Windows ADRCI Issue

ADRCI (ADR Command Interpreter) 无疑是DBA在11g中管理数据库跟以前最不一样的地方,当然其实本质上没什么不一样,只是一个崭新的工具进入DBA的日常工作总是让人感到很有兴趣。

但是Windows平台下的ADRCI却有个小陷阱,show alert恐怕是进入ADRCI命令行提示符下大多数DBA第一个会敲上去看一看的命令吧。

D:\Temp>adrci

ADRCI: Release 11.1.0.6.0 – Beta on Sat Nov 17 20:51:49 2007

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

ADR base = “d:\oracle”
adrci> show alert

Choose the alert log from the following homes to view:

1: diag\rdbms\orcl11g\orcl11g
2: diag\tnslsnr\leyzhang-cn\listener
Q: to quit

Please select option: 1
Output the results to file: c:\docume~1\leyzhang\locals~1\temp\alert_3108_2324_o
rcl11g_1.ado
‘vi’ is not recognized as an internal or external command,
operable program or batch file.

Please select option:

在windows平台下show alert仍然试图去调用vi命令,而很明显vi并不存在于windows操作系统中,因此show alert命令失败。

Ricky,我知道你是测试Solaris平台下11g的,那也谏言一下,在Windows平台下还是不应该默认去调用vi的吧。。。当然,这不是大问题,毕竟,show alert -tail还是可以用的,呵呵。

解决方法:
在执行adrci之前先设置EDITOR环境变量,比如设置成notepad。
set EDITOR=notepad

备注:
如果想在Windows下使用一系列UNIX下的命令,可以安装MKS Toolkit,很好用的一套程序,包括vi,ls,tail,touch,cat等等。

Update@2008-12-12

如果在show alert -tail之后,遇到以下错误。

adrci> show alert -tail
DIA-48449: Tail alert can only apply to single ADR home

则需要先set home,比如:
adrci> show home
ADR Homes:
diag\clients\user_kenneth_zhang\host_366275074_11
diag\clients\user_system\host_366275074_11
diag\rdbms\orcl11g\orcl11g
diag\tnslsnr\prcsgil00066\listener
adrci> set home diag\rdbms\orcl11g\orcl11g
adrci> show alert -tail
2008-12-12 14:44:33.456000 +08:00
Starting background process SMCO
FBDA started with pid=7, OS id=4212
SMCO started with pid=18, OS id=3084
2008-12-12 14:44:34.628000 +08:00
replication_dependency_tracking turned off (no async multimaster replication fou
nd)
2008-12-12 14:44:37.425000 +08:00
Starting background process QMNC
QMNC started with pid=20, OS id=3412
2008-12-12 14:44:55.974000 +08:00
db_recovery_file_dest_size of 4096 MB is 3.91% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
2008-12-12 14:45:28.882000 +08:00
Completed: ALTER DATABASE OPEN
adrci>

Oracle11g默认目录结构

Oracle11g到现在为止应该算是正式发布了,基本上主流的操作系统平台版本都已经可以下载了。

在自己的机器上安装了一套for Windows 32bit的版本,在Windows平台下安装Oracle一如既往的简单和流畅,安装完软件,DBCA创建数据库,之后让我们来看一下Oracle11g默认的目录结构。

D:\oracle>dir
Volume in drive D is Tools
Volume Serial Number is 6317-CEA9

Directory of D:\oracle

2007-11-17 20:05

.
2007-11-17 20:05 ..
2007-11-17 20:05 admin
2007-11-17 19:55 cfgtoollogs
2007-11-17 19:50 diag
2007-11-17 20:05 flash_recovery_area
2007-11-17 20:05 oradata
2007-11-17 19:38 product
0 File(s) 0 bytes
8 Dir(s) 14,540,394,496 bytes free

admin
目前存放创建数据库的脚本,以前的alertlog已经不在这个地方了。

cfgtoollogs
下面分了目录分别存放当运行dbca,dbua,emca,netca等图形化配置程序时的log。

diag
是一个重组之后的目录,详细看一下其中的子目录,基本上Oracle每个组件都有了自己单独的目录,在Oracle10g中我们一直诟病的log文件散放在四处的问题终于得到解决,无论是asm还是crs还是rdbms,所有组件需要被用来诊断的log文件都存放在了这个新的目录下。

D:\oracle\diag>dir
Volume in drive D is Tools
Volume Serial Number is 6317-CEA9

Directory of D:\oracle\diag

2007-11-17 19:50

.
2007-11-17 19:50 ..
2007-11-17 19:50 asm
2007-11-17 19:50 clients
2007-11-17 19:50 crs
2007-11-17 19:50 diagtool
2007-11-17 19:50 lsnrctl
2007-11-17 19:50 netcman
2007-11-17 19:50 ofm
2007-11-17 20:05 rdbms
2007-11-17 19:50 tnslsnr
0 File(s) 0 bytes
11 Dir(s) 14,534,791,168 bytes free

flash_recovery_area
在Oracle10g中就已经存在,没什么多说的。

oradata
存放数据文件。

product
仍然是Oracle RDBMS的软件存放目录。