Perhpas the answer is obvious, but I’ve not figured it out. How do you delete a column of a MySQL View?
ā Answers
? Best Answer
As you rightly note, anyone dropping table columns to achieve this is going to have a lot of problems š
ALTER table [TABLENAME] DROP column [COLUMN NAME]
You don’t actually delete a column from a view, you simply don’t select that column in your SQL statement.
Such as “SELECT <column1>, <column2>, <etc> FROM <table or view> WHERE <criteria>”
Simply don’t include <column-x> in your SELECT statement.
Edit:
I just saw the other answer, and that answer is accurate, as far as it goes, but you were asking about a view, not a table. But what I said will work with either a view OR a table.
My solution is only if you cannot access the actual table or view, and you have to use what you have.
To delete the column col_stuff from the table table_things, use the following SQL command:
ALTER TABLE ‘table_things’ DROP ‘col_stuff’