sql server 2008中怎么约束一个密码的长度必须大于6
展开全部
--创建表
CREATE TABLE [dbo].[tb_e_User](
[UserID] [varchar](50) NOT NULL,
[UserPassword] [varchar](50) NOT NULL,
CONSTRAINT [PK_tb_e_User] PRIMARY KEY CLUSTERED
(
[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
--约束规则
ALTER TABLE [dbo].[tb_e_User] WITH CHECK ADD CONSTRAINT [CK_tb_e_User_PasswordLen] CHECK ((len([UserPassword])>(6)))
GO
--添加约束
ALTER TABLE [dbo].[tb_e_User] CHECK CONSTRAINT [CK_tb_e_User_PasswordLen]
GO
/*
然后再试试,输入数据,小于6位的密码是不被保存的
*/
CREATE TABLE [dbo].[tb_e_User](
[UserID] [varchar](50) NOT NULL,
[UserPassword] [varchar](50) NOT NULL,
CONSTRAINT [PK_tb_e_User] PRIMARY KEY CLUSTERED
(
[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
--约束规则
ALTER TABLE [dbo].[tb_e_User] WITH CHECK ADD CONSTRAINT [CK_tb_e_User_PasswordLen] CHECK ((len([UserPassword])>(6)))
GO
--添加约束
ALTER TABLE [dbo].[tb_e_User] CHECK CONSTRAINT [CK_tb_e_User_PasswordLen]
GO
/*
然后再试试,输入数据,小于6位的密码是不被保存的
*/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询