설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 94건, 최근 0 건
   

스트링과 single quote

글쓴이 : PostgresDBA 날짜 : 2014-11-11 (화) 12:01 조회 : 7423
PostgresQL 에서는 스트링을 감쌀때 single quote 를 사용하는데 대신에 $$ 를 사용할수 있습니다.
스트링자체내에 single quote 를 포함고 있으면 escape 해주어야 하는데 $$ 를 사용한다면 편하게 사용할수 있습니다.
예제를 보시죠.

postgres@[local]:5432:postgres] 
SQL> select 'Where''s my car?';  
    ?column?     
-----------------
 Where's my car?
(1 row)

postgres@[local]:5432:postgres] 
SQL> select $$Where's my car?$$
    ?column?     
-----------------
 Where's my car?
(1 row)

postgres@[local]:5432:postgres] 
SQL> select $$Where''s my car?$$;    -- double quote 가 아닌 single quote 2개
     ?column?     
------------------
 Where''s my car?
(1 row)

postgres@[local]:5432:postgres] 
SQL> 

   

postgresdba.com