{"id":207,"date":"2024-06-17T09:04:49","date_gmt":"2024-06-17T01:04:49","guid":{"rendered":"http:\/\/zhaoyanqi.cn\/?p=207"},"modified":"2024-06-19T22:12:15","modified_gmt":"2024-06-19T14:12:15","slug":"%e4%bb%8e%e6%97%a7%e8%a1%a8%e6%8f%92%e5%85%a5%e6%95%b0%e6%8d%ae%e5%88%b0%e6%96%b0%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/zhaoyanqi.cn\/?p=207","title":{"rendered":"\u4ece\u65e7\u8868\u63d2\u5165\u6570\u636e\u5230\u65b0\u8868"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"PwUy5\">\u5047\u8bbe\u9700\u8981\u628a\u65e7\u8868test1\u8868\u7684\u6570\u636e\uff0c\u63d2\u5165\u5230\u65b0\u8868test2\u91cc<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8fd6bf5b\">1. \u521b\u5efa <code>test1<\/code> \u8868\u5e76\u63d2\u5165\u6570\u636e<\/h4>\n\n\n\n<p id=\"u8e6d4be2\"><strong>\u521b\u5efa <\/strong><code><strong>test1<\/strong><\/code><strong> \u8868<\/strong><\/p>\n\n\n\n<pre id=\"985e3240\" class=\"wp-block-code\"><code>CREATE TABLE test1 (\n    id INT PRIMARY KEY AUTO_INCREMENT,\n    name VARCHAR(10),\n    age INT,\n    email VARCHAR(30),\n    born_year YEAR,\n    reg_time DATETIME\n);<\/code><\/pre>\n\n\n\n<p id=\"ubfd2bdbc\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>id<\/code>\uff1a\u4e3b\u952e\uff0c\u81ea\u52a8\u9012\u589e\u3002<\/li>\n\n\n\n<li><code>name<\/code>\uff1a\u540d\u5b57\uff0c\u6700\u5927\u957f\u5ea610\u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><code>age<\/code>\uff1a\u5e74\u9f84\uff0c\u6574\u6570\u7c7b\u578b\u3002<\/li>\n\n\n\n<li><code>email<\/code>\uff1a\u7535\u5b50\u90ae\u4ef6\uff0c\u6700\u5927\u957f\u5ea630\u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><code>born_year<\/code>\uff1a\u51fa\u751f\u5e74\u4efd\uff0cYEAR\u7c7b\u578b\u3002<\/li>\n\n\n\n<li><code>reg_time<\/code>\uff1a\u6ce8\u518c\u65f6\u95f4\uff0cDATETIME\u7c7b\u578b\u3002<\/li>\n<\/ul>\n\n\n\n<p id=\"u9296b5f3\"><strong>\u5411 <\/strong><code><strong>test1<\/strong><\/code><strong> \u8868\u63d2\u5165\u6570\u636e<\/strong><\/p>\n\n\n\n<pre id=\"0e2a3e38\" class=\"wp-block-code\"><code>INSERT INTO test1 (name, age, email, born_year, reg_time) VALUES\n('egon1', 18, '123123@qq.com', 1999, NOW()),\n('egon2', 28, '123123@163.com', 1999, NOW()),\n('egon3', 38, '123123@xx.com', 1999, NOW()),\n('egon4', 48, '123123@aa.com', 1999, NOW()),\n('egon5', 58, '123123@zz.com', 1999, NOW());<\/code><\/pre>\n\n\n\n<p id=\"u65e8fa8c\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5411 <code>test1<\/code> \u8868\u4e2d\u63d2\u51655\u6761\u8bb0\u5f55\u3002<\/li>\n\n\n\n<li><code>NOW()<\/code> \u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"7e28926c\">2. \u521b\u5efa <code>db3<\/code> \u6570\u636e\u5e93\u5e76\u521b\u5efa <code>test2<\/code> \u8868<\/h4>\n\n\n\n<p id=\"u6d2aa91c\"><strong>\u521b\u5efa\u6570\u636e\u5e93 <\/strong><code><strong>db3<\/strong><\/code><\/p>\n\n\n\n<pre id=\"5353d6cf\" class=\"wp-block-code\"><code>CREATE DATABASE db3;<\/code><\/pre>\n\n\n\n<p id=\"ua5eea524\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93 <code>db3<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<p id=\"ub87f581d\"><strong>\u4f7f\u7528\u6570\u636e\u5e93 <\/strong><code><strong>db3<\/strong><\/code><\/p>\n\n\n\n<pre id=\"f98f6c65\" class=\"wp-block-code\"><code>USE db3;<\/code><\/pre>\n\n\n\n<p id=\"ucb18d232\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5207\u6362\u5230\u6570\u636e\u5e93 <code>db3<\/code>\uff0c\u540e\u7eed\u64cd\u4f5c\u90fd\u5728 <code>db3<\/code> \u6570\u636e\u5e93\u4e2d\u6267\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p id=\"u22a4ac61\"><strong>\u521b\u5efa <\/strong><code><strong>test2<\/strong><\/code><strong> \u8868<\/strong><\/p>\n\n\n\n<pre id=\"f0aacaf4\" class=\"wp-block-code\"><code>CREATE TABLE test2 (\n    id INT PRIMARY KEY AUTO_INCREMENT,\n    name VARCHAR(15),\n    email VARCHAR(30),\n    reg_time DATETIME\n);<\/code><\/pre>\n\n\n\n<p id=\"u4b0dea50\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>id<\/code>\uff1a\u4e3b\u952e\uff0c\u81ea\u52a8\u9012\u589e\u3002<\/li>\n\n\n\n<li><code>name<\/code>\uff1a\u540d\u5b57\uff0c\u6700\u5927\u957f\u5ea615\u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><code>email<\/code>\uff1a\u7535\u5b50\u90ae\u4ef6\uff0c\u6700\u5927\u957f\u5ea630\u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><code>reg_time<\/code>\uff1a\u6ce8\u518c\u65f6\u95f4\uff0cDATETIME\u7c7b\u578b\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"952b56f9\">3. \u4ece <code>db2.test1<\/code> \u8868\u63d2\u5165\u6570\u636e\u5230 <code>db3.test2<\/code> \u8868<\/h4>\n\n\n\n<p id=\"u59e44cee\"><strong>\u63d2\u5165\u6570\u636e<\/strong><\/p>\n\n\n\n<pre id=\"c39eaee5\" class=\"wp-block-code\"><code>INSERT INTO db3.test2 (id, name, email, reg_time)\nSELECT id, name, email, reg_time FROM db2.test1;<\/code><\/pre>\n\n\n\n<p id=\"u440c6963\"><strong>\u89e3\u91ca<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06 <code>db2.test1<\/code> \u8868\u4e2d\u7684\u6570\u636e\u63d2\u5165\u5230 <code>db3.test2<\/code> \u8868\u4e2d\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <code>SELECT<\/code> \u8bed\u53e5\u4ece <code>db2.test1<\/code> \u8868\u4e2d\u83b7\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"25f9c7fa\">\u603b\u7ed3<\/h3>\n\n\n\n<p id=\"u7159662f\">\u4ee5\u4e0b\u662f\u5b8c\u6574\u7684\u64cd\u4f5c\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521b\u5efa <\/strong><code><strong>test1<\/strong><\/code><strong> \u8868\u5e76\u63d2\u5165\u6570\u636e<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"77d05bf5\" class=\"wp-block-code\"><code>CREATE TABLE test1 (\n    id INT PRIMARY KEY AUTO_INCREMENT,\n    name VARCHAR(10),\n    age INT,\n    email VARCHAR(30),\n    born_year YEAR,\n    reg_time DATETIME\n);\n\nINSERT INTO test1 (name, age, email, born_year, reg_time) VALUES\n('egon1', 18, '123123@qq.com', 1999, NOW()),\n('egon2', 28, '123123@163.com', 1999, NOW()),\n('egon3', 38, '123123@xx.com', 1999, NOW()),\n('egon4', 48, '123123@aa.com', 1999, NOW()),\n('egon5', 58, '123123@zz.com', 1999, NOW());<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>\u521b\u5efa <\/strong><code><strong>db3<\/strong><\/code><strong> \u6570\u636e\u5e93\u5e76\u521b\u5efa <\/strong><code><strong>test2<\/strong><\/code><strong> \u8868<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"ae521501\" class=\"wp-block-code\"><code>CREATE DATABASE db3;\nUSE db3;\n\nCREATE TABLE test2 (\n    id INT PRIMARY KEY AUTO_INCREMENT,\n    name VARCHAR(15),\n    email VARCHAR(30),\n    reg_time DATETIME\n);<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>\u4ece <\/strong><code><strong>db2.test1<\/strong><\/code><strong> \u8868\u63d2\u5165\u6570\u636e\u5230 <\/strong><code><strong>db3.test2<\/strong><\/code><strong> \u8868<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"c39eaee5-1\" class=\"wp-block-code\"><code>INSERT INTO db3.test2 (id, name, email, reg_time)\nSELECT id, name, email, reg_time FROM db2.test1;<\/code><\/pre>\n\n\n\n<p id=\"uc890c5ca\">\u901a\u8fc7\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u53ef\u4ee5\u6210\u529f\u521b\u5efa\u548c\u64cd\u4f5c\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u8868\uff0c\u5e76\u5b9e\u73b0\u4ece\u4e00\u4e2a\u8868\u5411\u53e6\u4e00\u4e2a\u8868\u7684\u6570\u636e\u63d2\u5165\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5047\u8bbe\u9700\u8981\u628a\u65e7\u8868test1\u8868\u7684\u6570\u636e\uff0c\u63d2\u5165\u5230\u65b0\u8868test2\u91cc 1. \u521b\u5efa test1 \u8868\u5e76\u63d2\u5165\u6570\u636e \u521b\u5efa test [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,12],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-mysql","category-sql"],"_links":{"self":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=207"}],"version-history":[{"count":1,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhaoyanqi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}