SQL Clone Table

5
155

sqltuts

The SQL clone table may be used in a situation that you need an exact copy of a table and CREATE TABLE … SELECT doesn’t suit your purposes because the copy must include the same indexes, default values, and so forth.

You can handle this situation by following steps:

You can handle this situation by following steps:

 

Use SHOW CREATE TABLE to get a CREATE TABLE statement that specifies the source table’s structure, indexes and all.

 

Modify the statement to change the table name to that of the clone table and execute the statement. This way, you will have an exact clone table.

 

Optionally, if you need the table contents copied as well, issue an INSERT INTO … The SELECT statement, too.

 

Step 1:

Get complete structure about table.

Step 2:

Rename this table and create another table.

 

Step 3:

 

You will have an exact clone table as the user wished for.

Facebook Comments

5 COMMENTS

  1. magnificent publish, very informative. I wonder why the opposite specialists of this sector don’t notice this. You must continue your writing. I am confident, you’ve a huge readers’ base already!

  2. Nos actualizamos tanto como el sector nos ofrece, estamos pendientes de las ultimos novedades de productos para Sex Shop de este modo logramos estar en los sitios punteros y ser referente de contar con todas las novedades.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.