Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我VARCHAR(30)在 Microsoft SQL Server 数据库中有一个列。我想添加一个不允许列中的值小于 3 个字符的 CHECK 约束。我必须使用什么表达方式?
VARCHAR(30)
利用:
ALTER TABLE [dbo].[YOUR_TABLE] ADD CONSTRAINT [MinLengthConstraint] CHECK (DATALENGTH([your_column]) > 2)
参考: