InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Mysql tutorials

  • Enable query log without restarting mysql on Linux
  • How to find mysql query rate on Linux
  • Mysql - display row count and size of tables
  • Mysql - get size of all databases
  • Mysql - get total queries since beginning
  • Mysql - how to copy a table
  • Mysql - how to enable query log
  • Mysql 5.7 root password after installation
  • Mysql difference between CURDATE() and NOW()
  • Mysql find current timezone offset
  • Mysql find slave lag
  • Mysql how to dump schema of all databases
  • Mysql multi column Index
  • Wordpress Mysql Queries
  • mysql - how to enable query logs
  • mysql find recently created-tables
 
  • Home
  • > Tutorials
  • > Mysql

Mysql – how to copy a table

By admin on Jan 7, 2016

Cloning table with indexes/triggers and data

  1. First create new table with same structure. We’ll use wordpress table wp_posts for the purpose of this tutorial.

    mysql> CREATE TABLE wp_posts_bak LIKE wp_posts;
    Query OK, 0 rows affected (0.00 sec)
    
  2. Now copy the data

    mysql> INSERT INTO wp_posts_bak SELECT * FROM wp_posts;
    Query OK, 2857 rows affected (0.49 sec)
    Records: 2857  Duplicates: 0  Warnings: 0
    

Cloning table without indexes/triggers (data only)

This is handy approach to take backup of a table when we don’t need indexes, etc.

mysql> CREATE TABLE wp_posts_bak2 AS (select * from wp_posts);
Query OK, 2857 rows affected (0.09 sec)
Records: 2857  Duplicates: 0  Warnings: 0

Suggested posts:

  1. How to search files by name in Mac Finder
  2. HTML li tag
  3. PHP check if key exists in array
  4. Curl – follow redirects
  5. How to find mysql query rate on Linux
  6. Display keys added to ssh-agent using ssh-add
  7. Mac – how to use kubernetes with Lima-VM
  8. Chrome – copy any request as cURL including headers
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Mysql, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress