與 SQL Server 型別 對照

  • Character and binary strings:
      SQL Server Oracle
    1 CHAR(n) Fixed-length non-Unicode string, 1 <= n <= 8000 CHAR(n)
    2 NCHAR(n) Fixed-length Unicode UCS-2 string, 1 <= n <= 4000 NCHAR(n)
    3 NVARCHAR(n) Variable-length Unicode UCS-2 string, 1 <= n <= 4000 NVARCHAR2(n)
    NVARCHAR(max) 2 GB NCLOB
    4 VARCHAR(n) Variable-length non-Unicode string, 1 <= n <= 8000 VARCHAR2(n)
    VARCHAR(max) 2 GB CLOB
     
  • Numbers:
      SQL Server Oracle
    1 BIGINT 64-bit integer NUMBER(19)
    2 DECIMAL(p, s) DEC(p, s) Fixed-point number NUMBER(p, s)
    3 FLOAT(n) Single (n <= 24) and double (n <= 53)
    precision floating-point number
    NUMBER
    4 INTEGER INT 32-bit integer NUMBER(10)
    5 NUMERIC(p, s) Fixed-point number NUMBER(p, s)
    6 REAL Single precision floating-point number NUMBER
    7 SMALLINT 16-bit integer NUMBER(5)
    8 TINYINT 0 to 255 NUMBER(3) // NUMBER(3,0)
    有時候 NUMBER(3) 語法不過,可寫 NUMBER(3,0)。
    例如:
        ALTER TABLE CourseSessions ADD ( 
            U_IsLive number(3) NOT NULL DEFAULT 0
        ) ;
    語法不過:「ORA-00907: missing right parenthesis
    「NUMBER(3,0)」有效位數:3、小數位數:0。
    Oracle 可以:「有效位數 < 小數位數」。
    SQL Server 只能:「有效位數 >= 小數位數」。
    例如:123.45 的位數是 5,小數位數是 2。
     
  • Date and time:
      SQL Server Oracle
    1 DATE Date (year, month and day) DATE Also includes time
    2 DATETIME Date and time with milliseconds (accuracy .000, .003, .007 seconds) TIMESTAMP(3)
    3 TIME(p) Time, 0 <= p <= 7 (100 nanoseconds accuracy) TIMESTAMP(p)
     
  • Other data types:
      SQL Server Oracle
    1 BIT 0, 1 and NULL NUMBER(1)
    2 MONEY Monetary data NUMBER(19, 4)
    3 SMALLMONEY Monetary data NUMBER(10, 4)
    4 UNIQUEIDENTIFIER GUID with dashes (-) CHAR(36)
    5 XML XML data XMLTYPE
     

參考:
Microsoft SQL Server to Oracle Migration - SQLines Open Source Tools
Oracle 發行者的資料類型對應 | Microsoft Docs
有效位數、小數位數和長度 (Transact-SQL) | Microsoft Docs
Oracle Data Types - w3resource
Data Type Conversion
 

 

字串

  • 空字串 '' 視為 NULL,沒有空字串。
  • 一律會保留空格字元(例如 SPACE、TAB、CR(回車)及 LF(換行)),不會修整前端或尾端空格字元。
     

參考:
IBM Knowledge Center - 空格字元、NULL 值及空字串值
ORACLE, 你把空字串怎麼了? - 黑暗執行緒
 

 

arrow
arrow

    Robert 發表在 痞客邦 留言(0) 人氣()