The Pursuit of Happyness

Create a copy of the table 

CREATE TABLE products_bak LIKE products

Copying the data from the original table to the new table

INSERT INTO products_bak SELECT * FROM products

Copying the data back again

TRUNCATE products;
INSERT INTO products SELECT * FROM products_bak

original link http://www.electrictoolbox.com/copy-table-mysql-create-table-like/


Comment +0

은근히 유용한 팁

  1. Dump (Backup 및 Migration)
    [전체 Dump]

    Usage : #> mysqldump -u{userid} -p{password} DatabaseName > file_name.sql
    ex) mysqldump -uroot -proot!@# dev_db > dev_dump.sql
    [Table Dump]
    Usage : #> mysqldump -u{userid} -p{password} DatabaseName TableName > file_name.sql
    ex) mysqldump -uroot -proot!@# dev_db board > board_dump.sql
  2. 복구
    [전체 Dump 했을 경우]
    Usage : #> mysql -u{userid} -p{password} DatabaseName < file_name.sql
    ex) mysql -uroot -proot!@# dev_db < dev_dump.sql
    [Table Dump 했을 경우]
    Usage : #> mysql -u{userid} -p{password} DatabaseName TableName < file_name.sql
    ex) mysql -uroot -proot!@# dev_db board < board_dump.sql

이 자료는 negafix 님 블로그에서 퍼왔습니다. (http://negafix.tistory.com/27)

Comment +0