{"id":173355,"date":"2024-11-07T17:20:19","date_gmt":"2024-11-07T09:20:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/173355\/"},"modified":"2024-11-07T17:20:20","modified_gmt":"2024-11-07T09:20:20","slug":"%e5%a6%82%e4%bd%95%e8%a4%87%e8%a3%bd%e6%95%b8%e6%93%9a%e5%ba%ab%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b%ef%bc%9f-%e6%80%8e%e9%ba%bc%e8%a4%87%e8%a3%bd%e6%95%b8%e6%93%9a%e5%ba%ab%e8%a1%a8%e7%b5%90%e6%a7%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/173355\/","title":{"rendered":"\u5982\u4f55\u8907\u88fd\u6578\u64da\u5eab\u8868\u683c\u7d50\u69cb\uff1f (\u600e\u9ebc\u8907\u88fd\u6578\u64da\u5eab\u8868\u7d50\u69cb)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e8%a4%87%e8%a3%bd%e6%95%b8%e6%93%9a%e5%ba%ab%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b%ef%bc%9f-apvYWyNkoA\">\u5982\u4f55\u8907\u88fd\u6578\u64da\u5eab\u8868\u683c\u7d50\u69cb\uff1f<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0c\u8907\u88fd\u8868\u683c\u7d50\u69cb\u662f\u4e00\u500b\u5e38\u898b\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f\u70ba\u4e86\u5099\u4efd\u3001\u6e2c\u8a66\u9084\u662f\u958b\u767c\u65b0\u529f\u80fd\uff0c\u4e86\u89e3\u5982\u4f55\u6709\u6548\u5730\u8907\u88fd\u6578\u64da\u5eab\u8868\u683c\u7d50\u69cb\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5e7e\u7a2e\u5e38\u898b\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u4e2d\u8907\u88fd\u8868\u683c\u7d50\u69cb\u7684\u65b9\u6cd5\uff0c\u4e26\u63d0\u4f9b\u76f8\u61c9\u7684\u793a\u4f8b\u4ee3\u78bc\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e8%a4%87%e8%a3%bd%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b%ef%bc%9f-apvYWyNkoA\">\u70ba\u4ec0\u9ebc\u9700\u8981\u8907\u88fd\u8868\u683c\u7d50\u69cb\uff1f<\/h2>\n<p>\u8907\u88fd\u8868\u683c\u7d50\u69cb\u7684\u539f\u56e0\u6709\u5f88\u591a\uff0c\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u5099\u4efd\uff1a<\/strong>\u5728\u9032\u884c\u6578\u64da\u64cd\u4f5c\u4e4b\u524d\uff0c\u8907\u88fd\u8868\u683c\u7d50\u69cb\u53ef\u4ee5\u4f5c\u70ba\u4e00\u7a2e\u4fdd\u8b77\u63aa\u65bd\uff0c\u78ba\u4fdd\u539f\u59cb\u6578\u64da\u4e0d\u6703\u53d7\u5230\u5f71\u97ff\u3002<\/li>\n<li><strong>\u6e2c\u8a66\uff1a<\/strong>\u958b\u767c\u4eba\u54e1\u53ef\u4ee5\u5728\u8907\u88fd\u7684\u8868\u683c\u4e0a\u9032\u884c\u6e2c\u8a66\uff0c\u800c\u4e0d\u6703\u5f71\u97ff\u5230\u751f\u7522\u74b0\u5883\u4e2d\u7684\u6578\u64da\u3002<\/li>\n<li><strong>\u6578\u64da\u9077\u79fb\uff1a<\/strong>\u5728\u6578\u64da\u9077\u79fb\u904e\u7a0b\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u5728\u65b0\u6578\u64da\u5eab\u4e2d\u5275\u5efa\u8207\u820a\u6578\u64da\u5eab\u76f8\u540c\u7684\u8868\u683c\u7d50\u69cb\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%9c%a8-mysql-%e4%b8%ad%e8%a4%87%e8%a3%bd%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b-apvYWyNkoA\">\u5728 MySQL \u4e2d\u8907\u88fd\u8868\u683c\u7d50\u69cb<\/h2>\n<p>\u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8a9e\u53e5\u4f86\u8907\u88fd\u8868\u683c\u7d50\u69cb\uff1a<\/p>\n<pre><code>CREATE TABLE new_table LIKE original_table;<\/code><\/pre>\n<p>\u9019\u689d\u8a9e\u53e5\u6703\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>new_table<\/code> \u7684\u65b0\u8868\uff0c\u4e26\u5c07 <code>original_table<\/code> \u7684\u7d50\u69cb\u8907\u88fd\u904e\u4f86\uff0c\u4f46\u4e0d\u6703\u8907\u88fd\u6578\u64da\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-apvYWyNkoA\">\u793a\u4f8b<\/h3>\n<pre><code>CREATE TABLE employees_backup LIKE employees;<\/code><\/pre>\n<p>\u4e0a\u8ff0\u793a\u4f8b\u5c07\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>employees_backup<\/code> \u7684\u65b0\u8868\uff0c\u7d50\u69cb\u8207 <code>employees<\/code> \u8868\u76f8\u540c\u3002<\/p>\n<h2 id=\"%e5%9c%a8-postgresql-%e4%b8%ad%e8%a4%87%e8%a3%bd%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b-apvYWyNkoA\">\u5728 PostgreSQL \u4e2d\u8907\u88fd\u8868\u683c\u7d50\u69cb<\/h2>\n<p>\u5728 PostgreSQL \u4e2d\uff0c\u8907\u88fd\u8868\u683c\u7d50\u69cb\u7684\u8a9e\u6cd5\u7a0d\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u53e5\uff1a<\/p>\n<pre><code>CREATE TABLE new_table (LIKE original_table INCLUDING ALL);<\/code><\/pre>\n<p>\u9019\u689d\u8a9e\u53e5\u4e0d\u50c5\u6703\u8907\u88fd\u8868\u683c\u7684\u7d50\u69cb\uff0c\u9084\u6703\u5305\u62ec\u7d22\u5f15\u3001\u7d04\u675f\u7b49\u6240\u6709\u5c6c\u6027\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-apvYWyNkoA\">\u793a\u4f8b<\/h3>\n<pre><code>CREATE TABLE employees_backup (LIKE employees INCLUDING ALL);<\/code><\/pre>\n<p>\u9019\u6a23\u6703\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>employees_backup<\/code> \u7684\u65b0\u8868\uff0c\u4e26\u5b8c\u6574\u8907\u88fd <code>employees<\/code> \u8868\u7684\u7d50\u69cb\u3002<\/p>\n<h2 id=\"%e5%9c%a8-sql-server-%e4%b8%ad%e8%a4%87%e8%a3%bd%e8%a1%a8%e6%a0%bc%e7%b5%90%e6%a7%8b-apvYWyNkoA\">\u5728 SQL Server \u4e2d\u8907\u88fd\u8868\u683c\u7d50\u69cb<\/h2>\n<p>\u5728 SQL Server \u4e2d\uff0c\u8907\u88fd\u8868\u683c\u7d50\u69cb\u7684\u65b9\u5f0f\u7a0d\u5fae\u8907\u96dc\u4e00\u4e9b\uff0c\u901a\u5e38\u9700\u8981\u4f7f\u7528 <code>SELECT INTO<\/code> \u8a9e\u53e5\uff0c\u4f46\u9019\u7a2e\u65b9\u6cd5\u6703\u5275\u5efa\u4e00\u500b\u65b0\u8868\u4e26\u8907\u88fd\u6578\u64da\u3002\u82e5\u53ea\u60f3\u8907\u88fd\u7d50\u69cb\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre><code>SELECT * INTO new_table FROM original_table WHERE 1=0;<\/code><\/pre>\n<p>\u9019\u689d\u8a9e\u53e5\u6703\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>new_table<\/code> \u7684\u65b0\u8868\uff0c\u4e26\u4e14\u4e0d\u6703\u8907\u88fd\u4efb\u4f55\u6578\u64da\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-apvYWyNkoA\">\u793a\u4f8b<\/h3>\n<pre><code>SELECT * INTO employees_backup FROM employees WHERE 1=0;<\/code><\/pre>\n<p>\u9019\u6a23\u6703\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>employees_backup<\/code> \u7684\u65b0\u8868\uff0c\u7d50\u69cb\u8207 <code>employees<\/code> \u8868\u76f8\u540c\uff0c\u4f46\u4e0d\u5305\u542b\u4efb\u4f55\u6578\u64da\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-apvYWyNkoA\">\u7e3d\u7d50<\/h2>\n<p>\u8907\u88fd\u6578\u64da\u5eab\u8868\u683c\u7d50\u69cb\u662f\u4e00\u9805\u91cd\u8981\u7684\u6280\u80fd\uff0c\u7121\u8ad6\u662f\u5728 MySQL\u3001PostgreSQL \u9084\u662f SQL Server \u4e2d\uff0c\u638c\u63e1\u76f8\u61c9\u7684\u8a9e\u6cd5\u90fd\u80fd\u63d0\u9ad8\u6578\u64da\u5eab\u7ba1\u7406\u7684\u6548\u7387\u3002\u900f\u904e\u672c\u6587\u4ecb\u7d39\u7684\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u8907\u88fd\u8868\u683c\u7d50\u69cb\uff0c\u70ba\u6578\u64da\u7684\u5b89\u5168\u548c\u7ba1\u7406\u63d0\u4f9b\u4fdd\u969c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7ba1\u7406\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u6578\u64da\u5eab\u64cd\u4f5c\u63d0\u4f9b\u66f4\u7a69\u5b9a\u7684\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u8907\u88fd\u6578\u64da\u5eab\u8868\u683c\u7d50\u69cb\uff0c\u638c\u63e1 SQL \u8a9e\u53e5\u548c\u5de5\u5177\uff0c\u8f15\u9b06\u8907\u88fd\u8868\u683c\u800c\u4e0d\u5f71\u97ff\u6578\u64da\u5167\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-173355","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/173355","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=173355"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/173355\/revisions"}],"predecessor-version":[{"id":173356,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/173355\/revisions\/173356"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=173355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=173355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=173355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}