Archive

Posts Tagged ‘create table’

Quickly duplicating MySQL table structures

May 1st, 2009 Comments off

I often find myself duplicating table structures to either do some testing or duplicating a database structure from one database to another. Most of the time,  I find that I do not need to copy the existing data to the new database table. The easiest way I have found to do this is using MySQL’s CREATE TABLE…LIKE… () syntax. Even the most basic form can fulfill most requirements. This form could be something like:

CREATE TABLE `bar` LIKE `foo`;

For the MySQL 5.1 reference page, go here:  http://dev.mysql.com/doc/refman/5.1/en/create-table.html

Categories: MySQL Tags: ,