{"id":169995,"date":"2024-11-06T20:16:19","date_gmt":"2024-11-06T12:16:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/169995\/"},"modified":"2024-11-06T20:16:20","modified_gmt":"2024-11-06T12:16:20","slug":"%e9%82%a3%e4%ba%9boracle%e7%a7%bb%e6%a4%8d%e5%88%b0mysql%e5%80%bc%e5%be%97%e6%88%91%e5%80%91%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a0%85","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/169995\/","title":{"rendered":"\u90a3\u4e9bOracle\u79fb\u690d\u5230MySQL\u503c\u5f97\u6211\u5011\u6ce8\u610f\u7684\u4e8b\u9805"},"content":{"rendered":"<h1 id=\"%e9%82%a3%e4%ba%9boracle%e7%a7%bb%e6%a4%8d%e5%88%b0mysql%e5%80%bc%e5%be%97%e6%88%91%e5%80%91%e6%b3%a8%e6%84%8f%e7%9a%84%e4%ba%8b%e9%a0%85-YXszgaJxwN\">\u90a3\u4e9bOracle\u79fb\u690d\u5230MySQL\u503c\u5f97\u6211\u5011\u6ce8\u610f\u7684\u4e8b\u9805<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0cOracle\u548cMySQL\u90fd\u662f\u975e\u5e38\u6d41\u884c\u7684\u9078\u64c7\u3002\u96a8\u8457\u4f01\u696d\u9700\u6c42\u7684\u8b8a\u5316\uff0c\u8a31\u591a\u516c\u53f8\u9078\u64c7\u5c07\u5176\u6578\u64da\u5eab\u5f9eOracle\u79fb\u690d\u5230MySQL\u3002\u9019\u4e00\u904e\u7a0b\u96d6\u7136\u53ef\u4ee5\u5e36\u4f86\u6210\u672c\u6548\u76ca\u548c\u9748\u6d3b\u6027\uff0c\u4f46\u4e5f\u4f34\u96a8\u8457\u4e00\u4e9b\u6311\u6230\u548c\u6ce8\u610f\u4e8b\u9805\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5728Oracle\u79fb\u690d\u5230MySQL\u6642\u9700\u8981\u6ce8\u610f\u7684\u5e7e\u500b\u95dc\u9375\u65b9\u9762\u3002<\/p>\n<h2 id=\"1-%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%b7%ae%e7%95%b0-YXszgaJxwN\">1. \u6578\u64da\u985e\u578b\u7684\u5dee\u7570<\/h2>\n<p>Oracle\u548cMySQL\u5728\u6578\u64da\u985e\u578b\u7684\u652f\u6301\u4e0a\u5b58\u5728\u4e00\u4e9b\u5dee\u7570\u3002\u4f8b\u5982\uff0cOracle\u7684\u6578\u64da\u985e\u578b\u5305\u62ecNUMBER\u3001VARCHAR2\u548cCLOB\uff0c\u800cMySQL\u5247\u4f7f\u7528INT\u3001VARCHAR\u548cTEXT\u7b49\u985e\u578b\u3002\u5728\u79fb\u690d\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u9700\u8981\u4ed4\u7d30\u6aa2\u67e5\u6bcf\u500b\u5b57\u6bb5\u7684\u6578\u64da\u985e\u578b\uff0c\u4e26\u78ba\u4fdd\u5728MySQL\u4e2d\u9078\u64c7\u5408\u9069\u7684\u5c0d\u61c9\u985e\u578b\u3002<\/p>\n<pre><code>-- Oracle\nCREATE TABLE employees (\n    id NUMBER PRIMARY KEY,\n    name VARCHAR2(100),\n    bio CLOB\n);\n\n-- MySQL\nCREATE TABLE employees (\n    id INT PRIMARY KEY,\n    name VARCHAR(100),\n    bio TEXT\n);\n<\/code><\/pre>\n<h2 id=\"2-sql%e8%aa%9e%e6%b3%95%e7%9a%84%e5%b7%ae%e7%95%b0-YXszgaJxwN\">2. SQL\u8a9e\u6cd5\u7684\u5dee\u7570<\/h2>\n<p>Oracle\u548cMySQL\u5728SQL\u8a9e\u6cd5\u4e0a\u4e5f\u6709\u4e00\u4e9b\u4e0d\u540c\u4e4b\u8655\u3002\u4f8b\u5982\uff0cOracle\u4f7f\u7528\u7684\u5e8f\u5217\uff08SEQUENCE\uff09\u5728MySQL\u4e2d\u5247\u53ef\u4ee5\u4f7f\u7528\u81ea\u589e\uff08AUTO_INCREMENT\uff09\u4f86\u5be6\u73fe\u3002\u9019\u610f\u5473\u8457\u5728\u79fb\u690d\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u9700\u8981\u91cd\u65b0\u8a2d\u8a08\u67d0\u4e9b\u67e5\u8a62\u548c\u6578\u64da\u63d2\u5165\u7684\u908f\u8f2f\u3002<\/p>\n<pre><code>-- Oracle\nCREATE SEQUENCE emp_seq START WITH 1 INCREMENT BY 1;\n\n-- MySQL\nCREATE TABLE employees (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    name VARCHAR(100)\n);\n<\/code><\/pre>\n<h2 id=\"3-%e4%ba%8b%e5%8b%99%e8%99%95%e7%90%86%e5%92%8c%e9%8e%96%e5%ae%9a%e6%a9%9f%e5%88%b6-YXszgaJxwN\">3. \u4e8b\u52d9\u8655\u7406\u548c\u9396\u5b9a\u6a5f\u5236<\/h2>\n<p>Oracle\u7684\u4e8b\u52d9\u8655\u7406\u548c\u9396\u5b9a\u6a5f\u5236\u76f8\u5c0d\u65bcMySQL\u4f86\u8aaa\u66f4\u70ba\u8907\u96dc\u3002Oracle\u652f\u6301\u591a\u7248\u672c\u4e26\u767c\u63a7\u5236\uff08MVCC\uff09\uff0c\u800cMySQL\u7684InnoDB\u5f15\u64ce\u4e5f\u652f\u6301MVCC\uff0c\u4f46\u5728\u5be6\u73fe\u4e0a\u6709\u6240\u4e0d\u540c\u3002\u5728\u79fb\u690d\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u9700\u8981\u8003\u616e\u5982\u4f55\u8655\u7406\u4e8b\u52d9\u7684\u9694\u96e2\u7d1a\u5225\u548c\u9396\u5b9a\u7b56\u7565\uff0c\u4ee5\u78ba\u4fdd\u6578\u64da\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<h2 id=\"4-%e5%ad%98%e5%84%b2%e9%81%8e%e7%a8%8b%e5%92%8c%e8%a7%b8%e7%99%bc%e5%99%a8-YXszgaJxwN\">4. \u5b58\u5132\u904e\u7a0b\u548c\u89f8\u767c\u5668<\/h2>\n<p>Oracle\u7684\u5b58\u5132\u904e\u7a0b\u548c\u89f8\u767c\u5668\u529f\u80fd\u5f37\u5927\uff0c\u4f46MySQL\u7684\u652f\u6301\u76f8\u5c0d\u8f03\u5f31\u3002\u5728\u79fb\u690d\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u9700\u8981\u8a55\u4f30\u73fe\u6709\u7684\u5b58\u5132\u904e\u7a0b\u548c\u89f8\u767c\u5668\uff0c\u4e26\u8003\u616e\u662f\u5426\u9700\u8981\u91cd\u5beb\u6216\u7c21\u5316\u9019\u4e9b\u908f\u8f2f\uff0c\u4ee5\u9069\u61c9MySQL\u7684\u7279\u6027\u3002<\/p>\n<pre><code>-- Oracle\nCREATE OR REPLACE PROCEDURE update_salary (emp_id NUMBER, new_salary NUMBER) AS\nBEGIN\n    UPDATE employees SET salary = new_salary WHERE id = emp_id;\nEND;\n\n-- MySQL\nDELIMITER \/\/\nCREATE PROCEDURE update_salary(IN emp_id INT, IN new_salary DECIMAL(10,2))\nBEGIN\n    UPDATE employees SET salary = new_salary WHERE id = emp_id;\nEND \/\/\nDELIMITER ;\n<\/code><\/pre>\n<h2 id=\"5-%e6%80%a7%e8%83%bd%e5%84%aa%e5%8c%96-YXszgaJxwN\">5. \u6027\u80fd\u512a\u5316<\/h2>\n<p>\u5728\u79fb\u690d\u904e\u7a0b\u4e2d\uff0c\u6027\u80fd\u512a\u5316\u662f\u4e00\u500b\u91cd\u8981\u7684\u8003\u91cf\u56e0\u7d20\u3002MySQL\u548cOracle\u5728\u67e5\u8a62\u512a\u5316\u548c\u7d22\u5f15\u7ba1\u7406\u4e0a\u6709\u4e0d\u540c\u7684\u7b56\u7565\u3002\u958b\u767c\u8005\u9700\u8981\u5c0d\u67e5\u8a62\u9032\u884c\u6027\u80fd\u6e2c\u8a66\uff0c\u4e26\u6839\u64daMySQL\u7684\u7279\u6027\u9032\u884c\u8abf\u6574\uff0c\u4ee5\u78ba\u4fdd\u7cfb\u7d71\u7684\u9ad8\u6548\u904b\u884c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-YXszgaJxwN\">\u7e3d\u7d50<\/h2>\n<p>\u5c07Oracle\u6578\u64da\u5eab\u79fb\u690d\u5230MySQL\u662f\u4e00\u500b\u8907\u96dc\u7684\u904e\u7a0b\uff0c\u9700\u8981\u8003\u616e\u6578\u64da\u985e\u578b\u3001SQL\u8a9e\u6cd5\u3001\u4e8b\u52d9\u8655\u7406\u3001\u5b58\u5132\u904e\u7a0b\u53ca\u6027\u80fd\u512a\u5316\u7b49\u591a\u65b9\u9762\u7684\u56e0\u7d20\u3002\u901a\u904e\u4ed4\u7d30\u898f\u5283\u548c\u6e2c\u8a66\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u6e1b\u5c11\u79fb\u690d\u904e\u7a0b\u4e2d\u7684\u554f\u984c\uff0c\u4e26\u78ba\u4fdd\u6578\u64da\u7684\u5b8c\u6574\u6027\u548c\u7cfb\u7d71\u7684\u7a69\u5b9a\u6027\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Oracle\u79fb\u690d\u5230MySQL\u7684\u5173\u952e\u6ce8\u610f\u4e8b\u9879\uff0c\u786e\u4fdd\u6570\u636e\u5b8c\u6574\u6027\u4e0e\u6027\u80fd\u4f18\u5316\uff0c\u52a9\u529b\u987a\u5229\u8fc1\u79fb\u4e0e\u7cfb\u7edf\u517c\u5bb9\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-169995","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/169995","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=169995"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/169995\/revisions"}],"predecessor-version":[{"id":169996,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/169995\/revisions\/169996"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=169995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=169995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=169995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}