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
MySQL Server

Avatar of undefined
Last Comment
Dave Baldwin

8/22/2022 - Mon
dsacker

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.
ASKER
Richard Korts

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
dsacker

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Dave Baldwin

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck