Comparison 比较操作符 oracle /mssql 对比

15 篇文章 0 订阅
12 篇文章 0 订阅

 

                                                   Same in Both    SQL  Server  Server
                   Operator                        Databases       Only                     Oracle Only

                   Equal to                        =

                    Not equal to                    !=                                       ^=

                                                    <>

                    Less than                        <

                    Greater than                     >

                    Less than or equal to            <=               !>

                    Greater than or equal to         >=               !<

                    Greater than or equal to x      BETWEEN x
                    and less than or equal to y     AND y

                    Less than x or greater than y   NOT
                                                    BETWEEN x
                                                    AND y

                    Pattern Matches                 LIKE 'a%'        LIKE'a[x-z]'            LIKE 'a\%'

                    a followed by 0 or more         LIKE 'a_'        LIKE'a[^x-z]'           ESCAPE '\'
                    characters

                    a followed by exactly 1
                    character

                    a followed by any character
                    between x and z

                    a followed by any character
                    except those between x and
                    z

                    a followed by %

                    Does not match pattern           NOT LIKE

                    No value exists                  IS NULL

                    A value exists                   IS NOT NULL

                    At least one row returned by    EXISTS
                    query                           (query)

                    No rows returned by query        NOT EXISTS
                                                    (query)

                    Equal to a member of set         IN     =ANY                              = SOME

                    Not equal to a member of set     NOT IN    !=                            != SOME     <>
                                                    ANY     <>                               SOME
                                                    ANY

                    Less than a member of set       < ANY                                     < SOME

                    Greater than a member of set    > ANY                                     > SOME

                    Less than or equal to a          <= ANY           !> ANY                  <= SOME
                    member of set

                    Greater than or equal to a      >= ANY           !< ANY                  >= SOME
                    member of set

                    Equal to every member of set     =ALL

                  Not equal to every member of      != ALL     <>
                 set                              ALL

                 Less than every member of         < ALL
                set

                 Greater than every member         > ALL
                   of set

                 Less than or equal to every       <= ALL           !> ALL
                member of set

                  Greater than or equal to every    >= ALL           !< ALL
                  member of set

 

Recommendations:

1.   Convert all !< and !> to >= and <=

     Convert the following in Microsoft SQL Server or Sybase Adaptive Server:

     WHERE col1 !< 100

     to this for Oracle:

     WHERE col1 >= 100

1.   Convert like comparisons which use [ ] and [^]

     SELECT title
     FROM titles
     WHERE title like "[A-F]%"

1.   Change NULL constructs:

     Table 2–12 shows that in Oracle, NULL is never equal to NULL. Change the all =
     NULL constructs to IS NULL to retain the same functionality.

Table 2–12     Changing NULL Constructs

                                Microsoft SQL Server or
NULL Construct                  Sybase Adaptive Server           Oracle

where col1 = NULL               depends on the data             FALSE

where col1 != NULL              depends on the data             TRUE

where col1 IS NULL              depends on the data             depends on the data

where col1 IS NOT NULL          depends on the data             depends on the data

where NULL = NULL               TRUE                             FALSE

If you have the following in Microsoft SQL Server or Sybase Adaptive Server:

WHERE col1 = NULL

Convert it as follows for Oracle:

WHERE col1 IS NULL

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值