Create a table with the same structure in the MySQL database

Source: Internet
Author: User
Tags mysql index

The following article describes how to quickly create tables with the same structure in the MySQL database, the following articles describe how to quickly create a table with the same structure as a MySQL database from two aspects: indexing and not creating an index. The following is the main content of this article.

1. quickly create tables with the same MySQL structure, including indexes:

 
 
  1. mysql> SHOW CREATE TABLE a;   
  2. CREATE TABLE `a` (   
  3. `name` varchar(50) default NULL,   
  4. KEY `name` (`name`)   
  5. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;   
  6. mysql> CREATE TABLE b LIKE a;   
  7. mysql> SHOW CREATE TABLE b;   
  8. CREATE TABLE `b` (   
  9. `name` varchar(50) default NULL,   
  10. KEY `name` (`name`)   
  11. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;  

2. quickly create a table with the same structure, but do not create a MySQL index:

 
 
  1. mysql> SHOW CREATE TABLE a;   
  2. CREATE TABLE `a` (   
  3. `name` varchar(50) default NULL,   
  4. KEY `name` (`name`)   
  5. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;   
  6. mysql> CREATE TABLE c SELECT * FROM a LIMIT 0;   
  7. mysql> SHOW CREATE TABLE c;   
  8. CREATE TABLE `c` (   
  9. `name` varchar(50) default NULL   
  10. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;  

The above content is an introduction to quickly creating tables with the same MySQL structure. I hope you will get some benefits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.