{"id":160225,"date":"2024-11-03T21:19:21","date_gmt":"2024-11-03T13:19:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/160225\/"},"modified":"2024-11-03T21:19:22","modified_gmt":"2024-11-03T13:19:22","slug":"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-schema-%e5%b0%8d%e8%b1%a1%e5%91%bd%e5%90%8d%e6%ba%96%e5%89%87","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/160225\/","title":{"rendered":"OceanBase \u6559\u7a0b\uff1aOceanBase Schema \u5c0d\u8c61\u547d\u540d\u6e96\u5247"},"content":{"rendered":"<h1 id=\"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-schema-%e5%b0%8d%e8%b1%a1%e5%91%bd%e5%90%8d%e6%ba%96%e5%89%87-UzaXWKzlxG\">OceanBase \u6559\u7a0b\uff1aOceanBase Schema \u5c0d\u8c61\u547d\u540d\u6e96\u5247<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0c\u547d\u540d\u6e96\u5247\u5c0d\u65bc\u7dad\u8b77\u6578\u64da\u5eab\u7684\u53ef\u8b80\u6027\u548c\u53ef\u7dad\u8b77\u6027\u81f3\u95dc\u91cd\u8981\u3002OceanBase \u4f5c\u70ba\u4e00\u6b3e\u9ad8\u6027\u80fd\u7684\u5206\u4f48\u5f0f\u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u9748\u6d3b\u7684\u67b6\u69cb\u548c\u5f37\u5927\u7684\u529f\u80fd\u3002\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e OceanBase \u7684 Schema \u5c0d\u8c61\u547d\u540d\u6e96\u5247\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u66f4\u597d\u5730\u8a2d\u8a08\u548c\u7ba1\u7406\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-oceanbase-schema%ef%bc%9f-UzaXWKzlxG\">\u4ec0\u9ebc\u662f OceanBase Schema\uff1f<\/h2>\n<p>\u5728 OceanBase \u4e2d\uff0cSchema \u662f\u6578\u64da\u5eab\u7684\u7d50\u69cb\u5b9a\u7fa9\uff0c\u5305\u62ec\u8868\u3001\u7d22\u5f15\u3001\u8996\u5716\u3001\u5b58\u5132\u904e\u7a0b\u7b49\u5c0d\u8c61\u3002Schema \u5b9a\u7fa9\u4e86\u6578\u64da\u7684\u7d44\u7e54\u65b9\u5f0f\uff0c\u4e26\u4e14\u5f71\u97ff\u5230\u6578\u64da\u7684\u5b58\u53d6\u6548\u7387\u548c\u7dad\u8b77\u96e3\u5ea6\u3002\u56e0\u6b64\uff0c\u5408\u7406\u7684\u547d\u540d\u6e96\u5247\u80fd\u5920\u63d0\u9ad8\u958b\u767c\u6548\u7387\uff0c\u6e1b\u5c11\u932f\u8aa4\u767c\u751f\u7684\u6a5f\u6703\u3002<\/p>\n<h2 id=\"%e5%91%bd%e5%90%8d%e6%ba%96%e5%89%87%e7%9a%84%e9%87%8d%e8%a6%81%e6%80%a7-UzaXWKzlxG\">\u547d\u540d\u6e96\u5247\u7684\u91cd\u8981\u6027<\/h2>\n<p>\u826f\u597d\u7684\u547d\u540d\u6e96\u5247\u4e0d\u50c5\u80fd\u5920\u63d0\u9ad8\u4ee3\u78bc\u7684\u53ef\u8b80\u6027\uff0c\u9084\u80fd\u4fc3\u9032\u5718\u968a\u5354\u4f5c\u3002\u7576\u591a\u4f4d\u958b\u767c\u8005\u5171\u540c\u7dad\u8b77\u4e00\u500b\u6578\u64da\u5eab\u6642\uff0c\u7d71\u4e00\u7684\u547d\u540d\u898f\u7bc4\u80fd\u5920\u5e6b\u52a9\u4ed6\u5011\u5feb\u901f\u7406\u89e3\u6578\u64da\u7d50\u69cb\uff0c\u5f9e\u800c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002\u6b64\u5916\uff0c\u6e05\u6670\u7684\u547d\u540d\u9084\u80fd\u6e1b\u5c11\u672a\u4f86\u7dad\u8b77\u904e\u7a0b\u4e2d\u7684\u56f0\u60d1\u548c\u932f\u8aa4\u3002<\/p>\n<h2 id=\"oceanbase-schema-%e5%b0%8d%e8%b1%a1%e7%9a%84%e5%91%bd%e5%90%8d%e6%ba%96%e5%89%87-UzaXWKzlxG\">OceanBase Schema \u5c0d\u8c61\u7684\u547d\u540d\u6e96\u5247<\/h2>\n<h3 id=\"1-%e8%a1%a8%e7%9a%84%e5%91%bd%e5%90%8d-UzaXWKzlxG\">1. \u8868\u7684\u547d\u540d<\/h3>\n<ul>\n<li>\u4f7f\u7528\u5c0f\u5beb\u5b57\u6bcd\uff1a\u8868\u540d\u61c9\u8a72\u4f7f\u7528\u5c0f\u5beb\u5b57\u6bcd\uff0c\u4e26\u4e14\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5283\u7dda\uff08_\uff09\u5206\u9694\u55ae\u8a5e\u3002\u4f8b\u5982\uff1a<code>user_profile<\/code>\u3002<\/li>\n<li>\u63cf\u8ff0\u6027\u547d\u540d\uff1a\u8868\u540d\u61c9\u8a72\u80fd\u5920\u6e05\u6670\u5730\u63cf\u8ff0\u5176\u5167\u5bb9\u3002\u4f8b\u5982\uff1a<code>order_details<\/code> \u8868\u793a\u8a02\u55ae\u8a73\u7d30\u4fe1\u606f\u3002<\/li>\n<li>\u907f\u514d\u4f7f\u7528\u4fdd\u7559\u5b57\uff1a\u5728\u547d\u540d\u8868\u6642\uff0c\u61c9\u907f\u514d\u4f7f\u7528 SQL \u7684\u4fdd\u7559\u5b57\uff0c\u4ee5\u514d\u9020\u6210\u8a9e\u6cd5\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e5%88%97%e7%9a%84%e5%91%bd%e5%90%8d-UzaXWKzlxG\">2. \u5217\u7684\u547d\u540d<\/h3>\n<ul>\n<li>\u4f7f\u7528\u5c0f\u5beb\u5b57\u6bcd\uff1a\u5217\u540d\u540c\u6a23\u61c9\u4f7f\u7528\u5c0f\u5beb\u5b57\u6bcd\uff0c\u4e26\u4e14\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5283\u7dda\u5206\u9694\u55ae\u8a5e\u3002\u4f8b\u5982\uff1a<code>first_name<\/code>\u3002<\/li>\n<li>\u5177\u9ad4\u4e14\u7c21\u6f54\uff1a\u5217\u540d\u61c9\u8a72\u5177\u9ad4\u4e14\u7c21\u6f54\uff0c\u80fd\u5920\u6e05\u695a\u5730\u8868\u9054\u5176\u5b58\u5132\u7684\u6578\u64da\u3002\u4f8b\u5982\uff1a<code>created_at<\/code> \u8868\u793a\u5275\u5efa\u6642\u9593\u3002<\/li>\n<li>\u907f\u514d\u4f7f\u7528\u7e2e\u5beb\uff1a\u9664\u975e\u662f\u975e\u5e38\u5e38\u898b\u7684\u7e2e\u5beb\uff0c\u5426\u5247\u61c9\u907f\u514d\u4f7f\u7528\uff0c\u4ee5\u514d\u9020\u6210\u7406\u89e3\u4e0a\u7684\u56f0\u96e3\u3002<\/li>\n<\/ul>\n<h3 id=\"3-%e7%b4%a2%e5%bc%95%e7%9a%84%e5%91%bd%e5%90%8d-UzaXWKzlxG\">3. \u7d22\u5f15\u7684\u547d\u540d<\/h3>\n<ul>\n<li>\u4ee5\u8868\u540d\u958b\u982d\uff1a\u7d22\u5f15\u540d\u61c9\u4ee5\u5176\u6240\u5c6c\u8868\u7684\u540d\u7a31\u958b\u982d\uff0c\u5f8c\u63a5\u7d22\u5f15\u7684\u7279\u6027\u3002\u4f8b\u5982\uff1a<code>idx_user_profile_email<\/code> \u8868\u793a\u7528\u65bc <code>user_profile<\/code> \u8868\u7684\u96fb\u5b50\u90f5\u4ef6\u7d22\u5f15\u3002<\/li>\n<li>\u63cf\u8ff0\u6027\u547d\u540d\uff1a\u7d22\u5f15\u540d\u61c9\u8a72\u80fd\u5920\u63cf\u8ff0\u5176\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<code>idx_order_created_at<\/code> \u8868\u793a\u91dd\u5c0d\u8a02\u55ae\u5275\u5efa\u6642\u9593\u7684\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<h3 id=\"4-%e8%a6%96%e5%9c%96%e7%9a%84%e5%91%bd%e5%90%8d-UzaXWKzlxG\">4. \u8996\u5716\u7684\u547d\u540d<\/h3>\n<ul>\n<li>\u4ee5\u524d\u7db4\u201cv_\u201d\u958b\u982d\uff1a\u8996\u5716\u540d\u61c9\u4ee5\u201cv_\u201d\u4f5c\u70ba\u524d\u7db4\uff0c\u4ee5\u4fbf\u65bc\u5340\u5206\u3002\u4f8b\u5982\uff1a<code>v_user_summary<\/code>\u3002<\/li>\n<li>\u63cf\u8ff0\u6027\u547d\u540d\uff1a\u8996\u5716\u540d\u61c9\u8a72\u80fd\u5920\u6e05\u695a\u5730\u8868\u9054\u5176\u5167\u5bb9\u548c\u7528\u9014\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%91%bd%e5%90%8d%e6%ba%96%e5%89%87%e7%9a%84%e5%af%a6%e8%b8%90-UzaXWKzlxG\">\u547d\u540d\u6e96\u5247\u7684\u5be6\u8e10<\/h2>\n<p>\u5728\u5be6\u969b\u958b\u767c\u4e2d\uff0c\u9075\u5faa\u9019\u4e9b\u547d\u540d\u6e96\u5247\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u53ef\u7dad\u8b77\u6027\u548c\u53ef\u8b80\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u6839\u64da\u4e0a\u8ff0\u6e96\u5247\u8a2d\u8a08\u4e00\u500b\u7c21\u55ae\u7684 OceanBase Schema\uff1a<\/p>\n<pre><code>\nCREATE TABLE user_profile (\n    user_id INT PRIMARY KEY,\n    first_name VARCHAR(50),\n    last_name VARCHAR(50),\n    email VARCHAR(100),\n    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE INDEX idx_user_profile_email ON user_profile(email);\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-UzaXWKzlxG\">\u7e3d\u7d50<\/h2>\n<p>\u5728 OceanBase \u7684\u958b\u767c\u904e\u7a0b\u4e2d\uff0c\u9075\u5faa Schema \u5c0d\u8c61\u7684\u547d\u540d\u6e96\u5247\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u9019\u4e0d\u50c5\u80fd\u5920\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u53ef\u8b80\u6027\uff0c\u9084\u80fd\u4fc3\u9032\u5718\u968a\u7684\u5354\u4f5c\u3002\u901a\u904e\u5408\u7406\u7684\u547d\u540d\u898f\u7bc4\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u7ba1\u7406\u548c\u7dad\u8b77\u6578\u64da\u5eab\uff0c\u5f9e\u800c\u63d0\u9ad8\u6574\u9ad4\u5de5\u4f5c\u6548\u7387\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u4e86\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3 OceanBase Schema \u5c0d\u8c61\u547d\u540d\u6e96\u5247\uff0c\u63d0\u5347\u6578\u64da\u5eab\u8a2d\u8a08\u6548\u7387\uff0c\u78ba\u4fdd\u4e00\u81f4\u6027\u8207\u53ef\u7dad\u8b77\u6027\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-160225","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160225","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=160225"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160225\/revisions"}],"predecessor-version":[{"id":160226,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160225\/revisions\/160226"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=160225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=160225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=160225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}