SQL Syntax for default constraint in MySQL
I want to add a default constraint to a existing table. So i use this SQL query. Is there any wrong with this? It generates a error message. Please can anyone give me the correct syntax or tell me what is the error. I have a book and according to its syntax this 开发者_运维百科is correct.
ALTER TABLE dbo.customer
ADD CONSTRAINT df_contactname DEFAULT 'Unknown'
FOR contactname
If you are trying to add a default value for a column, this would be the correct syntax:
ALTER TABLE dbo.customer ALTER COLUMN contactname SET DEFAULT 'Unknown'
精彩评论