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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

49K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo