Copying Table Structures in MySQL

In MySQL it’s possible to create a new table – with the same column names and types of that of an existing table – using the following syntax:

CREATE TABLE <new table> LIKE <existing table>

This is for MySQL 4.1 and above.

Reference

MySQL 3.23, 4.0, 4.1 Reference Manual :: 12.1.5 CREATE TABLE Syntax

26 May 2008 | MySQL | Comments

One Response to “Copying Table Structures in MySQL”

  1. 1 sharulazlan 27 May 2008 @ 12:06 pm

    This is for oracle database.Copy only table structure

    CREATE TABLE newTable AS
    SELECT *
    FROM oldTable
    WHERE 1= 2;

    This will create table newTable with the same columns as oldTable.
    It will have no constraints or indexes. It will have zero(o) rows in it.

Comments:

  1.  
  2.  
  3.