Reputation: 539
I want to alter my table and drop a column which i know there is no data in it(because I just created it) now I want to delete it and it says
"SQL Error (3727): Could not drop constraint. See previous errors."
I use the following code:
ALTER TABLE Object DROP WAddress
Upvotes: 0
Views: 11480
Reputation: 1402
Below are the syntax to drop column(s) from table:
Drop single column:
ALTER TABLE table_name DROP COLUMN column_name;
Drop multiple columns for SQL Server:
ALTER TABLE table_name DROP COLUMN (column_name1, column_name2);
For Oracle:
ALTER TABLE table_name DROP (column_name1, column_name2);
In your case you want to drop a single column
so COLUMN
keyword is required
after DROP
.
If you want to drop multiple columns, you can omit COLUMN
keyword based on DB that you are using.
Upvotes: 2
Reputation: 513
Your query is missing the "COLUMN" keyword. Use:
ALTER TABLE Object DROP COLUMN WAddress
The reason it was throwing the error about the constraint, is that it was expecting that WAddress was the name of a constraint on the table because the keyword "COLUMN" was missing.
Upvotes: 6