{"id":4647,"date":"2026-07-19T12:01:37","date_gmt":"2026-07-19T03:01:37","guid":{"rendered":"https:\/\/www.kinryo.net\/?p=4647"},"modified":"2026-07-19T19:13:21","modified_gmt":"2026-07-19T10:13:21","slug":"ruby-on-rails%e3%81%abexcel%e3%83%87%e3%83%bc%e3%82%bf%e3%83%bc%e3%82%92%e3%82%a4%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%88%e3%81%99%e3%82%8b%e6%99%82%e3%81%ae%e3%83%a1%e3%83%a2","status":"publish","type":"post","link":"https:\/\/www.kinryo.net\/?p=4647","title":{"rendered":"Ruby on Rails\u306bEXCEL\u30c7\u30fc\u30bf\u30fc\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u6642\u306e\u30e1\u30e2"},"content":{"rendered":"<p>\u3069\u3046\u3082DB\u95a2\u9023\u306e\u30b3\u30de\u30f3\u30c9\u3092\u899a\u3048\u3089\u308c\u306a\u3044\u306e\u3067\u30e1\u30e2<\/p>\n<ol>\n<li><span style=\"color: #0000ff;\">\u30c6\u30fc\u30d6\u30eb\u3092\u6d88\u53bb\u3057\u521d\u671f\u5316\u3059\u308b(foreign key\u304c\u3042\u308b\u6642)<br \/>\n<\/span>SET FOREIGN_KEY_CHECKS = 0;<br \/>\nTRUNCATE TABLE \u30c6\u30fc\u30d6\u30eb\u540d;<br \/>\nSET FOREIGN_KEY_CHECKS = 1;<br \/>\n\u6ce8\uff1aauto increment \u304c\u3042\u308b\u4e8b\u3001ID\u306f1\u304b\u3089\u306b\u306a\u308b<\/li>\n<li><span style=\"color: #0000ff;\">\u3042\u308b\u7bc4\u56f2\u306eID\u3092\u6d88\u53bb(foreign key\u304c\u3042\u308b\u6642)<br \/>\n<\/span><span style=\"color: #0000ff;\"><span style=\"color: #333333;\">SET FOREIGN_KEY_CHECKS=0;<\/span><br \/>\n<span style=\"color: #333333;\">DELETE FROM \u30c6\u30fc\u30d6\u30eb\u540d WHERE id BETWEEN \u59cb\u3081\u306eid AND \u7d42\u308f\u308a\u306eid;<br \/>\nSET FOREIGN_KEY_CHECKS=1;<br \/>\n<\/span><\/span><\/li>\n<li><span style=\"color: #0000ff;\">\u7279\u5b9a\u306eID\u304b\u3089\u30b9\u30bf\u30fc\u30c8\u3059\u308b<\/span><br \/>\nALTER TABLE \u30c6\u30fc\u30d6\u30eb\u540d AUTO_INCREMENT=\u30b9\u30bf\u30fc\u30c8\u3059\u308bid<\/li>\n<li><span style=\"color: #0000ff;\">CSV\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b(id\u306e\u30ab\u30e9\u30e0\u304c\u7121\u3044\u6642)<\/span><br \/>\nLOAD DATA INFILE &#8216;\/Save\/TrHotels_09 2026.csv&#8217; into table tr_hotels fields terminated by &#8216;,&#8217; enclosed by &#8216;&#8221;&#8216; escaped by &#8216;&#8221;&#8216; lines terminated by &#8216;\\n&#8217; ignore 1 lines (flight,arr,dep,htl_name,room_type,meals,nts,remarks,rooming,unit_price,usd_ttl,<br \/>\njpy_ttl,net,htl_code,tour_id,created_at,updated_at,cancelled,cancelled_date,<br \/>\nconf_no,offer_code);<\/li>\n<li><span style=\"color: #0000ff;\">\u6700\u5927\u306eID\u756a\u53f7\u3092\u8abf\u3079\u308b<\/span><br \/>\nSELECT MAX(id) FROM\u00a0 \u30c6\u30fc\u30d6\u30eb\u540d<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3046\u3082DB\u95a2\u9023\u306e\u30b3\u30de\u30f3\u30c9\u3092\u899a\u3048\u3089\u308c\u306a\u3044\u306e\u3067\u30e1\u30e2 \u30c6\u30fc\u30d6\u30eb\u3092\u6d88\u53bb\u3057\u521d\u671f\u5316\u3059\u308b(foreign key\u304c\u3042\u308b\u6642) SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE \u30c6\u30fc\u30d6\u30eb\u540d; SET F &hellip; <a href=\"https:\/\/www.kinryo.net\/?p=4647\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"common","vkexunit_cta_each_option":"","footnotes":""},"categories":[10,38,18],"tags":[],"class_list":["post-4647","post","type-post","status-publish","format-standard","hentry","category-linux","category-rails","category-window"],"acf":[],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/posts\/4647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4647"}],"version-history":[{"count":11,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/posts\/4647\/revisions"}],"predecessor-version":[{"id":4658,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=\/wp\/v2\/posts\/4647\/revisions\/4658"}],"wp:attachment":[{"href":"https:\/\/www.kinryo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kinryo.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}