处理登陆和打开仓库延迟的方法
在查询分析器里运行脚本如下
1 备份数据库 (建立了一个warehousebak表,仔细检查没问题才删除它,切记!!!!)
select * into warehousebak from warehouse
备份optiondata表:
select * into optiondatabak from optiondata
2 导出不重复数据。用distinct函数,重复就放弃
select distinct * into #tmp from warehouse
3 清空warehouse
truncate table warehouse
清空optiondata表
truncate table optiondata
4 建立索引,在查询分析器里运行
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[warehouse]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[warehouse]
GO
CREATE TABLE [dbo].[warehouse] (
[AccountID] [nvarchar] (10) COLLATE Latin1_General_CS_AS NOT NULL ,
[Items] [varbinary] (1200) NULL ,
[Money] [int] NULL ,
[EndUseDate] [smalldatetime] NULL ,
[DbVersion] [tinyint] NULL ,
[pw] [smallint] NULL
) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [PK_Warehouse] ON [dbo].[warehouse]([AccountID] DESC ) ON [PRIMARY]
GO
运行上面的脚本就在warehouse表中建立索引了.
if exists (select * from dbo.sysobjects where id = object_id(N[dbo].[OptionData]) and OBJECTPROPERTY(id, NIsUserTable) = 1)
drop table [dbo].[OptionData]
GO
CREATE TABLE [dbo].[OptionData] (
[Name] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Skillkey] [binary] (10) NULL ,
[GameOption] [tinyint] NULL ,
[Qkey] [tinyint] NULL ,
[Wkey] [tinyint] NULL ,
[Ekey] [tinyint] NULL ,
[ChatWindow] [tinyint] NULL
) ON [PRIMARY]
GO dedecms.com
CREATE UNIQUE CLUSTERED INDEX [PK_Optiondata] ON [dbo].[OptionData]([Name] DESC ) ON [PRIMARY]
GO
上面这段是OptionData的索引脚本.
这两个脚本是给不会建立索引的朋友用的,知道怎么建立就不需要啦
5 把非重复数据导回
insert into warehouse select * from #tmp
6 进入warehouse表内看看,如果仓库空了,就赶紧把这个表删除,把warehousebak表改名字,别弄了.
如果还原数据正确,那就恭喜你,可以把warechousebak,optiondatabak删除了