Reputation: 511
I am learning SQL
online from w3school.com.
for droping a column
ALTER TABLE table_name
DROP COLUMN column_name
command is given in SQL ALTER page
i tried it in Try it yourself section provided by w3school.
but it's not working
I used
ALTER TABLE Customers
DROP COLUMN City;
I also try to do this query on compile online/sql.
but again it's not working.
so, can any one explain me where i am wrong.
Upvotes: 0
Views: 4876
Reputation: 102
try like this:
use 'DatabaseName';
ALTER TABLE Customers
DROP COLUMN City;
enter code here
Upvotes: 0
Reputation: 318
Did you notice what it says in the brackets?
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column)
See the answers to these questions:
websql drop column with javascript
How to delete or add column in SQLITE?
W3schools uses websql. Try SQLFiddle instead.
Upvotes: 1
Reputation: 2013
The 'try it yourself' link you provided seems to be set up for testing a 'Select all' statement. It may not be a fully functional environment, and you may not have permission to run all statements.
Upvotes: 0