{"id":270,"date":"2023-08-18T18:04:54","date_gmt":"2023-08-18T10:04:54","guid":{"rendered":"http:\/\/blog.xjfvps.top\/index.php\/2023\/08\/18\/%e5%a6%82%e4%bd%95%e6%8a%8aexcel%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae%e5%ba%93\/"},"modified":"2023-08-18T18:46:20","modified_gmt":"2023-08-18T10:46:20","slug":"%e5%a6%82%e4%bd%95%e6%8a%8aexcel%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/blog.fs.cloudns.biz\/index.php\/2023\/08\/18\/%e5%a6%82%e4%bd%95%e6%8a%8aexcel%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae%e5%ba%93\/","title":{"rendered":"\u5982\u4f55\u628aexcel\u6570\u636e\u5bfc\u5165\u6570\u636e\u5e93"},"content":{"rendered":"<p><span style=\"font-size: 14px;\">\u8fd9\u91cc\u4ecb\u7ecd2\u79cd\u628aexcel\u6570\u636e\u5bfc\u5165oracle\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">1. \u5728excel\u4e2d\u751f\u6210sql\u8bed\u53e5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">1\uff09\u5728\u6570\u636e\u5217\u7684\u53f3\u4fa7\uff0c\u7b2c\u4e00\u884c\u7684\u4efb\u4f55\u4f4d\u7f6e\u8f93\u5165=&#8221;insert into table(xx,yyy..) values(&#8216;&#8221;&amp;A2&amp;&#8221;&#8216;, &#8216;&#8221;&amp;B2&amp;&#8221;&#8216;&hellip;.);&#8221;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u6ce8\u610f\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 14px;\">&nbsp;\u6574\u4e2asql\u8bed\u53e5\u7528\u53cc\u5f15\u53f7\u5957\u7740\u3002<\/span><\/li>\n<li><span style=\"font-size: 14px;\">values\u503c\u4e2d\u4f7f\u7528 &#8220;&amp;A2&amp;&#8221;&nbsp; \u6765\u5f15\u7528A\u5217\u7684\u7b2c\u4e8c\u884c\u6570\u636e\uff0c\u518d\u5916\u9762\u7684\u5355\u5f15\u53f7\u662f\u56e0\u4e3avalues\u4e2d\u7684\u503c\uff08varchar\u578b\uff09\u9700\u8981\u5355\u5f15\u53f7\u3002<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 14px;\">2\uff09\u5199\u5b8c\u4e00\u884c\u540e\u5f80\u4e0b\u62d6\uff0c\u81ea\u52a8\u751f\u6210\u5176\u4ed6\u884c\u7684sql\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">3\uff09\u628a\u8fd9\u4e9bsql copy\u5230pl\/sql dev\u5de5\u5177\u4e2d\u6267\u884c\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u8fd9\u79cd\u65b9\u6cd5\u9002\u5408\u6570\u636e\u91cf\u4e0d\u592a\u5927\uff0c\u4e14\u53ea\u542b\u6709varchar(\u6216\u8005\u8bf4\u8f6c\u5165\u6570\u636e\u5e93\u4e2d\u90fd\u4e3avarchar\u7c7b\u578b\u5b57\u6bb5\uff09\u8fd9\u79cd\u7b80\u5355\u7684\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u3002\u5bf9\u4e8e\u542b\u6709\u65e5\u671f\u7c7b\u578b\u7684\u8981\u6ce8\u610f\uff0c<\/span><span>\u5982\u679cexcel\u683c\u5f0f\u4e2d\u6709\u65e5\u671f\u7c7b\u578b\u7684\uff0c\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u5f15\u7528\u51fa\u6765\u7684\u503c\u662f\u4e2a\u6d6e\u70b9\u6570\u3002\u9700\u8981\u9996\u5148\u628a\u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u6210\u6587\u672c\u683c\u5f0f\u3002\u518d\u5199sql\u8bed\u53e5\uff0c\u5b83\u624d\u80fd\u5f15\u7528\u6b63\u786e\u7684\u65e5\u671f\u683c\u5f0f\u7684\u503c\u3002insert into user_test(seq, msisdn,user_name,dt,comment1,comment2) values(&#8216;1&#8242;,&#8217;13597093898&#8242;,&#8217;\u5f20\u4e0942&#8217;,to_date(&#8216;2013\/2\/8 20:00:01&#8242;,&#8217;yyyy\/mm\/dd HH24:mi:ss&#8217;),&#8217;yyyy&#8217;,&#8217;yyyyy&#8217;);<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<img decoding=\"async\" src=\"http:\/\/images.cnitblog.com\/blog\/8751\/201308\/04000808-9a3c11ca82cd4e46811f756a049b655b.jpg\" alt=\"\" \/><\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u4f46\u5b58\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0d\u5efa\u8bae\u7528\u8fd9\u79cd\u65b9\u6cd5\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">1. \u5bf9\u4e8e\u6570\u636e\u91cf\u5f88\u5927\uff0c\u51e0\u5341\u4e07\uff0c\u4e0a\u767e\u4e07\u7684\u6570\u636e\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">2. \u5982\u679c\u6570\u636e\u5e93\u8868\u5b58\u5728\u7531\u5e8f\u5217\u751f\u6210\u7684\u5217\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">3. \u5b58\u5728\u65e5\u671f\u683c\u5f0f\u5217\u7684excel\u3002&mdash;&mdash;\u6211\u6ca1\u6709\u627e\u5230\u5f88\u65b9\u4fbf\u7684\u76f4\u63a5\u628a\u65e5\u671f\u683c\u5f0f\u8f6c\u4e3a\u6587\u672c\u683c\u5f0f\u7684\u65b9\u6cd5\uff08\u5982\u76f4\u63a5\u8f6c\u6362\u6210\u6587\u672c\uff0c\u5b83\u4f1a\u663e\u793a\u6210\u6d6e\u70b9\uff09\uff0c\u56e0\u6b64\u5b58\u5728\u65e5\u671f\u683c\u5f0f\u7684excel\u5217\u4e0d\u5efa\u8bae\u91c7\u7528\u8fd9\u79cd\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5f53\u7136\u7b2c\u4e8c\u70b9\uff0c\u8fd8\u662f\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u65b9\u6cd5\u89e3\u51b3\u7684\uff0c\u5c31\u662f\u5199\u89e6\u53d1\u5668\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5728\u5199insert\u8bed\u53e5\u63d2\u5165\u7684\u5217\u4e0d\u5305\u542b\u5e8f\u5217\u7684\u5217\uff0c\u5199\u89e6\u53d1\u5668\uff0c\u5f53\u8868\u8fdb\u884cinsert\u4e4b\u524d\u751f\u6210\u5e8f\u5217\u53f7\u63d2\u5165\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5047\u8bbe\u6570\u636e\u5e93\u8868\u5982\u4e0b<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<div class=\"cnblogs_code\">\n<pre><span style=\"font-size: 14px;\"><span style=\"color: #0000ff;\">create<\/span> <span style=\"color: #0000ff;\">table<\/span><span style=\"color: #000000;\"> user_test\n\n(\n\n   seq <\/span><span style=\"color: #0000ff;\">number<\/span>(<span style=\"color: #800000; font-weight: bold;\">10<\/span>) <span style=\"color: #0000ff;\">primary<\/span> <span style=\"color: #0000ff;\">key<\/span><span style=\"color: #000000;\">,\n\n   msisdn <\/span><span style=\"color: #0000ff;\">varchar2<\/span>(<span style=\"color: #800000; font-weight: bold;\">11<\/span>) <span style=\"color: #808080;\">not<\/span> <span style=\"color: #0000ff;\">null<\/span><span style=\"color: #000000;\">,\n\n   <\/span><span style=\"color: #ff00ff;\">user_name<\/span> <span style=\"color: #0000ff;\">varchar2<\/span>(<span style=\"color: #800000; font-weight: bold;\">50<\/span>) <span style=\"color: #808080;\">not<\/span> <span style=\"color: #0000ff;\">null<\/span><span style=\"color: #000000;\">,\n\n   dt     date,\n\n   comment1 <\/span><span style=\"color: #0000ff;\">varchar2<\/span>(<span style=\"color: #800000; font-weight: bold;\">50<\/span><span style=\"color: #000000;\">),\n\n   comment2 <\/span><span style=\"color: #0000ff;\">varchar2<\/span>(<span style=\"color: #800000; font-weight: bold;\">50<\/span><span style=\"color: #000000;\">)\n\n);\n\n \n\n<\/span><span style=\"color: #0000ff;\">create<\/span><span style=\"color: #000000;\"> sequence user_test_seq\n\nINCREMENT <\/span><span style=\"color: #0000ff;\">BY<\/span> <span style=\"color: #800000; font-weight: bold;\">1<\/span> <span style=\"color: #008080;\">--<\/span><span style=\"color: #008080;\"> \u6bcf\u6b21\u52a0\u51e0\u4e2a<\/span>\n<span style=\"color: #000000;\">\nSTART <\/span><span style=\"color: #0000ff;\">WITH<\/span> <span style=\"color: #800000; font-weight: bold;\">1<\/span> <span style=\"color: #008080;\">--<\/span><span style=\"color: #008080;\"> \u4ece1\u5f00\u59cb\u8ba1\u6570<\/span>\n<span style=\"color: #000000;\">\n \n\ninsert\u53d8\u6210\u8fd9\u6837\u5199\uff1a\n\n<\/span><span style=\"color: #0000ff;\">insert<\/span> <span style=\"color: #0000ff;\">into<\/span> user_test(msisdn,<span style=\"color: #ff00ff;\">user_name<\/span>,dt,comment1,comment2) <span style=\"color: #0000ff;\">values<\/span>(<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">13597093898<\/span><span style=\"color: #ff0000;\">'<\/span>,<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">\u5f20\u4e0942<\/span><span style=\"color: #ff0000;\">'<\/span>,to_date(<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">2013\/2\/8 20:00:01<\/span><span style=\"color: #ff0000;\">'<\/span>,<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">yyyy\/mm\/dd HH24:mi:ss<\/span><span style=\"color: #ff0000;\">'<\/span>),<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">yyyy<\/span><span style=\"color: #ff0000;\">'<\/span>,<span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">yyyyy<\/span><span style=\"color: #ff0000;\">'<\/span><span style=\"color: #000000;\"&gt;);\n\n <\/span><\/span><\/pre>\n<\/div>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u89e6\u53d1\u5668\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<div class=\"cnblogs_code\">\n<pre><span style=\"font-size: 14px;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #808080;\">OR<\/span> <span style=\"color: #ff00ff;\">REPLACE<\/span> <span style=\"color: #0000ff;\">TRIGGER<\/span><span style=\"color: #000000;\"> my_trigger\n\n  BEFORE <\/span><span style=\"color: #0000ff;\">INSERT<\/span>\n\n  <span style=\"color: #0000ff;\">ON<\/span> user_test  <span style=\"color: #0000ff;\">FOR<\/span><span style=\"color: #000000;\"> EACH ROW\n\n<\/span><span style=\"color: #0000ff;\">WHEN<\/span> (new.seq <span style=\"color: #0000ff;\">is<\/span> <span style=\"color: #0000ff;\">null<\/span><span style=\"color: #000000;\">)\n\n<\/span><span style=\"color: #0000ff;\">BEGIN<\/span>\n\n  <span style=\"color: #0000ff;\">SELECT<\/span> user_test_seq.nextval <span style=\"color: #0000ff;\">INTO<\/span> :new.seq  <span style=\"color: #0000ff;\">FROM<\/span><span style=\"color: #000000;\"> DUAL;\n\n<\/span><span style=\"color: #0000ff;\">END<\/span> my_trigger;<\/span><\/pre>\n<\/div>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5176\u4e2d:new.seq\u662f\u6307\u65b0\u5217\u4e2d\u7684seq\u5b57\u6bb5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u4e3a\u66f4\u597d\u7684\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c \u4e0b\u9762\u4ecb\u7ecd\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">2. \u5199loader<\/span><\/p>\n<p lang=\"en-US\"><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">1\uff09 \u628aexcel\u4e2d\u7684\u6570\u636e\u53e6\u5b58\u4e3a.csv\u6587\u4ef6\uff0c\u5b57\u6bb5\u9017\u53f7\u5206\u9694\u3002\u5047\u8bbe\u4fdd\u5b58\u4e3agov.csv<\/span><\/p>\n<p><span style=\"font-size: 14px;\">2 \uff09\u5199ctl\u6587\u4ef6\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;gov.ctl<\/span><\/p>\n<div class=\"cnblogs_code\">\n<pre><span style=\"font-size: 14px;\"><span style=\"color: #0000ff;\">LOAD<\/span><span style=\"color: #000000;\"> DATA\n\nINFILE <\/span><span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">gov.csv<\/span><span style=\"color: #ff0000;\">'<\/span><span style=\"color: #000000;\">\n\nAPPEND\n\n<\/span><span style=\"color: #0000ff;\">INTO<\/span> <span style=\"color: #0000ff;\">TABLE<\/span><span style=\"color: #000000;\">  user_test\n\nFIELDS TERMINATED <\/span><span style=\"color: #0000ff;\">BY<\/span> <span style=\"color: #ff0000;\">'<\/span><span style=\"color: #ff0000;\">,<\/span><span style=\"color: #ff0000;\">'<\/span><span style=\"color: #000000;\">\n\ntrailing nullcols\n\n<\/span><span style=\"color: #808080;\">\/\/<\/span><span style=\"color: #000000;\">\u4e0b\u9762\u5217\u5148\u540e\u987a\u5e8f\u540c\u6587\u4ef6\u4e2d\u6570\u636e\u5b57\u6bb5\u7684\u987a\u5e8f\u3002\n\n(\n\nseq \"user_test_seq.nextval\",\n\nMSISDN,\n\n<\/span><span style=\"color: #ff00ff;\">user_name<\/span><span style=\"color: #000000;\">,\n\nDT date \"yyyy\/mm\/dd HH24:mi\",\n\ncomment1 ,\n\ncomment2\n\n)<\/span><\/span><\/pre>\n<\/div>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">3\uff09 \u5199par\u6587\u4ef6, \u5047\u8bbe\u540d\u4e3atest.par\uff0c\u5176\u5185\u5bb9\u4e3a\uff1a<\/span><\/p>\n<div class=\"cnblogs_code\">\n<pre><span style=\"font-size: 14px;\">userid<span style=\"color: #808080;\">=<\/span>\u7528\u6237<span style=\"color: #808080;\">\/<\/span><span style=\"color: #000000;\">\u5bc6\u7801\n\ncontrol<\/span><span style=\"color: #808080;\">=<\/span>.<span style=\"color: #808080;\">\/<\/span><span style=\"color: #000000;\">gov.ctl\n\n<\/span><span style=\"color: #ff00ff;\">log<\/span><span style=\"color: #808080;\">=<\/span>.<span style=\"color: #808080;\">\/<\/span>t.<span style=\"color: #ff00ff;\">log<\/span><span style=\"color: #000000;\">\n\nbad<\/span><span style=\"color: #808080;\">=<\/span>.<span style=\"color: #808080;\">\/<\/span><span style=\"color: #000000;\">t.bad\n\nskip<\/span><span style=\"color: #808080;\">=<\/span><span style=\"color: #800000; font-weight: bold;\">1<\/span>            <span style=\"color: #808080;\">\/\/<\/span><span style=\"color: #000000;\">\u8df3\u8fc7\u7b2c\u4e00\u884c\u6807\u9898\n\nrows<\/span><span style=\"color: #808080;\">=<\/span><span style=\"color: #800000; font-weight: bold;\">10000<\/span>   <span style=\"color: #808080;\">\/\/<\/span>\u6bcfn\u884ccommit\u4e00\u6b21<\/span><\/pre>\n<\/div>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">4\uff09sqlldr parfile=test.par<\/span><\/p>\n<p lang=\"en-US\"><span style=\"font-size: 14px;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5728\u6211\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u5bfc\u5165\u767e\u591a\u4e07\u7684\u6570\u636e\u5e94\u8be5\u662f\u4e00\u5206\u949f\u4e4b\u5185\u7684\u4e8b\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u91cc\u4ecb\u7ecd2\u79cd\u628aexcel\u6570\u636e\u5bfc\u5165oracle\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u3002 &nbsp; 1.  &hellip; <a href=\"https:\/\/blog.fs.cloudns.biz\/index.php\/2023\/08\/18\/%e5%a6%82%e4%bd%95%e6%8a%8aexcel%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae%e5%ba%93\/\">\u7ee7\u7eed\u9605\u8bfb <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":{"footnotes":""},"categories":[8,1],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-8","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":1,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":318,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/270\/revisions\/318"}],"wp:attachment":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}