Problem statement: How do you copy Old table TO New table with whole structures (column name, data type, datatype size, constraints) within the same database !
Syntax:
CREATE TABLE new_table LIKE old_table
e.g.
mysql>show tables;
------------------
tables in my db|
------------------
old_emp
mysql> CREATE TABLE new_emp LIKE old_emp;
QUERY OK, 0 rows affected(0.33sec)
verify:
mysql>show tables;
------------------
tables in my db|
------------------
old_emp
new_emp
------------------
Syntax:
CREATE TABLE new_table LIKE old_table
e.g.
mysql>show tables;
------------------
tables in my db|
------------------
old_emp
mysql> CREATE TABLE new_emp LIKE old_emp;
QUERY OK, 0 rows affected(0.33sec)
verify:
mysql>show tables;
------------------
tables in my db|
------------------
old_emp
new_emp
------------------
No comments:
Post a Comment