使用PHP通过HTML表单更改MySQL表上的ENUM列是不是一个坏主意?

Suppose that I have an enum column on a table and I want users to be able to expand the number of values it contains via an HTML form submission on the front end by using PHP to run a query that alters the table to contain more enum values for that column .

  • Is it a bad idea to run queries very often that will alter the a table structure?
  • Is there a security issue inherent that I can't see?
  • If I sanitize user input before altering the table with the new values is that sufficient?

As Col.Shrapnel already said, yes, it's a bad idea. Unless you're making an application specifically meant to admin a database, it's generally bad practice to allow your app to alter a database in any way with very few exceptions (so feel free to use temp tables). Doubly so in PHP. The most immediately apparent impact is if you modify any enum list value, this field in all records in the table using that old value will be erased. A choice quote from mysql manual...

An ENUM is a string object with a value chosen from a list of permitted values 
that are enumerated explicitly in the column specification 
at table creation time. 

Yes, it is a bad idea. If you need the list to be editable it should be a referenced table. Apart from being generally bad practice, it may cause a reindex of the table which will have a significant performance impact especially on larger tables.