{"id":95410,"date":"2024-10-20T00:49:17","date_gmt":"2024-10-19T16:49:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/95410\/"},"modified":"2024-10-20T00:49:18","modified_gmt":"2024-10-19T16:49:18","slug":"oracle%e6%95%b8%e6%93%9a%e5%b0%8e%e5%85%a5sql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/95410\/","title":{"rendered":"Oracle\u6578\u64da\u5c0e\u5165SQL\u6578\u64da\u5eab\u7684\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"oracle%e6%95%b8%e6%93%9a%e5%b0%8e%e5%85%a5sql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%96%b9%e6%b3%95-cqfdZzlsPe\">Oracle\u6578\u64da\u5c0e\u5165SQL\u6578\u64da\u5eab\u7684\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u7684\u6709\u6548\u7ba1\u7406\u548c\u8f49\u79fb\u81f3\u95dc\u91cd\u8981\u3002\u8a31\u591a\u4f01\u696d\u4f7f\u7528Oracle\u6578\u64da\u5eab\u4f86\u5b58\u5132\u548c\u7ba1\u7406\u5176\u6578\u64da\uff0c\u800cSQL\u6578\u64da\u5eab\u5247\u662f\u53e6\u4e00\u500b\u6d41\u884c\u7684\u9078\u64c7\u3002\u5c07\u6578\u64da\u5f9eOracle\u5c0e\u5165SQL\u6578\u64da\u5eab\u7684\u904e\u7a0b\u53ef\u80fd\u6703\u6d89\u53ca\u591a\u500b\u6b65\u9a5f\uff0c\u672c\u6587\u5c07\u63a2\u8a0e\u5e7e\u7a2e\u5e38\u898b\u7684\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e6%96%b9%e6%b3%95%e4%b8%80%ef%bc%9a%e4%bd%bf%e7%94%a8sql-developer-cqfdZzlsPe\">\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528SQL Developer<\/h2>\n<p>SQL Developer\u662f\u4e00\u500b\u7531Oracle\u63d0\u4f9b\u7684\u514d\u8cbb\u5de5\u5177\uff0c\u80fd\u5920\u8f15\u9b06\u5730\u5c07\u6578\u64da\u5f9eOracle\u6578\u64da\u5eab\u5c0e\u5165\u5230SQL Server\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528SQL Developer\u7684\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li><strong>\u5b89\u88ddSQL Developer\uff1a<\/strong>\u9996\u5148\uff0c\u4e0b\u8f09\u4e26\u5b89\u88ddSQL Developer\u3002<\/li>\n<li><strong>\u5efa\u7acb\u9023\u63a5\uff1a<\/strong>\u5728SQL Developer\u4e2d\uff0c\u5efa\u7acb\u5230Oracle\u6578\u64da\u5eab\u7684\u9023\u63a5\u3002<\/li>\n<li><strong>\u5c0e\u51fa\u6578\u64da\uff1a<\/strong>\u9078\u64c7\u8981\u5c0e\u51fa\u7684\u8868\uff0c\u53f3\u9375\u9ede\u64ca\u4e26\u9078\u64c7\u201c\u5c0e\u51fa\u201d\u3002\u9078\u64c7CSV\u6216\u5176\u4ed6\u683c\u5f0f\u3002<\/li>\n<li><strong>\u5c0e\u5165\u5230SQL Server\uff1a<\/strong>\u4f7f\u7528SQL Server Management Studio (SSMS) \u5c07\u5c0e\u51fa\u7684\u6587\u4ef6\u5c0e\u5165\u5230SQL Server\u4e2d\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%96%b9%e6%b3%95%e4%ba%8c%ef%bc%9a%e4%bd%bf%e7%94%a8oracle%e7%9a%84data-pump-cqfdZzlsPe\">\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528Oracle\u7684Data Pump<\/h2>\n<p>Oracle\u7684Data Pump\u662f\u4e00\u500b\u9ad8\u6548\u7684\u6578\u64da\u8f49\u79fb\u5de5\u5177\uff0c\u9069\u5408\u5927\u898f\u6a21\u6578\u64da\u7684\u5c0e\u51fa\u548c\u5c0e\u5165\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Data Pump\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li><strong>\u5c0e\u51fa\u6578\u64da\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c0e\u51fa\u6578\u64da\uff1a<\/li>\n<pre><code>expdp username\/password DIRECTORY=dir_name DUMPFILE=data.dmp LOGFILE=export.log schemas=schema_name<\/code><\/pre>\n<li><strong>\u8f49\u63db\u6578\u64da\uff1a<\/strong>\u5c07\u5c0e\u51fa\u7684DUMP\u6587\u4ef6\u8f49\u63db\u70baSQL Server\u53ef\u8b80\u7684\u683c\u5f0f\uff0c\u9019\u901a\u5e38\u9700\u8981\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\u3002<\/li>\n<li><strong>\u5c0e\u5165\u5230SQL Server\uff1a<\/strong>\u4f7f\u7528SSMS\u5c07\u8f49\u63db\u5f8c\u7684\u6578\u64da\u5c0e\u5165\u5230SQL Server\u4e2d\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%96%b9%e6%b3%95%e4%b8%89%ef%bc%9a%e4%bd%bf%e7%94%a8etl%e5%b7%a5%e5%85%b7-cqfdZzlsPe\">\u65b9\u6cd5\u4e09\uff1a\u4f7f\u7528ETL\u5de5\u5177<\/h2>\n<p>ETL\uff08\u63d0\u53d6\u3001\u8f49\u63db\u3001\u52a0\u8f09\uff09\u5de5\u5177\u5982Talend\u3001Informatica\u7b49\uff0c\u80fd\u5920\u81ea\u52d5\u5316\u6578\u64da\u7684\u8f49\u79fb\u904e\u7a0b\u3002\u9019\u4e9b\u5de5\u5177\u901a\u5e38\u63d0\u4f9b\u7528\u6236\u53cb\u597d\u7684\u754c\u9762\uff0c\u4e26\u652f\u6301\u591a\u7a2e\u6578\u64da\u6e90\u548c\u76ee\u6a19\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528ETL\u5de5\u5177\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li><strong>\u8a2d\u7f6e\u9023\u63a5\uff1a<\/strong>\u5728ETL\u5de5\u5177\u4e2d\u8a2d\u7f6e\u5230Oracle\u548cSQL Server\u7684\u9023\u63a5\u3002<\/li>\n<li><strong>\u63d0\u53d6\u6578\u64da\uff1a<\/strong>\u5f9eOracle\u6578\u64da\u5eab\u63d0\u53d6\u6240\u9700\u7684\u6578\u64da\u3002<\/li>\n<li><strong>\u8f49\u63db\u6578\u64da\uff1a<\/strong>\u6839\u64da\u9700\u8981\u8f49\u63db\u6578\u64da\u683c\u5f0f\u3002<\/li>\n<li><strong>\u52a0\u8f09\u6578\u64da\uff1a<\/strong>\u5c07\u8f49\u63db\u5f8c\u7684\u6578\u64da\u52a0\u8f09\u5230SQL Server\u4e2d\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%96%b9%e6%b3%95%e5%9b%9b%ef%bc%9a%e4%bd%bf%e7%94%a8%e8%87%aa%e5%ae%9a%e7%be%a9%e8%85%b3%e6%9c%ac-cqfdZzlsPe\">\u65b9\u6cd5\u56db\uff1a\u4f7f\u7528\u81ea\u5b9a\u7fa9\u8173\u672c<\/h2>\n<p>\u5c0d\u65bc\u4e00\u4e9b\u7279\u5b9a\u9700\u6c42\uff0c\u958b\u767c\u81ea\u5b9a\u7fa9\u8173\u672c\u4e5f\u662f\u4e00\u7a2e\u53ef\u884c\u7684\u65b9\u6cd5\u3002\u4f7f\u7528Python\u6216\u5176\u4ed6\u7de8\u7a0b\u8a9e\u8a00\uff0c\u53ef\u4ee5\u7de8\u5beb\u8173\u672c\u4f86\u81ea\u52d5\u5316\u6578\u64da\u7684\u63d0\u53d6\u548c\u52a0\u8f09\u904e\u7a0b\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684Python\u793a\u4f8b\uff1a<\/p>\n<pre><code>import cx_Oracle\nimport pyodbc\n\n# \u9023\u63a5\u5230Oracle\u6578\u64da\u5eab\noracle_conn = cx_Oracle.connect('username\/password@host:port\/service_name')\noracle_cursor = oracle_conn.cursor()\n\n# \u9023\u63a5\u5230SQL Server\nsql_conn = pyodbc.connect('DRIVER={SQL Server};SERVER=server_name;DATABASE=db_name;UID=user;PWD=password')\nsql_cursor = sql_conn.cursor()\n\n# \u63d0\u53d6\u6578\u64da\noracle_cursor.execute(\"SELECT * FROM table_name\")\nrows = oracle_cursor.fetchall()\n\n# \u52a0\u8f09\u6578\u64da\nfor row in rows:\n    sql_cursor.execute(\"INSERT INTO table_name (column1, column2) VALUES (?, ?)\", row[0], row[1])\n\nsql_conn.commit()\noracle_cursor.close()\nsql_conn.close()\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-cqfdZzlsPe\">\u7e3d\u7d50<\/h2>\n<p>\u5c07Oracle\u6578\u64da\u5c0e\u5165SQL\u6578\u64da\u5eab\u7684\u65b9\u6cd5\u6709\u591a\u7a2e\u9078\u64c7\uff0c\u5305\u62ec\u4f7f\u7528SQL Developer\u3001Data Pump\u3001ETL\u5de5\u5177\u4ee5\u53ca\u81ea\u5b9a\u7fa9\u8173\u672c\u3002\u6839\u64da\u5177\u9ad4\u9700\u6c42\u548c\u6578\u64da\u91cf\u7684\u4e0d\u540c\uff0c\u9078\u64c7\u5408\u9069\u7684\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8\u6578\u64da\u8f49\u79fb\u7684\u6548\u7387\u548c\u6e96\u78ba\u6027\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u7684\u6578\u64da\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\u7684\u4f01\u696d\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u652f\u6301\u5176\u6578\u64da\u8655\u7406\u9700\u6c42\u662f\u660e\u667a\u7684\u9078\u64c7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Oracle\u6578\u64da\u5c0e\u5165SQL\u6578\u64da\u5eab\u7684\u6709\u6548\u65b9\u6cd5\uff0c\u63d0\u5347\u6578\u64da\u7ba1\u7406\u6548\u7387\uff0c\u7c21\u5316\u6578\u64da\u9077\u79fb\u904e\u7a0b\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-95410","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=95410"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95410\/revisions"}],"predecessor-version":[{"id":95411,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95410\/revisions\/95411"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=95410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=95410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=95410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}