MySQL provides many methods to create duplicate table with its
data or without its data. The following is a simple example to create a
duplicate table along-with data of the original table:
If you also want to have such attributes, this can be done with another easy way. Below queries will create a copy of the original table with all its constraints and attributes and also insert entire data from the original table to the new on:
CREATE TABLE new_table_name SELECT * FROM old_table_name;
An important point to note is that this query will not create
column attributes
and indexes as defined in the original table.If you also want to have such attributes, this can be done with another easy way. Below queries will create a copy of the original table with all its constraints and attributes and also insert entire data from the original table to the new on:
CREATE TABLE new_table_name LIKE old_table_name;
INSERT INTO new_table_name SELECT * FROM old_table_name;
No comments:
Post a Comment