{"id":6841,"date":"2015-03-27T10:00:33","date_gmt":"2015-03-27T01:00:33","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=6841"},"modified":"2018-11-14T16:33:48","modified_gmt":"2018-11-14T07:33:48","slug":"3%e5%88%86%e3%81%a7%e6%a7%8b%e7%af%89%ef%bc%81sqlite%e3%82%92%e8%89%b2%e3%80%85%e3%81%aa%e7%92%b0%e5%a2%83%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2015\/03\/27\/3%e5%88%86%e3%81%a7%e6%a7%8b%e7%af%89%ef%bc%81sqlite%e3%82%92%e8%89%b2%e3%80%85%e3%81%aa%e7%92%b0%e5%a2%83%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b\/","title":{"rendered":"3\u5206\u3067\u69cb\u7bc9\uff01SQLite\u3092\u8272\u3005\u306a\u74b0\u5883\u3067\u52d5\u304b\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u7530\u6e15\u3067\u3059\u3002<br \/>\n\u666e\u6bb5\u306f\u3001PostgreSQL\u3084MySQL\u306a\u3069\u306eRDB\u3092\u4f7f\u7528\u3057\u3066\u3001Web\u30b7\u30b9\u30c6\u30e0\u3092\u5236\u4f5c\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3059\u304c\u3001<br \/>\n\u69d8\u3005\u306a\u3068\u3053\u308d\u3067\u76ee\u306b\u3059\u308b\u6a5f\u4f1a\u304c\u591a\u3044\u3001SQLite\u3092\u8907\u6570\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u52d5\u304b\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u306b\u306f\u3001PostgreSQL\u3084MySQL\u306a\u3069\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\/\u30b5\u30fc\u30d0\u69cb\u6210\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u4fbf\u5229\u3067\u3059\u304c\u3001\u3061\u3087\u3053\u3063\u3068\u3057\u305f\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u306e\u305f\u3081\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u69cb\u7bc9\u3059\u308b\u306e\u306f\u624b\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<br \/>\nSQLite\u306f\u3001\u8907\u6570\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u30c7\u30fc\u30bf\u3092\u5171\u6709\u3059\u308b\u76ee\u7684\u3067\u306f\u306a\u304f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u306e\u6c38\u7d9a\u5316\u306b\u4f7f\u7528\u3059\u308b\u7528\u9014\u3067\u4f7f\u308f\u308c\u308b\u3053\u3068\u304c\u591a\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u3059\u3002<br \/>\n\u307e\u305f\u3001\u30b5\u30a4\u30ba\u3082\u8efd\u304f\u69cb\u7bc9\u3082\u7c21\u5358\u306a\u305f\u3081\u3001\u4f1a\u793e\u306a\u3069\u958b\u767a\u74b0\u5883\u306e\u6574\u3063\u305f\u74b0\u5883\u3067\u306f\u306a\u304f\u3001\u5bb6\u306e\u8ca7\u5f31\u306a\u30ce\u30fc\u30c8PC\u306a\u3069\u3067\u3001\u3061\u3087\u3053\u3063\u3068\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u691c\u8a3c\u3057\u305f\u308a\u3059\u308b\u969b\u306b\u3001\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\uff01<\/p>\n<h2>\u7279\u5fb4<\/h2>\n<p>\u7279\u5fb4\u306f\u3001\u305f\u304f\u3055\u3093\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u306f\u7d39\u4ecb\u3057\u304d\u308c\u306a\u3044\u306e\u3067\u3002\u3002\u3002\u304a\u304a\u304d\u304f2\u3064\u3002<br \/>\nSQLite\u306f\u3001\u6a19\u6e96SQL\u898f\u683c\u306eSQL92\u306b\u591a\u304f\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u666e\u6bb5PostgreSQL\u306a\u3069\u3067\u958b\u767a\u3057\u3066\u3044\u308b\u4eba\u306f\u3001\u30b9\u30c8\u30ec\u30b9\u306a\u304f\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001SQLite\u306f\u30d1\u30d6\u30ea\u30c3\u30af\u30c9\u30e1\u30a4\u30f3\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u304a\u308a\u3001\u6539\u5909\u3084\u518d\u914d\u5e03\u3082\u81ea\u7531\u306b\u884c\u3048\u308b\u3053\u3068\u304b\u3089\u3001\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u306e\u30a2\u30d7\u30ea\u306b\u3082\u591a\u304f\u5185\u5305\u3057\u3066\u3042\u308a\u307e\u3059\u306d\u3002<\/p>\n<h2>\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/h2>\n<p>SQLite\u306f\u3053\u3061\u3089\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n<a title=\"sqlite\" href=\"http:\/\/www.sqlite.org\/\">http:\/\/www.sqlite.org\/<\/a><br \/>\nWindows\u7248\u3001Linux\u7248\u306a\u3069\u3001\u74b0\u5883\u306b\u3042\u3063\u305f\u3082\u306e\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u306f\u3001Windows\u7248\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fzip\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u89e3\u51cd\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u3001\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3059\u308c\u3070\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4f5c\u6210\u5b8c\u4e86\uff01<\/p>\n<pre class=\"lang:sh decode:true\">sqlite3 hoge.db<\/pre>\n<p>\u4eca\u56de\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u306b\u300choge.db\u300d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u6642\u70b9\u3067\u306f\u3001\u307e\u3060\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306f\u4f5c\u6210\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u3001fruits\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\">create table fruits(name);<\/pre>\n<p>\u203bSQLite\u306f\u3001\u30c7\u30fc\u30bf\u578b\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u3082\u3061\u308d\u3093\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u578b\u306f\u3001NULL\/INTEGER\/REAL\/TEXT\/BLOB\u3067\u3059\u3002<br \/>\nCREATE TABLE\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u3001hoge.db\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002SQLite\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b91\u3064\u306b\u3064\u304d\u30011\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3082\u697d\u3061\u3093\u3067\u3059\u306d\u3002<br \/>\n\u6b21\u306b\u3001\u30c7\u30fc\u30bf\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">insert into fruits values('apple');\r\ninsert into fruits values('orange');\r\ninsert into fruits values('banana');\r\ninsert into fruits values('peach');\r\n<\/pre>\n<p>\u6b21\u306b\u3001\u767b\u9332\u3057\u305f\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">select * from fruits;<\/pre>\n<pre class=\"lang:sh decode:true \">apple\r\norange\r\nbanana\r\npeach\r\n<\/pre>\n<p>\u7d42\u4e86\u3059\u308b\u5834\u5408\u306f\u3001.exit \u3068\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<h2>\u691c\u8a3c<\/h2>\n<p>\u6b21\u306b\u3001\u3053\u306e\u30c7\u30fc\u30bf\u3092Linux\u4e0a\u3078\u6301\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\nLinux\u7248\u306eSQLite\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001zip\u30d5\u30a1\u30a4\u30eb\u3092\u9069\u5f53\u306a\u5834\u6240\u306b\u89e3\u51cd\u3057\u307e\u3059\u3002\u305d\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u3001\u5148\u307b\u3069Windows\u4e0a\u3067\u4f5c\u6210\u3057\u305fhoge.db\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3001\u30c7\u30fc\u30bf\u3092\u8aad\u3080\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305a\u306f\u3001hoge.db\u306b\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\">sqlite3 hoge.db<\/pre>\n<p>\u6b21\u306b\u3001\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\">select * from fruits;<\/pre>\n<pre class=\"lang:sh decode:true\">apple\r\norange\r\nbanana\r\npeach\r\n<\/pre>\n<p>Windows\u3067\u767b\u9332\u3057\u305f\u5185\u5bb9\u304c\u3001\u305d\u306e\u307e\u307e\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u7570\u306a\u308b\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u3082\u3001\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3059\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002\u65e5\u672c\u8a9e\u3092\u5165\u529b\u3059\u308b\u5834\u5408\u306f\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u7d71\u4e00\u3059\u308c\u3070\u3001\u554f\u984c\u306a\u304f\u8aad\u307f\u66f8\u304d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001Java\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u3001SQLite\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3093\u3067\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\nJava\u304b\u3089SQLite\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u3001\u304a\u306a\u3058\u307f\u306eJDBC\u30c9\u30e9\u30a4\u30d0\u30fc\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002\u3053\u3061\u3089\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001\u30af\u30e9\u30b9\u30d1\u30b9\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<a title=\"sqlite-jdbc\" href=\"https:\/\/bitbucket.org\/xerial\/sqlite-jdbc\/downloads\">https:\/\/bitbucket.org\/xerial\/sqlite-jdbc\/downloads<\/a><\/p>\n<p>\u305d\u3057\u3066\u3001SqliteSample.java\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br \/>\n\u203b \/path\/to\/hoge.db \u306f\u304a\u4f7f\u3044\u306e\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"lang:sh decode:true \">package test;\r\n\r\nimport java.sql.Connection;\r\nimport java.sql.DriverManager;\r\nimport java.sql.ResultSet;\r\nimport java.sql.SQLException;\r\nimport java.sql.Statement;\r\n\r\npublic class SqliteSample {\r\n\r\n    public static void main(String[] args) {\r\n\r\n        Connection connection = null;\r\n        Statement statement = null;\r\n\r\n        try {\r\n            Class.forName(\"org.sqlite.JDBC\");\r\n\r\n            connection = DriverManager.getConnection(\"jdbc:sqlite:\/path\/to\/hoge.db\");\r\n            statement = connection.createStatement();\r\n            String sql = \"select * from fruits\";\r\n            ResultSet rs = statement.executeQuery(sql);\r\n            while (rs.next()) {\r\n                System.out.println(rs.getString(1));\r\n            }\r\n        } catch (ClassNotFoundException e) {\r\n          e.printStackTrace();\r\n        } catch (SQLException e) {\r\n          e.printStackTrace();\r\n        } finally {\r\n            try {\r\n                if (statement != null) {\r\n                    statement.close();\r\n                }\r\n            } catch (SQLException e) {\r\n                e.printStackTrace();\r\n            }\r\n            try {\r\n                if (connection != null) {\r\n                    connection.close();\r\n                }\r\n            } catch (SQLException e) {\r\n                e.printStackTrace();\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u4ee5\u4e0b\u30b3\u30de\u30f3\u30c9\u3067\u3001\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>java -classpath .:sqlite-jdbc-3.8.7.jar test.SqliteSample\r\n<\/pre>\n<p>\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u30c6\u30fc\u30d6\u30eb\u30c7\u30fc\u30bf\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u6210\u529f\u3067\u3059\u3002<\/p>\n<pre>apple\r\norange\r\nbanana\r\npeach\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u666e\u6bb5\u306eJava\u306e\u30c7\u30fc\u30bf\u64cd\u4f5c\u3068\u540c\u3058\u8981\u9818\u3067\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3055\u3089\u306b\u3001Android\u30a2\u30d7\u30ea\u306e\u958b\u767a\u74b0\u5883\u3067\u306f\u3001\u6a19\u6e96\u3067SQLite\u304c\u3064\u3044\u3066\u304a\u308a\u3001SQLiteOpenHelper\u304c\u6e96\u5099\u3055\u308c\u3066\u307e\u3059\u306e\u3067\u3001\u30c7\u30fc\u30bf\u306e\u64cd\u4f5c\u304c\u3088\u308a\u7c21\u5358\u306b\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u5404\u30d7\u30ed\u30b0\u30e9\u30e0\u8a00\u8a9e\u3068\u306e\u89aa\u548c\u6027\u306e\u9ad8\u3044SQLite\u3001\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u306d\u3002\u305c\u3072\u3001\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u3044\u305f\u3060\u304d\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u7530\u6e15\u3067\u3059\u3002<br \/>\n\u666e\u6bb5\u306f\u3001PostgreSQL\u3084MySQL\u306a\u3069\u306eRDB\u3092\u4f7f\u7528\u3057\u3066\u3001Web\u30b7\u30b9\u30c6\u30e0\u3092\u5236\u4f5c\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3059\u304c\u3001<br \/>\n\u69d8\u3005\u306a\u3068\u3053\u308d\u3067\u76ee\u306b\u3059\u308b\u6a5f\u4f1a\u304c\u591a\u3044\u3001SQLite\u3092\u8907\u6570\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u52d5\u304b\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2015\/03\/27\/3%e5%88%86%e3%81%a7%e6%a7%8b%e7%af%89%ef%bc%81sqlite%e3%82%92%e8%89%b2%e3%80%85%e3%81%aa%e7%92%b0%e5%a2%83%e3%81%a7%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[57,124,93,178],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/6841"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=6841"}],"version-history":[{"count":43,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/6841\/revisions"}],"predecessor-version":[{"id":6874,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/6841\/revisions\/6874"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=6841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=6841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=6841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}