-- ============================================= -- 程序编写: Jeff -- 版 本: V 1.0 -- 建立日期: 2015-04-09 -- 功能说明: 创建共享表[NetShareInfo],大店使用相片存储时,往往4T硬盘存储不下相片原片,所以要多个同类型共享目录存储; -- 备 注: -- 修改日期: -- 修改说明: -- ============================================= use [db] go set ansi_nulls on go set quoted_identifier on go set ansi_padding on go --判断表是否存在,不存在则创建; if not exists(select * from dbo.sysobjects where id = object_id(N'NetShareInfo') and objectproperty(id,'IsTable') = 1) begin create table [dbo].[NetShareInfo]( [enable] [bit] default(1) not null, /* 启动状态:false禁用,true启用 */ [branchid] [nvarchar](32) null, /* 分店域名 */ [enable] [bit] default(1) not null, /* 启动状态:false禁用,true启用 */ [shareHost] [nvarchar](16) not null, /* 共享主机名 --有冗余*/ [sharePath] [nvarchar](16) not null, /* 共享目录名 */ [mincapacity] [tinyint] default(30) not null, /* 共享目录所在硬盘的最小可用容量(单位G byte),当实际可用容量值小于该值时,停止使用硬盘 */ [maxcapacity] [tinyint] default(30) not null, /* 共享目录所在硬盘的最大可用容量(单位G byte),当实际可用容量值小于该值时,使用下一共享目录 */ [photoType] [tinyint] not null, /* 共享相片类型:原片==1,初修片==2,精修片==3,设计片==4,原片备份==5,初修备份==6,精修备份==7,设计备份==8 */ [priority] [tinyint] default(1) not null, /* 某分店下,相同共享相片类型的多个共享目录的优先使用级别 */ /* 联合主键:域名+共享主机名+共享目录名*/ constraint [PK_NetShareinfo] primary key clustered ( [branchid] asc, [shareHost] asc, [sharePath] asc ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary], -- 设置UNIQUE约束; constraint [PK_NetShareInfo_U] unique nonclustered ( [branchid] asc, [photoType] asc, [priority] asc ) with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on,allow_page_locks = on) on [primary] ) on [primary] end go --可用容量最小设置值为5G; alter table [dbo].[NetShareInfo] with check add check([mincapacity] >= 5) alter table [dbo].[NetShareInfo] with check add check([maxcapacity] >= 35) go --最低权限值为1,无上限; alter table [dbo].[NetShareInfo] with check add check([priority] >= 1) go set ansi_padding off