oracle和db2的一些异同点
1, Table space for indexes 的不同
Oralce:
Create TABLE T1 .............IN DATA_TA
Create Index ........ ON T1 ...... IN INDX_TS
DB2:
Create TABLE T1 ........ IN DATA_TS INDEX IN INDX_TS
Create INDEX .....ON T1
www.2cto.com
2, RowID
Oracle:
Oracle 有RowID ,它是由
数据库唯一产生的,在程序里可以获得
DB2:
DB2的相对应的这个值不能被程序获得
3,一些转换
Oracle 支持一些转换,比如:
Create table t1(c1 int);
Select * from t1 where c1=’1’
Select ‘abc’||2 from t1
DB2:
DB2不支持一些转换,比如:
Create table t1(c1 int);
Select * from t1 where c1=CAST(‘1’ AS INT)
Select ‘abc’||CHAR(2) from t1
4,函数的值做为表中的缺省值
Oracle:
Oracle 支持把函数的值做为表中的缺省值,比如:
Create table t1(C1 Number DEFAULT FN() NOT NULL,
C2 DATE DEFAULT NOT NULL SYSDATE
)
DB2:
DB2不支持把函数的值做为表中的缺省值,比如:
Create table t1(C1 INT NOT NULL,
C2 TIMESTAMP DEFAULT CURRENT TIMESTAMP
)
这个是不允许的
5,一些内建的函数
Oracle
DB2
NVL
COALESCE
INSTR
LOCATE
DECODE
CASE
LENGTH
LENGTH
TO_CAHR()
CHAR(),INTEGER(),TO_CHAR()
TO_DATE()
CHAR(date,FN)
TO_DATE()
6,公用的同义词(Public Synonyms)
Oracle:
Oracle 支持公用的同义词
DB2:
DB2不支持公用的同义词
7,Date/Time
Oracle
DB2
SYSDATE
CURRENT DATE
CURRENT TIMESTAMP
DT1+2
Add_months(DT1,5)
DT1+2days
DT2+5months
DT1+3years
DT1-DT2
TIMESTAMODIFF(k,Char(TS1-TS2)
To_date(DT1,’MM/DD/YYYY’)
Char(DT1,USA)
Char(TM1,ISO)
8,外连接
Oracle
DB2
Select A.lastname,A_id,B.name From emp A,Customer B
where A.id(+)=B.sales_rep_id;
Select A.lastname,A_id,B.name From emp A, RIGHT OUTER JOIN Customer B
where A.id=B.sales_rep_id;
Select A.lastname,A_id,B.name From emp A,Customer B
where A.id=B.sales_rep_id(+);
Select A.lastname,A_id,B.name From emp A, LEFT OUTER JOIN Customer B
where A.id=B.sales_rep_id;
Select A.lastname,A_id,B.name From emp A,Customer B
where A.id(+)=B.sales_rep_id(+);
Select A.lastname,A_id,B.name From emp A, Full OUTER JOIN Customer B
where A.id=B.sales_rep_id;
现在, Oracle 9i也支持这种ANSI join 语法
9,字符串和null的合并
Select ‘abc’||c1 from T1
C1 is null
Result :
Oracle : abc
DB2: null
要想得到’abc’,DB2中需要这样处理
Select ‘abc’||coalesce(c1,’’) from T1