CREATE TABLE publishers
(
PublisherName varchar(75),
City varchar(35),
PublisherState char(2),
Country varchar(4)
)
GO
- 修改发布商,以便州必须是两个字母
ALTER TABLE publishers
ALTER COLUMN publisherstate char(2) CHECK (publisherstate LIKE '[A-Za-z][A-Za-z]')
答案 0 :(得分:1)
您必须提及Constraint Name
和Check
。
试试这个:
alter table publishers
add constraint codeCheck check (PublisherState like '[A-Za-z][A-Za-z]');