{"id":476,"date":"2009-12-27T12:39:43","date_gmt":"2009-12-27T12:39:43","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=476"},"modified":"2023-12-31T02:53:44","modified_gmt":"2023-12-31T09:53:44","slug":"mysql-copy-table","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/","title":{"rendered":"MySQL Copy Table"},"content":{"rendered":"\n<p><strong>Summary<\/strong><em>: <\/em>in this tutorial, you will learn how to copy tables within the same database or from one database to another\u00a0using <code>CREATE TABLE ... SELECT<\/code> statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copying tables within the same database<\/h2>\n\n\n\n<p>Copying data from an existing table to a new one is very useful in some cases such as <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysql-dump-one-table\/\">backing up<\/a> data and replicating the production data for testing.<\/p>\n\n\n\n<p>To copy data from a table to a new one, you use <code>CREATE TABLE... SELECT<\/code> statement as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> new_table \n<span class=\"hljs-keyword\">SELECT<\/span> column1, column2, ...\n<span class=\"hljs-keyword\">FROM<\/span> existing_table;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the name of the new table in the <code>CREATE TABLE<\/code> clause.<\/li>\n\n\n\n<li>Second, construct a query that retrieves data from an existing table. <\/li>\n<\/ul>\n\n\n\n<p>This statement creates a new table <code>new_table<\/code>, and copy data from the <code>existing_table<\/code> to the new one based on the result set of the <code>SELECT<\/code> clause.<\/p>\n\n\n\n<p>To copy partial data from an existing table to the new one, you use the <a title=\"MySQL WHERE\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\">WHERE clause<\/a> in the <a title=\"MySQL SELECT\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-select-from\/\">SELECT statement<\/a> as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> new_table \n<span class=\"hljs-keyword\">SELECT<\/span> column1, column2, ...\n<span class=\"hljs-keyword\">FROM<\/span> existing_table\n<span class=\"hljs-keyword\">WHERE<\/span> condition;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It is very important to check whether the table you want to create already exists before creating it. <\/p>\n\n\n\n<p>To do so, you can use <code>IF NOT EXIST<\/code> option in the <code>CREATE TABLE<\/code> statement. <\/p>\n\n\n\n<p>The complete\u00a0statement of copying data from an existing table to a new one is as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> new_table \n<span class=\"hljs-keyword\">SELECT<\/span> column1, column2, ...\n<span class=\"hljs-keyword\">FROM<\/span> existing_table\n<span class=\"hljs-keyword\">WHERE<\/span> condition;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Note that this statement copies the table and its data. It does not copy other database objects associated with the existing table such as <a href=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/\">indexes<\/a>, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-primary-key\/\">primary key constraints<\/a>, <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-foreign-key\/\">foreign key constraints<\/a>,\u00a0<a href=\"https:\/\/www.mysqltutorial.org\/mysql-triggers\/\">triggers<\/a>, and so on.<\/p>\n\n\n\n<p>To copy data from one table and also all the dependent objects of the table, you use the following statements:<\/p>\n\n\n\n<p>First, create a new table whose structure is the same as the existing one:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">CREATE TABLE IF NOT EXISTS new_table \nLIKE existing_table;<\/code><\/span><\/pre>\n\n\n<p>Second, insert data from the existing table into the new table:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">INSERT new_table\nSELECT * FROM existing_table;<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Examples of copying a table within the same database<\/h3>\n\n\n\n<p>We&#8217;ll use the <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a> for the demonstration purposes.<\/p>\n\n\n\n<p>First, create a new table called <code>offices_bk<\/code> and copy all data from the <code>offices<\/code> table to the new table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> offices_bk \n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> offices;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, verify the copy by retrieving data from the <code>office_bk<\/code> table as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> offices_bk;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">+------------+---------------+------------------+--------------------------+--------------+------------+-----------+------------+-----------+\r\n| officeCode | city          | phone            | addressLine1             | addressLine2 | state      | country   | postalCode | territory |\r\n+------------+---------------+------------------+--------------------------+--------------+------------+-----------+------------+-----------+\r\n| 1          | San Francisco | +1 650 219 4782  | 100 Market Street        | Suite 300    | CA         | USA       | 94080      | NA        |\r\n| 2          | Boston        | +1 215 837 0825  | 1550 Court Place         | Suite 102    | MA         | USA       | 02107      | NA        |\r\n| 3          | NYC           | +1 212 555 3000  | 523 East 53rd Street     | apt. 5A      | NY         | USA       | 10022      | NA        |\r\n| 4          | Paris         | +33 14 723 4404  | 43 Rue Jouffroy D'abbans | NULL         | NULL       | France    | 75017      | EMEA      |\r\n| 5          | Tokyo         | +81 33 224 5000  | 4-1 Kioicho              | NULL         | Chiyoda-Ku | Japan     | 102-8578   | Japan     |\r\n| 6          | Sydney        | +61 2 9264 2451  | 5-11 Wentworth Avenue    | Floor #2     | NULL       | Australia | NSW 2010   | APAC      |\r\n| 7          | London        | +44 20 7877 2041 | 25 Old Broad Street      | Level 7      | NULL       | UK        | EC2N 1HN   | EMEA      |\r\n+------------+---------------+------------------+--------------------------+--------------+------------+-----------+------------+-----------+\r\n7 rows in set (0.00 sec)<\/code><\/span><\/pre>\n\n\n<p>If you want to\u00a0copy the\u00a0offices in the USA only, you can use a <code>WHERE<\/code> clause in the statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> offices_usa \n<span class=\"hljs-keyword\">SELECT<\/span> * \n<span class=\"hljs-keyword\">FROM<\/span>\n    offices\n<span class=\"hljs-keyword\">WHERE<\/span>\n    country = <span class=\"hljs-string\">'USA'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following statement gets all the data from the <code>offices_usa<\/code> table.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> offices_usa;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+\r\n| officeCode | city          | phone           | addressLine1         | addressLine2 | state | country | postalCode | territory |\r\n+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+\r\n| <span class=\"hljs-number\">1<\/span>          | San Francisco | +<span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">650<\/span> <span class=\"hljs-number\">219<\/span> <span class=\"hljs-number\">4782<\/span> | <span class=\"hljs-number\">100<\/span> Market Street    | Suite <span class=\"hljs-number\">300<\/span>    | CA    | USA     | <span class=\"hljs-number\">94080<\/span>      | NA        |\r\n| <span class=\"hljs-number\">2<\/span>          | Boston        | +<span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">215<\/span> <span class=\"hljs-number\">837<\/span> <span class=\"hljs-number\">0825<\/span> | <span class=\"hljs-number\">1550<\/span> Court Place     | Suite <span class=\"hljs-number\">102<\/span>    | MA    | USA     | <span class=\"hljs-number\">02107<\/span>      | NA        |\r\n| <span class=\"hljs-number\">3<\/span>          | NYC           | +<span class=\"hljs-number\">1<\/span> <span class=\"hljs-number\">212<\/span> <span class=\"hljs-number\">555<\/span> <span class=\"hljs-number\">3000<\/span> | <span class=\"hljs-number\">523<\/span> East <span class=\"hljs-number\">53<\/span>rd Street | apt. <span class=\"hljs-number\">5<\/span>A      | NY    | USA     | <span class=\"hljs-number\">10022<\/span>      | NA        |\r\n+------------+---------------+-----------------+----------------------+--------------+-------+---------+------------+-----------+\r\n<span class=\"hljs-number\">3<\/span> rows <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">set<\/span> (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Suppose, you want to copy not only the data but also all database objects associated with the <code>offices<\/code> table, we use the following statements:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> offices2 <span class=\"hljs-keyword\">LIKE<\/span> offices;\n\n<span class=\"hljs-keyword\">INSERT<\/span> offices2\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> offices;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Copying tables across databases<\/h2>\n\n\n\n<p>Sometimes, you want to copy a table to a different database. In such cases, you use the following statements:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> destination_db.new_table \n<span class=\"hljs-keyword\">LIKE<\/span> source_db.existing_table;\n\n<span class=\"hljs-keyword\">INSERT<\/span> destination_db.new_table \n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> source_db.existing_table;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The first statement creates a new table new_table in the destination database (<code>destination_db<\/code>) by duplicating the existing table (<code>existing_table<\/code>) from the source database (<code>source_db<\/code>).<\/p>\n\n\n\n<p>The second statement copies data from the existing table in the source database to the new table in the destination database.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p>First, create a database named <code>testdb<\/code> using the following statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> testdb;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, create the\u00a0<code>offices<\/code> table in the <code>testdb<\/code> by copying its structure from the <code>offices<\/code> table in the\u00a0<code>classicmodels<\/code> database.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> testdb.offices <span class=\"hljs-keyword\">LIKE<\/span> classicmodels.offices;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, copy data from the <code>classimodels.offices<\/code> table to <code>testdb.offices<\/code> table.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">INSERT<\/span> testdb.offices\n<span class=\"hljs-keyword\">SELECT<\/span> *\n<span class=\"hljs-keyword\">FROM<\/span> classicmodels.offices;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, verify the data from the <code>testdb.offices<\/code> table.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> testdb.offices;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"745\" height=\"177\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg\" alt=\"MySQL COPY TABLE example\" class=\"wp-image-3943\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg 745w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example-300x71.jpg 300w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><\/figure>\n\n\n\n<p>In this tutorial, you have learned various techniques to copy tables within a database and from one database to another.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"476\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/\"\n\t\t\t\tdata-post-title=\"MySQL Copy Table\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"476\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/\"\n\t\t\t\tdata-post-title=\"MySQL Copy Table\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you various techniques to copy tables within the same database or from one database to another.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":94,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-476","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL Copy Tables<\/title>\n<meta name=\"description\" content=\"This tutorial shows you various techniques to copy tables within the same database or from one database to another.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Copy Tables\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you various techniques to copy tables within the same database or from one database to another.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-31T09:53:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/\",\"name\":\"MySQL Copy Tables\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2009\\\/12\\\/MySQL-COPY-TABLE-example.jpg\",\"datePublished\":\"2009-12-27T12:39:43+00:00\",\"dateModified\":\"2023-12-31T09:53:44+00:00\",\"description\":\"This tutorial shows you various techniques to copy tables within the same database or from one database to another.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2009\\\/12\\\/MySQL-COPY-TABLE-example.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2009\\\/12\\\/MySQL-COPY-TABLE-example.jpg\",\"width\":745,\"height\":177},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-copy-table\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL Copy Table\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL Copy Tables","description":"This tutorial shows you various techniques to copy tables within the same database or from one database to another.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Copy Tables","og_description":"This tutorial shows you various techniques to copy tables within the same database or from one database to another.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/","og_site_name":"MySQL Tutorial","article_modified_time":"2023-12-31T09:53:44+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/","name":"MySQL Copy Tables","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg","datePublished":"2009-12-27T12:39:43+00:00","dateModified":"2023-12-31T09:53:44+00:00","description":"This tutorial shows you various techniques to copy tables within the same database or from one database to another.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2009\/12\/MySQL-COPY-TABLE-example.jpg","width":745,"height":177},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-copy-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL Copy Table"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":4,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/476\/revisions"}],"predecessor-version":[{"id":13940,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/476\/revisions\/13940"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}