开发者

SQL Syntax for default constraint in MySQL

开发者 https://www.devze.com 2023-03-12 00:31 出处:网络
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 wha

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'
0

精彩评论

暂无评论...
验证码 换一张
取 消