sql server和oracle的差異

來源:互聯網
上載者:User

標籤:

.部分SQL語句差異 

(1)SQL:select top 10 * from table
     ORA: select * from table where rownum<11
(2)SQL:Select * from t1 join t2 on t1.c1=t2.c1
     ORA: select * from t1,t2 where t1.c1=t2.c1
(3)select * from t1 left join t2 on t1.c1=t2.c1
     ORA: select * from t1,t2 where t1.c1=t2.c1(+)
(4)SQL:select * from t1 right join t2 on t1.c1=t2.c1
     ORA: select * from t1,t2 where t1.c1(+)=t2.c1

2. 其他技術差異
    GPRS技術可以應用的領域有:
    ◆在oracle中,delete語句中的from從句中不能涉及到多個表,要基於多個表進行刪除記錄只有使用子查詢。;
    ◆在oracle中,update語句不能基於多個表進行修改資料,要基於多個表進行修改資料只有使用子查詢;
    ◆在oracle中,預存程序不能返回記錄集,如果要預存程序返回記錄集,可以建立視圖,可以單獨執行select語句  (注意:並不是說在預存程序中不能使用select語句,但select只能用於以下情況:insert into table select * from t1 /select col1 into a from table where ……(a為一變數));
    ◆在oracle中insert 的文法是:insert into table values() 或insert into table select * from t1;;
    ◆Oracle中的日期型常量必須用to_date()函數得到。;
    ◆Dual表是一個虛擬表,專門用於測試的目的用,注意dual表的用法:
在sql server中,如果我們項測試某個函數,例如:select convert(int,’13’) ,在 oracle 中這種表示方法是錯誤的,應表示為:select to_number(‘13’) from dual;;
    ◆得到相差的天數:兩個日期相減,再用ceil或floor函數取整得到相差的月數:months_between()
    ◆資料類型的轉換;
    ◆ORACLE中對象名不能超過30個字元。ORACLE中界限符是“”(對應SQLSERVER中的[ ])(我的建議是:最好不要是用界限符,能避免實用系統的保留字就盡量避免);
    ◆ORACLE中Null 字元串被看成null;
    ◆ORACLE中字元的比較是區分大小寫;
    ◆視圖中如果用了order by ,並且order by 從句中的欄位名都是別名,那麼,在顯示視圖時必須顯示出order by 子句中的所有欄位,例如,有下面這樣一個視圖:
create view v 
as
select name as c1,address from t1 order by c1
那麼在select 該視圖時
select c1,address from v   是正確的,   select address from v是錯誤的;
    ◆關於暫存資料表的問題
      在sqlserver中 create table #table1 (c int);
      在oracle 中解決辦法是:
create global temporary table table1(c int) on commit preserve rows
這個table1在資料庫中是永久存在的,所以不要是用drop命令,在你的程式中在對這個表進行任何操作之前,先執行truncate table table1,切忌不要用drop命令刪除此表。;
    ◆http://technet.oracle.com/doc/server815.htm這個網站有許多線上教程,但一定要先註冊;

    3. 資料類型轉換

SQL SERVER ORACLE 
    bigint       NUMBER (19 ,0)     
    binary  (50)      RAW (50)     
    bit       NUMBER (1, 0)     
    char  (10)    CHAR (10)     
    datetime       DATE     
    decimal (18 , 0)      NUMBER (18, 0)     
    float       FLOAT     
    image      BLOB 
    int      NUMBER (10, 0)     
    money       NUMBER (19 ,4)     
    nchar  (10)    CHAR (20)     
    ntext    CLOB 
    numeric (18 , 0)      NUMBER (18 ,0)     
    nvarchar  (50)    VARCHAR2 (100)     
    real       FLOAT     
    smalldatetime       DATE     
    smallint       NUMBER (5, 0)     
    smallmoney       NUMBER (10, 4)     
    sql_variant       LONG RAW     
    text    CLOB 
    timestamp       RAW (8) NOT     
    tinyint       NUMBER (3 ,0)     
    uniqueidentifier       LONG RAW     
    varbinary  (50)     RAW (50)     
    varchar  (50)  VARCHAR2 (50)   
 

sql server和oracle的差異

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.