Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a database 'portfolio' and it contains the portfolio of all the users and there are over 1000 tables inside this portfolio database.
I need to add a new column "Date" to all the tables.

However, i am getting the following error:

Error Code: 1054. Unknown column 'Tables' in 'field list'




Any help will be appreciated. Thank you in advance.

What I have tried:

use portfolio;
show tables;


select CONCAT("Alter Table ", TABLE_SCHEMA,`.`,Tables, " Add Column presentDate date") from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = "portfolio";


The result for show tables is as follows:

Tables_in_portfolio
123
222
p3647
4458e
76367jgfkg
......and so on
Posted
Updated 18-Jul-18 6:28am
v2
Comments
Richard Deeming 19-Jul-18 11:23am    
Multiple tables with the same schema is a sign of a terrible database design.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900