没有合适的资源?快使用搜索试试~ 我知道了~
ORACLE数据库开发,Oracle数据隐式转换规则。
资源推荐
资源详情
资源评论
Oracle 数据隐式转换规则
The following rules govern the direcon in which Oracle makes implicit data type conversions(在
oracle 中,如果不同的数据类型之间关联,如果不显式转换数据,则它会根据以下规则对
数据进行隐式转换):
1) During INSERT and UPDATE operaons, Oracle converts the value to the datatype
of the a'ected column
(对于 INSERT 和 UPDATE 操作,oracle 会把插入值或者更新值隐式转换为字段
的数据类型)
如:
假如 id 列的数据类型为 number
update t set id='1'; -> 相当于 update t set id=to_number('1');
insert into t(id) values('1') -> insert into t values(to_number('1'));
2) During SELECT FROM operaons, Oracle converts the data from the column to
the type of the target variable
(对于 SELECT 语句,oracle 会把字段的数据类型隐式转换为变量的数据类型).
如:
假设 id 列的数据类型为 varchar2
select * from t where id=1; -> select * from t where to_number(id)=1;
但如果 id 列的数据类型为 number,则
select * from t where id='1'; -> select * from t where id=to_number('1');
3) When comparing a character value with a NUMBER value, Oracle converts the
character data to NUMBER
(当比较一个字符型和数值型的值时,oracle 会把字符型的值隐式转换为数值
型).
如:
假设 id 列的数据类型为 number
select * from t where id='1'; -> select * from t where id=to_number('1');
4) When comparing a character value with a DATE value, Oracle converts the
character data to DATE
(当比较字符型和日期型的数据时,oracle 会把字符型转换为日期型).
如:
假设 create_date 为字符型,
select * from t where create_date>sysdate; -> select * from t where
to_date(create_date)>sysdate;(注意,此时 session 的 nls_date_format 需要与字符串格式
相符)
假设 create_date 为 date 型
select * from t where create_date>'2006-11-11 11:11:11'; -> select * from t where
create_date>to_date('2006-11-11 11:11:11'); (注意,此时 session 的 nls_date_format 需要
与字符串格式相符)
5) When you use a SQL funcon or operator with an argument of a datatype other
than the one it accepts, Oracle converts the argument to the accepted datatype.
(如果调用函数或过程等时,如果输入参数的数据类型与函数或者过程定义
资源评论
hailensen
- 粉丝: 0
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功