{"id":68,"date":"2017-02-05T20:04:17","date_gmt":"2017-02-05T11:04:17","guid":{"rendered":"http:\/\/testengine.co.jp\/engine\/?p=68"},"modified":"2017-02-05T21:24:00","modified_gmt":"2017-02-05T12:24:00","slug":"%e5%a4%a7%e9%87%8finsert-sql%e3%81%ae%e7%94%9f%e6%88%90","status":"publish","type":"post","link":"https:\/\/testengine.co.jp\/engine\/2017\/02\/05\/%e5%a4%a7%e9%87%8finsert-sql%e3%81%ae%e7%94%9f%e6%88%90\/","title":{"rendered":"\u5927\u91cfINSERT SQL\u306e\u751f\u6210"},"content":{"rendered":"<div id=\"dslc-theme-content\"><div id=\"dslc-theme-content-inner\"><pre><strong>\u5927\u91cfINSERT SQL\u306e\u751f<\/strong>\u6210\r\n\r\n\u4f7f\u3044\u65b9\r\nawk -f scriptbuilder.awk -v dateSet=\"$(date +%Y-%m-%d)\" insert.sql&gt;import.sql\r\n\r\n\u4f8b\uff09\u4e0b\u8a18\u306e\u3088\u3046\u306a\u6ce8\u6587\u30c6\u30fc\u30d6\u30eb\u306eINSERT SQL\u6587\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\r\n+--+------+---------+----------+----------+----------+-----------+-----------+\r\n|ID|USERID|ORDERTYPE|ORDERCOUNT|ORDERLIMIT|ORDERINPUT|ORDERUPDATE| VALIDFLAG |\r\n+--+------+---------+----------+----------+----------+-----------+-----------+\r\n\r\n1. SQLBuilder\u306e\u5143\u30cd\u30bf\r\nINSERT INTO ORDER_TBL (ID,USERID,ORDERTYPE,ORDERCOUNT,ORDERLIMIT,ORDERINPUT,ORDERUPDATE,VALIDFLAG)\r\n\u00a0VALUES\r\n\u00a0(\r\n'<strong>[dateNum][timeNum][fixNum02][lineNum05]<\/strong>',\r\n'USER<strong>[fixNum05]<\/strong>',\r\n'<strong>[seqNum05]<\/strong>',\r\n10000,\r\n100000,\r\n'<strong>[dateString] [timeString]<\/strong>',\r\n'<strong>[dateString] [timeString]<\/strong>',\r\n'1')\r\n;\r\n\r\n2. 1.\u304b\u3089SQLBuilder\u3067\u3001\u4e0b\u8a18INSERT SQL\u6587\r\nINSERT INTO ORDER_TBL (ID,USERID,ORDERTYPE,ORDERCOUNT,ORDERLIMIT,ORDERINPUT,ORDERUPDATE,VALIDFLAG)\r\n\u00a0VALUES\r\n\u00a0(\r\n'201703130659599980100001',\r\n'USER00001',\r\n'00001',\r\n10000,\r\n100000,\r\n'2017-03-13 06:59:59.998\u2019,\r\n'2017-03-13 06:59:59.998\u2019,\r\n'1')\r\n;\r\n\u304c\u751f\u6210\u3055\u308c\u307e\u3057\u305f\u3002\r\n\r\n\u5229\u7528\u65b9\u6cd5\r\n<strong>[loop 100000]<\/strong>\r\n\u751f\u6210\u3057\u305f\u3044\u5143\u30cd\u30bf\u306eSQL\u6587\r\n<strong>[loopEnd]<\/strong>\r\n\u3068\u6307\u5b9a\u3059\u308b\u3068\u3001\u305f\u3063\u305f1\u884c\u306eSQL\u5143\u30cd\u30bf\u304b\u3089100000\u4ef6\u306a\u3069\u306e\u3001\u5927\u91cfSQL\u30c7\u30fc\u30bf\u3092\u30b5\u30af\u30c3\u3068\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\r\n\r\n\r\n\r\nSQLBuilder\u306e\u4e88\u7d04\u8a9e\u8aac\u660e\r\n'<strong>[dateNum][timeNum][fixNum02][lineNum05]<\/strong>',\r\n\u7d44\u307f\u5408\u308f\u305b\u51fa\u529b\u4f8b\r\n'201702050659599980100001'\r\n\r\n\r\nSQLBuilder\u306e\u4e88\u7d04\u8a9e\u8aac\u660e\r\n\r\n<strong>[dateNum]<\/strong>\r\n\u30fb\u8aac\u660e\r\n\u5f15\u6570dateSet\u3067\u4e0e\u3048\u305f\u65e5\u4ed8\u3092yyyymmdd\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\ndateSet=\"$(date +%Y-%m-%d)\u201d\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u30de\u30b7\u30f3\u65e5\u4ed8\u3068\u306a\u308a\u307e\u3059\u3002\r\n\u4ed6\u306b\u30c6\u30b9\u30c8\u8981\u4ef6\u306b\u5408\u308f\u305b\u305f\u65e5\u4ed8\u3082\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002\r\n\u30fb\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30df\u30f3\u30b0\r\n\u3000\u521d\u671f\u5024\u306e\u307f\r\n\u30fb\u4f8b\uff092017\u5e74\u30b5\u30de\u30fc\u30bf\u30a4\u30e0\u5207\u66ff\u65e5\u7528\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u4f5c\u6210\r\ndateSet=\u201c2017-03-13\u201d -&gt; 20170313\r\n\r\n\r\n<strong>[timeNum]<\/strong>\r\n\u30fb\u8aac\u660e\r\n\u6642\u9593\u306e\u30ab\u30a6\u30f3\u30bf\u30fc\u3092hhmmss999\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\u30fb\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30df\u30f3\u30b0\r\n\u3000\u30eb\u30fc\u30d7\u51e6\u7406\u6bce\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\uff08SQLBuilder\u5168\u4f53\u3067\u30e6\u30cb\u30fc\u30af\u5024\uff09\r\n\u30fb\u4f8b NY\u5e02\u5834\u30aa\u30fc\u30d7\u30f3\u76f4\u524d\u7528\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u4f5c\u6210\r\n06:59:59.999 -&gt; 065959999\r\n\r\n<strong>[fixNum02]<\/strong>\r\n\u30fb\u8aac\u660e\r\nSQL\u5143\u30cd\u30bf\u8a18\u8ff0\u6bce\u306e\u30ab\u30a6\u30f3\u30bf\u30fc\u3092\u6307\u5b9a\u30b1\u30bf\u6570\uff08\u524d\u30bc\u30ed\uff09\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\r\n\u30fb\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30df\u30f3\u30b0\r\n\u3000SQLBuilder\u3067\u5143\u30cd\u30bfSQL\u884c\u6570\u6bce\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\r\n\u30fb\u4f8b \u30e6\u30fc\u30b6\u30fc\u6bce\u306e\u6ce8\u6587\u30ec\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3059\u308b\r\n\u5143\u30cd\u30bf\r\n<strong>[loop 2]<\/strong>\r\nINSERT INTO ORDER_TBL VALUES(\u2019<strong>[fixNum03]<\/strong>\u2019,\u2019USER<strong>[fixNum02]<\/strong>\u2019\u2026\u2026\u2026\r\n<strong>[loopEnd]<\/strong>\r\n<strong>[loop 3]<\/strong>\r\nINSERT INTO ORDER_TBL VALUES(\u2019<strong>[fixNum03]<\/strong>\u2019,\u2019USER<strong>[fixNum02]<\/strong>\u2019\u2026\u2026\u2026\r\n<strong>[loopEnd]<\/strong>\r\n<strong>[loop 4]<\/strong>\r\nINSERT INTO ORDER_TBL VALUES(\u2019<strong>[fixNum03]<\/strong>\u2019,\u2019USER<strong>[fixNum02]<\/strong>\u2019\u2026\u2026\u2026\r\n<strong>[loopEnd]<\/strong>\r\n\r\n\u751f\u6210\u5f8c\r\nINSERT INTO ORDER_TBL VALUES(\u2019001\u2019,\u2019USER01\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019001\u2019,\u2019USER01\u2019\u2026\u2026\u2026\r\n\r\nINSERT INTO ORDER_TBL VALUES(\u2019002\u2019,\u2019USER02\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019002\u2019,\u2019USER02\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019002\u2019,\u2019USER02\u2019\u2026\u2026\u2026\r\n\r\nINSERT INTO ORDER_TBL VALUES(\u2019003\u2019,\u2019USER03\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019003\u2019,\u2019USER03\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019003\u2019,\u2019USER03\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019003\u2019,\u2019USER03\u2019\u2026\u2026\u2026\r\n\r\n\r\n[lineNum05]\r\n\u30fb\u8aac\u660e\r\nSQL\u751f\u6210\u6bce\u306e\u30e6\u30cb\u30fc\u30af\u306a\u30ab\u30a6\u30f3\u30bf\u30fc\u5024\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001\u6307\u5b9a\u30b1\u30bf\u6570\uff08\u524d\u30bc\u30ed\uff09\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\r\n\u30fb\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30df\u30f3\u30b0\r\n\u3000SQLBuilder\u3067\u751f\u6210SQL\u884c\u6570\u6bce\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\r\n\r\n\u30fb\u4f8b \u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u3067\u30e6\u30cb\u30fc\u30af\u5024\u304c\u5fc5\u8981\u306a\u9805\u76ee\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3059\u308b\r\n<strong>[loop 4]<\/strong>\r\n'<strong>[dateNum][timeNum][fixNum02][lineNum05]<\/strong>',\r\n<strong>[loopEnd]<\/strong>\r\n<strong>[loop 2]<\/strong>\r\n'<strong>[dateNum][timeNum][fixNum02][lineNum05]<\/strong>',\r\n<strong>[loopEnd]<\/strong>\r\n\r\n'201703130659599980100001',\r\n'201703130659599990100002\u2019,\r\n'201703130700000000100003\u2019,\r\n'201703130700000010100004\u2019,\r\n\r\n'201703130700000020100005\u2019,\r\n'201703130700000030100006\u2019,\r\n\r\n\r\n<strong>[seqNum05]<\/strong>\r\n\u30fb\u8aac\u660e\r\nSQL\u5143\u30cd\u30bf\u306e\u30eb\u30fc\u30d7\u51e6\u7406\u5185\u3067\u306e\u30ab\u30a6\u30f3\u30bf\u30fc\u3092\u6307\u5b9a\u30b1\u30bf\u6570\uff08\u524d\u30bc\u30ed\uff09\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\r\n\u30fb\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u306e\u30bf\u30a4\u30df\u30f3\u30b0\r\n\u3000SQLBuilder\u3067\u30eb\u30fc\u30d7\u51e6\u7406\u5358\u4f4d\u306eSQL\u51fa\u529b\u884c\u6570\u6bce\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\r\n\u30fb\u4f8b \u30e6\u30fc\u30b6\u30fc\u306e\u8907\u6570\u6ce8\u6587\u30ec\u30b3\u30fc\u30c9\u306e\u5024\u3092\u4f5c\u6210\u3059\u308b\uff08\u30eb\u30fc\u30d7\u51e6\u7406\u3092\u307e\u305f\u304c\u308b\u3068\u30ea\u30bb\u30c3\u30c8\uff09\r\n<strong>[loop 2]<\/strong>\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER<strong>[seqNum05]<\/strong>\u2019\u2026\u2026\u2026\r\n<strong>[loopEnd]<\/strong>\r\n<strong>[loop 3]<\/strong>\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER<strong>[seqNum05]<\/strong>\u2019\u2026\u2026\u2026\r\n<strong>[loopEnd]<\/strong>\r\n\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER00001\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER00002\u2019\u2026\u2026\u2026\r\n\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER00001\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER00002\u2019\u2026\u2026\u2026\r\nINSERT INTO ORDER_TBL VALUES(\u2019ORDER00003\u2019\u2026\u2026\u2026\r\n\r\n<strong>[dateString]<\/strong> \r\n\u30fb\u8aac\u660e\r\n\u5f15\u6570dateSet\u3067\u4e0e\u3048\u305f\u65e5\u4ed8\u3092yyyy-mm-dd\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\u30ab\u30a6\u30f3\u30bf\u30fc\u306e\u6a5f\u80fd\u306f<strong>[dateNum]<\/strong>\u3068\u540c\u3058\u3067\u51fa\u529b\u66f8\u5f0f\u304c\u9055\u3046\u3060\u3051\u3067\u3059\u3002\r\n<strong>[timeString]<\/strong>\r\n\u30fb\u8aac\u660e\r\n\u6642\u9593\u306e\u30ab\u30a6\u30f3\u30bf\u30fc\u3092hh:mm:ss.999\u3067\u51fa\u529b\u3057\u307e\u3059\u3002\r\n\u30ab\u30a6\u30f3\u30bf\u30fc\u306e\u6a5f\u80fd\u306f<strong>[timeNum]<\/strong>\u3068\u540c\u3058\u3067\u51fa\u529b\u66f8\u5f0f\u304c\u9055\u3046\u3060\u3051\u3067\u3059\u3002\r\n\r\n\u30fb\u4f8b\uff092017\u5e74\u30b5\u30de\u30fc\u30bf\u30a4\u30e0\u5207\u66ff\u65e5\u7528\u306e\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u4f5c\u6210\r\ndateSet=\u201c2017-03-13\u201d -&gt; 2017-03-13\r\n\r\n'2017-03-13 06:59:59.998\u2019,\r\n<\/pre>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"1170\" height=\"659\" src=\"https:\/\/www.youtube.com\/embed\/LZGhxJnrHdo?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=ja&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5927\u91cfINSERT SQL\u306e\u751f\u6210 \u4f7f\u3044\u65b9 awk -f scr [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[15,14,23,22,24],"class_list":{"0":"post-68","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-4","7":"tag-insert","8":"tag-sql","9":"tag-23","10":"tag-22","12":"clearfix"},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7t6nl-16","jetpack-related-posts":[{"id":48,"url":"https:\/\/testengine.co.jp\/engine\/2016\/10\/02\/scriptbuilder-awk-%e5%a4%a7%e9%87%8f%e3%83%86%e3%82%b9%e3%83%88%e3%83%87%e3%83%bc%e3%82%bf%e7%94%9f%e6%88%90\/","url_meta":{"origin":68,"position":0},"title":"scriptbuilder.awk \u5927\u91cf\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u751f\u6210","author":"\u52aa\u82e5\u677e","date":"2016\u5e7410\u67082\u65e5","format":false,"excerpt":"ScriptBuilder \u4f7f\u3044\u65b9\u3000redis\u3078\u306e\u66f8\u8fbc\u307f\u3092\u5927\u91cf\u306b\u751f\u6210\u3057\u305f\u3044\u3001SQL\u306einset\u6587\u3092\u5927\u2026","rel":"","context":"\u6280\u8853\u306e\u5c0f\u90e8\u5c4b","block_context":{"text":"\u6280\u8853\u306e\u5c0f\u90e8\u5c4b","link":"https:\/\/testengine.co.jp\/engine\/category\/%e6%8a%80%e8%a1%93%e3%81%ae%e5%b0%8f%e9%83%a8%e5%b1%8b\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/PzwguQWnd2Y\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":57,"url":"https:\/\/testengine.co.jp\/engine\/2016\/10\/11\/redis-%e5%a4%a7%e9%87%8f%e6%9b%b8%e8%be%bc%e3%81%bf%e3%83%87%e3%83%bc%e3%82%bf%e7%94%9f%e6%88%90\/","url_meta":{"origin":68,"position":1},"title":"redis \u5927\u91cf\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u751f\u6210","author":"\u52aa\u82e5\u677e","date":"2016\u5e7410\u670811\u65e5","format":false,"excerpt":"redis \u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u30b5\u30f3\u30d7\u30eb \u4f7f\u3044\u65b9 awk\u3092\u4f7f\u7528\u3057\u3066\u3001redis\u3078\u306e\u5927\u91cfset\u3092\u5b9f\u884c\u3059\u308b\u30b5\u30f3\u30d7\u2026","rel":"","context":"\u6280\u8853\u306e\u5c0f\u90e8\u5c4b","block_context":{"text":"\u6280\u8853\u306e\u5c0f\u90e8\u5c4b","link":"https:\/\/testengine.co.jp\/engine\/category\/%e6%8a%80%e8%a1%93%e3%81%ae%e5%b0%8f%e9%83%a8%e5%b1%8b\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":3,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":71,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/posts\/68\/revisions\/71"}],"wp:attachment":[{"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/testengine.co.jp\/engine\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}