Page 1 of 1
Can you export columns, and then import them to another tbl?
Posted: Fri Nov 09, 2012 7:55 am
by simonmlewis
I have about 15 fields I need to extract from a DB table.
Rather than my counting how many I need to add, and then copy the exact titles, and field types and characters, can I not just select each field I was to export, and then import that into the current table - but NOT import/export the data within them?
MySQL database.
Re: Can you export columns, and then import them to another
Posted: Fri Nov 09, 2012 3:32 pm
by Christopher
You can SELECT specific fields from one table and INSERT the SELECTed data into another table in one SQL statement.
Re: Can you export columns, and then import them to another
Posted: Sat Nov 10, 2012 1:26 am
by califdon
simonmlewis wrote:I have about 15 fields I need to extract from a DB table.
Rather than my counting how many I need to add, and then copy the exact titles, and field types and characters, can I not just select each field I was to export, and then import that into the current table - but NOT import/export the data within them?
MySQL database.
I think you are asking about modifying a table structure to add columns which exist in another table. Are you trying to create a new table with just those columns, or do you want to add those columns to an existing table? If you want to create a new table with exactly the same columns as another table, you could use SHOW CREATE TABLE
http://dev.mysql.com/doc/refman/5.1/en/ ... table.html and save the output to a file and then execute that file as SQL, which will create an empty table structure with the same structure as the first one. If you want to add additional columns to an existing table, though, there's no easy way to do that without requiring more fuss and bother than just carefully using ALTER TABLE commands for 15 columns.