Archive for 七月, 2008

关于sql.bsq和dcore.bsq

星期四, 七月 31st, 2008

11g之前想查一些数据字典表的注释我都是通过查询sql.bsq来找到。 到了11g之后,这个文件变成了一个总控文件了,真正的数据字典表信息都被放到dcore.bsq里面。 ><

11g新特性——添加具有默认值的列(续1)

星期四, 七月 31st, 2008

经过我的深入测试发现11g中的添加具有默认值的列并没有那么简单。上一篇文章中有很多的问题,接下来做些深入的思考。 测试一:发现ecol$ sunwg>create table test1 pctfree 0 as select * from dba_objects; Table created. Elapsed: 00:00:00.18 sunwg>ALTER table test1 add col_1 varchar2(10) default 'aa'; Table altered. Elapsed: 00:00:00.06 sunwg>alter SESSION SET sql_trace = TRUE; Session altered. sunwg>select * FROM test1 WHERE rownum<2; sunwg>alter SESSION SET sql_trace = FALSE; Session altered. 查找trace文件,我们有了个惊奇的发现,在select的trace文件中多了一个系统表ecol$。这个表就是11g这个新特性的底层支持。 这个ecol$在10g中是不存在的。让我们看看这个表的结构。 sys>desc ecol$ Name Null? Type ------------------------- -------- ------------ TABOBJ# NUMBER COLNUM NUMBER BINARYDEFVAL BLOB sys@SWORD>select * from ecol$; TABOBJ# COLNUM ...

11g新特性——添加具有默认值的列

星期四, 七月 31st, 2008

不知道你是否还记得,为了给一个有几千万或者几亿的表增加一个有默认值的列,你苦苦的在计算机面前无聊的等待。 这一切在11g中完全被改变了,添加具有默认值的列变成一件快乐的事情。 10g: SQL> create table test as   2  select a.*   3  from dba_objects a,   4  dba_users b   5  where rownum< 1000000; 表已创建。 SQL> set timing on SQL> alter table test add col_a number default 0; 表已更改。 已用时间:  00: 05: 26.40 11g: sunwg>create table test as   2  select a.*   3  from dba_objects a,   4  dba_users b   5  where rownum<1000000; Table created. sunwg>set ...

ora-30926

星期三, 七月 30th, 2008

在使用merge更新数据的时候,有时会遇到ora-30926的错误。一般就是源表中存在重复记录,导致不能正确的进行更新操作。 SQL>create table sunwg1 (id number,name varchar2(10)); SQL>create table sunwg2 (id number,name varchar2(10)); SQL>insert into sunwg1 values(1,'a'); SQL>commit; 提交完成。 SQL>insert into sunwg2 values(1,'aa'); SQL>insert into sunwg2 values(1,'bb'); SQL>commit; 提交完成。 SQL> MERGE INTO sunwg1 a   2     USING sunwg2 b   3           ON (a.id = b.id )   4          WHEN MATCHED THEN UPDATE   5             SET a.name = b.name;         USING sunwg2 b               * 第 2 行出现错误: ORA-30926: ...

11g新特性——只读表

星期二, 七月 29th, 2008

还记得么,在11g以前想要实现一个只读表应该怎么做。我会先建立一张表,然后在表的基础上建立一个只读的视图。 在11g中,这一切都改变了,我们可以直接修改表上的读写属性。 sunwg>select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production PL/SQL Release 11.1.0.6.0 - Production CORE    11.1.0.6.0      Production TNS for Linux: Version 11.1.0.6.0 - Production NLSRTL Version 11.1.0.6.0 - Production sys@SWORD>conn sunwg/sunwg Connected. sunwg>create table test (id number); Table created. sunwg>insert into test values(1); 1 row created. sunwg>commit; Commit complete. sunwg>alter table test read only; Table altered. sunwg>insert into test values (2); insert ...

Page 1 of 6123456»