[20150707]外部表与rowid.txt

简介: [20150707]外部表与rowid.txt SCOTT@test> @ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -...

[20150707]外部表与rowid.txt

SCOTT@test> @ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.3.0     Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

CREATE OR REPLACE DIRECTORY
TRACE AS
'/u01/app/oracle11g/diag/rdbms/test/test/trace/';

GRANT EXECUTE, READ, WRITE ON DIRECTORY TRACE TO SCOTT WITH GRANT OPTION;

CREATE TABLE ALERT_LOG (text_line VARCHAR2 (512))
ORGANIZATION EXTERNAL
   (TYPE ORACLE_LOADER
         DEFAULT DIRECTORY TRACE
            ACCESS PARAMETERS
               (
            RECORDS DELIMITED BY NEWLINE
            NOBADFILE
            NODISCARDFILE
            NOLOGFILE
    )
         LOCATION ('alert_test.log'));

SCOTT@test> select rowid,alert_log.text_line c100 from ALERT_LOG where rownumROWID                   C100
----------------------- ----------------------------------------------------------------------------------------------------
(AASw6QAAAAAAAAAAAAAAAA Mon May 04 15:22:19 2015
(AASw6QAAAAAAAAAAAAAAGQ Error 12170 received logging on to the standby
(AASw6QAAAAAAAAAAAAAASA PING[ARC2]: Heartbeat failed to connect to standby 'testdg'. Error is 12170.
(AASw6QAAAAAAAAAAAAAAlQ Mon May 04 15:22:35 2015
(AASw6QAAAAAAAAAAAAAArg ALTER SYSTEM ARCHIVE LOG
(AASw6QAAAAAAAAAAAAAAxw Mon May 04 15:22:35 2015
(AASw6QAAAAAAAAAAAAAA4A Beginning log switch checkpoint up to RBA [0xa8f.2.10]
(AASw6QAAAAAAAAAAAAABKQ Thread 1 advanced to log sequence 2703 (LGWR switch)
(AASw6QAAAAAAAAAAAAABXg   Current log# 1 seq# 2703 mem# 0: /u01/app/oracle11g/oradata/test/redo01.log
(AASw6QAAAAAAAAAAAAABrA Mon May 04 15:22:35 2015

10 rows selected.)

--可以发现外部表也有rowid,但是明显与实际的rowid不同。
SCOTT@test> select rowid,dept.* from dept where rownum=1;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AABJVUAAEAAAAdzAAA         10 ACCOUNTING     NEW YORK

SCOTT@test> @ lookup_rowid (AASw6QAAAAAAAAAAAAAAAA
SELECT DBMS_ROWID.ROWID_OBJECT ('(AASw6QAAAAAAAAAAAAAAAA') "OBJECT",
       *
ERROR at line 1:
ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_ROWID", line 82


SCOTT@test> @ lookup_rowid AASw6QAAAAAAAAAAAAAAAA
SELECT DBMS_ROWID.ROWID_OBJECT ('AASw6QAAAAAAAAAAAAAAAA') "OBJECT",
       *
ERROR at line 1:
ORA-01410: invalid ROWID
ORA-06512: at "SYS.DBMS_ROWID", line 82

SCOTT@test> select text_line c100  from alert_log where rowid='(AASw6QAAAAAAAAAAAAAAAA';
C100
----------------------------------------------------------------------------------------------------
Mon May 04 15:22:19 2015

--我插入1行空行。

SCOTT@test> select rowid,alert_log.text_line c100 from ALERT_LOG where rownumROWID                   C100
----------------------- ----------------------------------------------------------------------------------------------------
(AASw6QAAAAAAAAAAAAAAAA
(AASw6QAAAAAAAAAAAAAAAQ Mon May 04 15:22:19 2015
(AASw6QAAAAAAAAAAAAAAGg Error 12170 received logging on to the standby
(AASw6QAAAAAAAAAAAAAASQ PING[ARC2]: Heartbeat failed to connect to standby 'testdg'. Error is 12170.
(AASw6QAAAAAAAAAAAAAAlg Mon May 04 15:22:35 2015
(AASw6QAAAAAAAAAAAAAArw ALTER SYSTEM ARCHIVE LOG
(AASw6QAAAAAAAAAAAAAAyA Mon May 04 15:22:35 2015
(AASw6QAAAAAAAAAAAAAA4Q Beginning log switch checkpoint up to RBA [0xa8f.2.10]
(AASw6QAAAAAAAAAAAAABKg Thread 1 advanced to log sequence 2703 (LGWR switch)
(AASw6QAAAAAAAAAAAAABXw   Current log# 1 seq# 2703 mem# 0: /u01/app/oracle11g/oradata/test/redo01.log
(AASw6QAAAAAAAAAAAAABrQ Mon May 04 15:22:35 2015

11 rows selected.

--我感觉rowid应该表示某种偏移量,具体细节很难猜透,至少我的能力不行.。

--建立一个aaa.txt文件在相应目录。
$ nl aaa.txt
     1  12334567890
     2  22334567890
     3  32334567890
     4  42334567890
     5  52334567890
     6  62334567890
     7  72334567890
     8  82334567890
     9  92334567890


SCOTT@test>  alter table ALERT_LOG location ('aaa.txt');
Table altered.

SCOTT@test> select rowid,text_line c100  from alert_log ;
ROWID                   C100
----------------------- ------------
(AASw6QAAAAAAAAAAAAAAAA 12334567890
(AASw6QAAAAAAAAAAAAAADA 22334567890
(AASw6QAAAAAAAAAAAAAAGA 32334567890
(AASw6QAAAAAAAAAAAAAAJA 42334567890
(AASw6QAAAAAAAAAAAAAAMA 52334567890
(AASw6QAAAAAAAAAAAAAAPA 62334567890
(AASw6QAAAAAAAAAAAAAASA 72334567890
(AASw6QAAAAAAAAAAAAAAVA 82334567890
(AASw6QAAAAAAAAAAAAAAYA 92334567890
9 rows selected.

--ABC DEF GHI JKL MNO PQR STU VWX YZ,视乎存在某种规律。

$ nl aaa.txt
     1  12334567890a
     2  22334567890
     3  32334567890
     4  42334567890
     5  52334567890
     6  62334567890
     7  72334567890
     8  82334567890
     9  92334567890

SCOTT@test> select rowid,text_line c100  from alert_log ;
ROWID                   C100
----------------------- ----------------------------------
(AASw6QAAAAAAAAAAAAAAAA 12334567890a
(AASw6QAAAAAAAAAAAAAADQ 22334567890
(AASw6QAAAAAAAAAAAAAAGQ 32334567890
(AASw6QAAAAAAAAAAAAAAJQ 42334567890
(AASw6QAAAAAAAAAAAAAAMQ 52334567890
(AASw6QAAAAAAAAAAAAAAPQ 62334567890
(AASw6QAAAAAAAAAAAAAASQ 72334567890
(AASw6QAAAAAAAAAAAAAAVQ 82334567890
(AASw6QAAAAAAAAAAAAAAYQ 92334567890
9 rows selected.

--放弃,应该表示某种偏移量,具体细节实在太难猜测。

目录
相关文章
|
存储 对象存储 开发者
DLA支持Parquet/ORC/OTS表的Alter Table Add Column
蛮多客户提过需求:要给一个表添加列,之前推荐的做法是让客户把表删掉重建,因为DLA是计算存储分离的,删掉的其实只是计算层的元数据,存储层的数据不会动,还是比较轻量级的一个操作。不过这种做法对于一些有特别多分区的表来说代价还是还是挺大的,要删掉所有的分区,而且可能会影响其它正在使用这个表的任务,为了解决用户的这个痛点,我们现在对部分数据源(Parquet/Orc)进行了的Alter Table Add Column的支持。
1885 0
DLA支持Parquet/ORC/OTS表的Alter Table Add Column
|
SQL 索引
Can you create an index on a foreign table?(外部表可以创建索引吗?)
来自google搜索的一段回答 No, you will get an error: ERROR: cannot create index on foreign table "tablename" ********** Error ********** ERROR: cannot create...
1496 0
|
SQL Oracle 关系型数据库
[20180423]关于闪回表与主外键约束.txt
[20180423]关于闪回表与主外键约束.txt --//上个星期做的测试,可以发现删除表在恢复主外键约束丢失. --//链接:http://blog.itpub.
1108 0
|
关系型数据库 Oracle Linux
[20180211]dblink查询单个分区数据.txt
[20180211]dblink查询单个分区数据.txt 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER -------------------...
1129 0
|
SQL 关系型数据库 HIVE
|
数据库
[20170210]关于dblink.txt
[20170210]关于dblink.txt --昨天朋友要求建立的数据库关闭全部dblink.实际上很简单设置open_links,open_links_per_instance为0就ok了.
954 0
|
SQL Shell 测试技术
[20161023]为什么以前可以这样的表.txt
[20161023]为什么以前可以这样的表.txt --上午看https://oracleblog.org/working-case/ora-01401-impdp-same-character/ CREATE TABLE ASS_ACC...
798 0
|
Oracle 关系型数据库
[20151024]关于ctas与建立主键.txt
[20151024]关于ctas与建立主键.txt --前一阵子别人问的问题,就是ctas是否可以建立主键,对于这种情况平时不这么建立,我给看看文档。 --平时我建立测试表 create table t as select rownum id ,'test' n...
936 0
[20150115]insert多个表.txt
[20150115]insert多个表.txt --别人给我提出一个问题,要把表拆开2个表,能否快速完成这个工作。还是通过例子来说明: SCOTT@test> @ver1 PORT_STRING                    VERSION  ...
712 0
|
Oracle 关系型数据库 数据库
[20141028]不同的表rowid可以相同.txt
[20141028]不同的表rowid可以相同.txt --前一阵子参加一个会议,在会议间隙听到别人议论"招DBA"的事,问上面的问题,竟然许多dba都回答不上来,看来现在的认证水分太大.
904 0