Oracle强烈建议使用lob来代替long型字段(转)

一、 可以在以下情况使用long字段:

1、 selectlist列表。

SQL> insert into test_long values (1,'tgfdsfgdsgfsd');

已创建 1 行。

SQL> insert into test_long values (2,'asfafafasd');

已创建 1 行。

SQL> commit;

提交完成。

SQL> col id for 9999;

SQL> col description for a30;

SQL> select * from test_long;

ID DESCRIPTION

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

1 tgfdsfgdsgfsd

2 asfafafasd

2、 update语句中的set子句:

SQL> update test_long

2 set description='hsy'

3 where id=2;

已更新 1 行。

SQL> commit;

提交完成。

SQL> select * from test_long;

ID DESCRIPTION

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

1 tgfdsfgdsgfsd

2 hsy

3、 insert语句中的values子句中。

SQL> insert into test_long values (1,'tgfdsfgdsgfsd');

已创建 1 行。

二、 限制使用long型字段的情况:

1、 一个表中只能使用一个long型字段。

SQL> alter table test_long add (description1 long);

alter table test_long add (description1 long)

*

ERROR 位于第 1 :

ORA-01754: 表只能包含一个 LONG 类型的列

2、 使用long属性来定义对象type

SQL> Create type test_list as object(str1 varchar2(50),str2 long);

2 /

警告: 创建的类型带有编译错误。

SQL> Create type test_list as object(str1 varchar2(50),str2 number(5)) ;

2 /

类型已创建。

3、 Long字段不能出现在where子句中和完整性约束中。【除了nullnot null约束】。

4、 Long字段不能用来indexed

5、 存储函数不能用来返回long值。

6、 plsql程序单元中可以使用long数据类型来定义变量或者参数。但是不能从sql中调用这个程序单元。

7、 在一个单一的sql语句中,所有的long字段,updated tableslocked tables必须位于同一个数据库。

8、 Longlong raw不能用在分布式sql语句中,不能复制。

9、 如果表中同时有longlob字段,在同一个sql语句中longlob字段不能bind超过4000字节的数据。然而可以单独bind超多4000字节在只有long或者lob字段时。

10、 拥有long字段的表不能位于assm【自动段管理表空间】中。

三、 long字段不能出现在sql语句的部分位置:

1、 含有group by order byconnect bydistinct关键字的select语句中。

2、 带有unique操作的select语句。

3、 Create cluster语句的字段列表中。

4、 Create materialized view语句的cluster子句中。

5、 functionexpressionscontitions的内嵌sql中。

6、 含有group by子句的select列表查询中。

7、 含有unionintersectminus的查询或者子查询中。

8、 Create table as select语句的select 列表中。

9、 Alter tablemove 语句中。

10、 Insert语句的子查询select 列表中。

四、 触发器可以用以下方式使用long字段:

1、 一个sql语句内部的trigger可以插入一个long字段。

2、 如果long字段的数据可以转换为constrained 数据类型(比如charvarchar2),此时可以引用在带有triggersql语句。

3、 触发器中的变量不能使用long定义。

4、 new和:old不能使用long字段。

总之:使用long字段的限制很多,使用情况很少,再加上oracle后期版本支持没有提高,所以强烈建议使用lob型来代替long型字段。

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9650775/viewspace-923309/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9650775/viewspace-923309/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值