Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

try like this:

    use 'DatabaseName';
    ALTER TABLE Customers
    DROP COLUMN City;
    enter code here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top