{"id":1756,"date":"2012-03-17T14:13:03","date_gmt":"2012-03-17T05:13:03","guid":{"rendered":"http:\/\/www.nkozawa.com\/blog\/?p=1756"},"modified":"2012-03-17T14:13:03","modified_gmt":"2012-03-17T05:13:03","slug":"sqlite%e3%81%ae%e3%82%a8%e3%82%b9%e3%82%b1%e3%83%bc%e3%83%97%e6%96%87%e5%ad%97","status":"publish","type":"post","link":"https:\/\/www.nkozawa.com\/blog\/archives\/1756","title":{"rendered":"SQLite\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57"},"content":{"rendered":"<p>SQLite3\u3068\u3044\u3046\u30b5\u30fc\u30d0\u30fc\u8981\u3089\u305a\u306eDB\u30a8\u30f3\u30b8\u30f3\u306f\u30d1\u30fc\u30bd\u30ca\u30eb\u306bSQL\u3092\u4f7f\u7528\u3059\u308b\u306e\u306b\u624b\u8efd\u3067\u3059\u3002\u307e\u305f\u3001\u6700\u8fd1\u306e\u591a\u304f\u306e\u30e2\u30d0\u30a4\u30eb\u30fb\u30c7\u30d0\u30a4\u30b9\u306e\u5185\u90e8\u3067\u3082\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067Mac OS X\u4e0a\u3067\u3082iOS\u30a2\u30d7\u30ea\u5185(\u6700\u8fd1\u306fCoreData\u306b\u79fb\u884c\u4e2d\u3067\u3059\u304c)\u3067\u3082\u591a\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u5358\u7d14\u306a\u5358\u8a9e\u306e\u5834\u5408\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u304c\u7279\u6b8a\u6587\u5b57\u3082\u542b\u3081\u3066query\u3059\u308b\u5834\u5408\u306b\u306f\u6587\u5b57\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u3092\u884c\u308f\u306a\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002iOS\u30a2\u30d7\u30ea\u306e\u5185\u90e8\u3067\u591a\u69d8\u306a\u6587\u5b57\u5217\u306equery\u3092\u884c\u3046\u5fc5\u8981\u304c\u51fa\u3066\u304d\u305f\u305f\u3081\u306b\u6587\u5b57\u5217\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><strong>[ LIKE operator\u306e\u5834\u5408 ]<\/strong><br \/>\n\u6a19\u6e96\u7684\u306aSQL\u3067\u4f7f\u7528\u3055\u308c\u308bLIKE\u3068\u540c\u3058\u3067\u3059\u3002\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3068\u3057\u3066<span style=\"color: #0000ff;\">%<\/span>(0\u500b\u4ee5\u4e0a\u306e\u4efb\u610f\u306e\u6587\u5b57\u306b\u4e00\u81f4)\u3068<span style=\"color: #0000ff;\">_<\/span>(\u4efb\u610f\u306e\u4e00\u6587\u5b57\u306b\u4e00\u81f4)\u304c\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u305d\u306e\u305f\u3081<span style=\"color: #0000ff;\">%<\/span>\u3068<span style=\"color: #0000ff;\">_<\/span>\u81ea\u8eab\u3092\u30de\u30c3\u30c1\u3055\u305b\u308b\u305f\u3081\u306b\u306f\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57\u306e\u6307\u5b9a\u304c\u5fc5\u8981\u3067\u3059\u3002 \u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57\u306e\u6307\u5b9a\u306b\u306fESCAPE\u7bc0\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre>SELECT * FROM hoge WHERE key LIKE '% test^_case %' ESCAPE '^';<\/pre>\n<p>\u3068\u3044\u3046\u5177\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002ESCAPE\u3067\u6307\u5b9a\u3057\u305f\u6587\u5b57\u81ea\u4f53\u3082\u30a8\u30b9\u30b1\u30fc\u30d7\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5f15\u7528\u7b26\u306e\u6271\u3044\u306fperl\u3068\u540c\u69d8\u3067\u3059\u3002<br \/>\n&#8211; \u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u00a0<strong><span style=\"color: #0000ff;\">&#8216;\u00a0<\/span><\/strong>\u3067\u56f2\u307e\u308c\u305f\u6587\u5b57\u5217\u306e\u4e2d\u3067\u306f\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u00a0<span style=\"color: #0000ff;\">&#8221;\u00a0<\/span>\u306f\u81ea\u7531\u306b\u4f7f\u7528\u3067\u304d\u308b\u3002<br \/>\n&#8211; \u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u00a0<strong><span style=\"color: #0000ff;\">&#8221;\u00a0<\/span><\/strong>\u3067\u56f2\u307e\u308c\u305f\u6587\u5b57\u5217\u306e\u4e2d\u3067\u306f\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u00a0<strong><span style=\"color: #0000ff;\">&#8216;\u00a0<\/span><\/strong>\u306f\u81ea\u7531\u306b\u4f7f\u7528\u3067\u304d\u308b\u3002<br \/>\n&#8211; \u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u3068\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u304c\u6df7\u5728\u3059\u308b\u5834\u5408\u306b\u306f\u56f2\u307f\u6587\u5b57\u81ea\u4f53\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u51fa\u6765\u308b\u3002<\/p>\n<pre>SELECT * FROM hoge WHERE key LIKE 'I''m reading the \"SNOW WHITE\"';<\/pre>\n<p><strong>[ GLOB operator\u306e\u5834\u5408 ]<\/strong><br \/>\nGLOB\u306fSQLite\u306b\u7279\u6709\u306a\u30aa\u30da\u30ec\u30fc\u30bf\u30fc\u3067\u3059\u3002\u6b63\u898f\u8868\u73fe\u7684\u306a\u8868\u73fe\u3092\u4f7f\u7528\u3057LIKE\u3088\u308a\u67d4\u8edf\u306a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u304c\u884c\u3048\u307e\u3059\u3002\u307e\u305fLIKE\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u306e\u533a\u5225\u304c\u3042\u308a\u307e\u305b\u3093\u304cGLOB\u3067\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u3092\u533a\u5225\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u30a8\u30b9\u30b1\u30fc\u30d7\u306b\u3064\u3044\u3066\u3060\u3051\u66f8\u304d\u307e\u3059\u3002\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u6587\u5b57\u306f <span style=\"color: #0000ff;\">[ ] * ?<\/span> \u3067\u3059\u3002\u30a8\u30b9\u30b1\u30fc\u30d7\u306e\u65b9\u6cd5\u306f\u3001\u305d\u308c\u305e\u308c\u3092[]\u3067\u56f2\u307f\u307e\u3059\u3002<\/p>\n<pre>SELECT * FROM hoge WHERE key GLOB 'How are you[?] *';<\/pre>\n<p>\u3068\u3044\u3063\u305f\u5177\u5408\u306b\u306a\u308a\u307e\u3059\u3002'[Y\/n]&#8217;\u306e\u3088\u3046\u306b[]\u81ea\u4f53\u304c\u542b\u307e\u308c\u308b\u6587\u5b57\u5217\u306e\u30de\u30c3\u30c1\u30f3\u30b0\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n<pre>SELECT * FROM hoge WHERE key GLOB '[[]Y\/n[]]';<\/pre>\n<p>\u5f15\u7528\u7b26\u306e\u6271\u3044\u306fLIKE\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQLite3\u3068\u3044\u3046\u30b5\u30fc\u30d0\u30fc\u8981\u3089\u305a\u306eDB\u30a8\u30f3\u30b8\u30f3\u306f\u30d1\u30fc\u30bd\u30ca\u30eb\u306bSQL\u3092\u4f7f\u7528\u3059\u308b\u306e\u306b\u624b\u8efd\u3067\u3059\u3002\u307e\u305f\u3001\u6700\u8fd1\u306e\u591a\u304f\u306e\u30e2\u30d0\u30a4\u30eb\u30fb\u30c7\u30d0\u30a4\u30b9\u306e\u5185\u90e8\u3067\u3082\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u3068\u3044\u3046\u3053\u3068\u3067Mac OS X\u4e0a\u3067\u3082iOS\u30a2\u30d7\u30ea\u5185(\u6700\u8fd1\u306fCor [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-1756","post","type-post","status-publish","format-standard","hentry","category-programing"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/posts\/1756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/comments?post=1756"}],"version-history":[{"count":5,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/posts\/1756\/revisions"}],"predecessor-version":[{"id":1762,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/posts\/1756\/revisions\/1762"}],"wp:attachment":[{"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/media?parent=1756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/categories?post=1756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nkozawa.com\/blog\/wp-json\/wp\/v2\/tags?post=1756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}