gikoha’s blog

個人的メモがわり

oracle database のはまり点

DB fieldはテーブルのフィールド文字は小文字のままだとダブルクオートescapeしないとアクセスできない
フィールド名は大文字にすると、小文字でアクセスできる
ただし予約語とかぶっているときはダブルクオートescapeが必要 たとえば"DATE” "INITIAL"
 
下記検証

create table testtable (
"test" number
);
 
insert into testtable values (1);
insert into testtable values (5);
insert into testtable values (3);
 
select * from testtable where test=3;
ORA-00904: "TEST": 無効な識別子です。
00904. 00000 -  "%s: invalid identifier"
 
select * from testtable where "test"=3;
      test
----------
         3
 
“test”を”TEST”に改名すると エラーがなくなる
とりあえず全部大文字にしておいたほうがよい
 
 
MySQLと違いいわゆるplaceholder (SELECT name WHERE id=? の “?”)が、 :1, :2となる