A few circumstances require delivering a precise of a current table. The CREATE...SELECT explanation can't deliver this yield since it disregards things like files and default esteems.
The system for a copying a table is as per the following −
- Use SHOW CREATE TABLE to deliver a CREATE TABLE explanation that subtleties the whole design of the source table.
- Alter the assertion to give the table another name, and execute it.
- Utilize an INSERT INTO...SELECT explanation in the event that you additionally need the table information duplicated.
mysql> INSERT INTO inventory_copy_tbl ( product_id,product_name,product_manufacturer,ship_date) SELECT product_id,product_name,product_manufacturer,ship_date, FROM inventory_tbl;
Another strategy for making a copy utilizes a CREATE TABLE AS explanation. The assertion duplicates all sections, segment definitions, and populates the duplicate with the source table's information.
Survey its language structure given beneath −
CREATE TABLE clone_tbl AS SELECT columns FROM original_tbl WHERE conditions];
Survey an illustration of its utilization underneath −
CREATE TABLE products_copy_tbl AS SELECT * FROM products_tbl;