1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Oracle と MS SQL Serverの違い

Last updated at Posted at 2020-02-03

初めて触ったのがSQL Serverという人がOracleを使い始めて戸惑った内容まとめ
(随時更新)
異なっている点などありましたらご指摘ください

SQLの文末の";"

SQL Serverでは、文末のセミコロンは必須ではないのでつける習慣がなかったので。

select * from items D1 where D1.ItemCode = 'AAA';
select * from Address D1 where D1.StateCode = '001';

Dualってなに

dualはダミーテーブル。自動作成されるので、自分で作らなくていい。

# SQL Server
select getdate()

# Oracle
select sysdate from dual;

テーブルの結合

一番戸惑った、カンマ区切り。SQL Serverの時と同じように、inner join left join も使える。

select * from A, B where A.Code = B.Code 
=> Inner join 
select * from A, B where A.Code = B.Code (+)
=> left outer join

全件抽出時の ' * '

# SQL server 
SELECT Code, Name, * from TableA left join TableB on TableA.code = TableB.code
=> OK

# Oracle
SELECT Code, Name, * from TableA left join TableB on TableA.code = TableB.code
=> NG

SELECT T1.Code, T2.Name, T2.* from TableA T1 left join TableB T2 on T1.Code = T2.Code;
=> OK 

テーブルが2つ以上ある場合、*で全件抽出時はテーブル指定が必須。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?