Question:
Is it a good programming practice to continually add columns to a SQL table on the fly?
Eleu ©
2010-03-09 18:34:45 UTC
The number of rows in a SQL table I'm designing will be the same practically all the time, but I will need to add columns periodically to add new data. I choose this approach because it is easier to make the queries I need in this way.

Is this a good programming practice, to continually add columns to a table via a PHP application?
Four answers:
TheMadProfessor
2010-03-12 08:19:09 UTC
If you are continually adding columns to a table, there's probably something seriously wrong with your table structure and overall application. In a properly-designed app, modifying the table structure should be a rare occurance. Feel free to drop me a line as to your database particulars and the circumstances that you feel require adding columns and chances are I can suggest a structure that should eliminate the need.
2010-03-10 08:45:47 UTC
I agree with Collin. Once a table goes 'live' the scheme should not change. If it does, it should be very rarely.



An easier method may be to create several unnamed columns (Col001, Col002) and use these for the new data.
Collin H
2010-03-09 18:46:19 UTC
This is a very bad idea. What are you trying to accomplish? There's probably a much better way to do it.



Your database schema should not change as a regular occurrence.
2016-04-12 16:05:55 UTC
ALTER TABLE table name


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...