Criação das tabelas de processamento do ColdSearch em SQL Server

Anterior
Próximo
Feedback
Imprimir

Criação das tabelas de processamento do ColdSearch em SQL Server

O script abaixo deve ser executado em um banco de dados próprio para o ColdSearch, cada serviço do ColdSearch deve ter seu próprio banco de dados.

 

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbColdSearch]') AND type in (N'U'))

BEGIN

 

CREATE TABLE [dbo].[tbColdSearch](

[ColdSearchId] [bigint] IDENTITY(1,1) NOT NULL,

[InsertDate] [smalldatetime] NOT NULL,

[TotalSearched] [bigint] NULL,

[TotalProcessed] [bigint] NULL,

[LastProcessDate] [smalldatetime] NULL,

[SearchStatus] [smallint] NOT NULL,

[XmlSearch] [varbinary](max) NOT NULL,

[TYPESEARCH] [varchar](1) NOT NULL,

CONSTRAINT [PK_tbColdSearch] PRIMARY KEY CLUSTERED

(

[ColdSearchId] 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

 

 

/****** Object:  Table [dbo].[tbColdSearchResult] ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbColdSearchResult]') AND type in (N'U'))

BEGIN

 

CREATE TABLE [dbo].[tbColdSearchResult](

[ResultId] [bigint] IDENTITY(1,1) NOT NULL,

[ColdSearchId] [bigint] NOT NULL,

[SequencialId] [bigint] NOT NULL,

[XmlData] [varbinary](max) NULL,

[PdfData] [varbinary](max) NULL,

[DocumentKey1] [bigint] NOT NULL,

[DocumentKey2] [bigint] NOT NULL,

[DocumentKey3] [bigint] NOT NULL,

CONSTRAINT [PK_tbColdSearchResult] PRIMARY KEY CLUSTERED

(

[ResultId] 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

 

ALTER TABLE [dbo].[tbColdSearchResult] WITH NOCHECK ADD CONSTRAINT [FK_tbColdSearchResult_tbColdSearch] FOREIGN KEY([ColdSearchId])

REFERENCES [dbo].[tbColdSearch] ([ColdSearchId])

NOT FOR REPLICATION

GO

 

ALTER TABLE [dbo].[tbColdSearchResult] NOCHECK CONSTRAINT [FK_tbColdSearchResult_tbColdSearch]

GO