Link to home
Create AccountLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

phpmyadmin

Is there a way t build a new table in phpmyadmin from an existing table making the table structure identical?

I need a table like that where I will add one new column, but all the rest is identical.

Thanks
Avatar of dsacker
dsacker
Flag of United States of America image

Use a query statement like this:

SELECT TOP 0 *
INTO MyNewTable
FROM MyOldTable

Open in new window

After you do that, then you can add your one new column at whatever point is applicable.

ALTER TABLE MyNewTable
ADD MyNewField varchar(50)

Open in new window

Or whatever size and type you really want.
Avatar of Richard Korts

ASKER

It fails & gives this message (whick I think is a catchall):

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 *  INTO ttask  FROM cl_task  LIMIT 0, 30' at line 1

The EXACT query I used is:

SELECT TOP 0 *
INTO ttask
FROM cl_task

ttask does not exist; do I have to create an empty table first?
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
In phpMyAdmin, select your database and table.  One of the tabs across the top is 'Operations'.  Click on that and one of the functions on that page is 'Copy table to ...' with several options.