1. D14问:“单表有LOB和LONG列并同时在SQL语句中,受4000限制”,这里的“同时在SQL语句中”是什么意思?4000又是指什么?以及提到的“顺序访问”和“随机访问”能否简单解释下?
答:D14,在一个表中只能有一个long字段,一条语句不能超过4000个字符,现在已经不推荐用这个了,还是用clob吧.
顺序访问就像字符设备:字符设备按照字符流的方式被有序访问,像串口和键盘就都属于字符设备
随机访问就像块设备:系统中能够随机(不需要按顺序)访问固定大小数据片(chunks)的设备被称作块设备,这些数据片就称作块。最常见的块设备是硬盘,除此以外,还有软盘驱动器、CD-ROM驱动器和闪存等等许多其他块设备。
注意,它们都是以安装文件系统的方式使用的——这也是块设备一般的访问方式
create table long1 (id number,name varchar2(12),history long);
create table long2 (id number,name varchar2(12),history long);
insert into long1 values(1,'tom','work in china');
insert into long1 values(2,'smith','work in bj');
SQL> select * from long1;
ID NAME HISTORY
---------- ------------ ---------------------
1 tom work in china
2 smith work in bj
SQL> insert into long2 select * from long1;
insert into long2 select * from long1
ORA-00997: illegal use of LONG datatype ==>报错了,说是非法使用LONG数据类型
2. D19问:lob最大支持4G字节,LOB列上设置有指针,指向在线LOB值或者离线LOB值,在线lob和离线lob能否也简单解释下?
答:D19,
LOB types store lob locators, which point to large objects stored in an external file, in-line (inside the row) or out-of-line (outside the row).
Database columns of type BLOB, CLOB, NCLOB, or BFILE store the locators.
BLOB, CLOB, and NCLOB data is stored in the database, in or outside the row. BFILE data is stored in operating system files outside the database.
in-line (inside the row):这个意思就是存储在逻辑的一个row上,没有存在外部文件上,逻辑的一个row在db里面,就好像,我存一行a=1
a=1存在db的tbs上的一个段的一个区的一个块上,这就是 in-line (inside the row)
a=1存在外部文件上,数据库里面只有个指针,这就是 out-of-line (outside the row)
LOB类型中可以存储了LOB定位器,它能够指向存放于外部文件中的"大对象",in-line (inside the row)或out-of-line (outside the row)的形式,就是数据即可以存储在数据库的表中,也可以存储在操作系统文件中。
BLOB、CLOB、NCLOB或BFILE类型的数据库字段存储了定位器。其中BLOB、CLOB和NCLOB的数据存在数据库中,
in-line (inside the row)或out-of-line (outside the row)的形式,而BFILE数据存在数据库之外的操作
系统文件中。
Ora
cle supports the following two types of LOBs
Those stored in the database either in-line in the table or in a separate segment or tablespace, such as BLOB, CLOB, and NCLOB.
Those stored as operating system files, such as BFILEs.
lob小于4000字节时是内部存放
LOB由两部分组成:数据(值)和指向数据的指针(定位器)。尽管值与表自身一起存储,但是一个LOB列并不包含值,仅有它的定位指针。
更进一步,为了使用大对象,程序必须声明定位器类型的本地变量。
当内部LOB被创建时,定位器被存放在列中,值被存放在LOB段中,LOB段是在数据库内部表的一部分。
当BFILE被创建时,定位器如同平常一样存储在列中,但是它的值被存储在数据库之外的操作系统文件中。
内部LOB
就是存放在DB内部的LOB,包括BLOB,CLOB,NCLOB。它们可以是
用户自定义的类型中的属性
表中某列
SQL 变量
程序host变量
PL/SQL中的变量、参数、返回值
3. D40问:SCHEMA OBKECT不能用
sql语