if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_admin]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_admin]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_daily]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_daily]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_from]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_from]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_global]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_global]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_hour]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_hour]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_ip]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_ip]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_keyword]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_keyword]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_onlineuser]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_onlineuser]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_page]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_page]
GO

CREATE TABLE [dbo].[t_admin] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[adminname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[adminpass] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_daily] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_date] [datetime] NULL ,
	[f_time] [datetime] NULL ,
	[f_week] [smallint] NULL ,
	[f_hits] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_from] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_fromurl] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_date] [datetime] NULL ,
	[f_hits] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_global] (
	[id] [int] NOT NULL ,
	[f_totalip] [int] NULL ,
	[f_totalpv] [int] NULL ,
	[f_date] [datetime] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_hour] (
	[f_date] [datetime] NOT NULL ,
	[f_h00] [int] NULL ,
	[f_h01] [int] NULL ,
	[f_h02] [int] NULL ,
	[f_h03] [int] NULL ,
	[f_h04] [int] NULL ,
	[f_h05] [int] NULL ,
	[f_h06] [int] NULL ,
	[f_h07] [int] NULL ,
	[f_h08] [int] NULL ,
	[f_h09] [int] NULL ,
	[f_h10] [int] NULL ,
	[f_h11] [int] NULL ,
	[f_h12] [int] NULL ,
	[f_h13] [int] NULL ,
	[f_h14] [int] NULL ,
	[f_h15] [int] NULL ,
	[f_h16] [int] NULL ,
	[f_h17] [int] NULL ,
	[f_h18] [int] NULL ,
	[f_h19] [int] NULL ,
	[f_h20] [int] NULL ,
	[f_h21] [int] NULL ,
	[f_h22] [int] NULL ,
	[f_h23] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_ip] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ip] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_date] [datetime] NULL ,
	[f_hits] [int] NULL ,
	[f_address] [varchar] (150) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_keyword] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_keyword] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_fromurl] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_date] [datetime] NULL ,
	[f_hits] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_onlineuser] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_pageurl] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_from] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_timevisite] [datetime] NULL ,
	[f_sessionid] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_ip] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[t_page] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_pageurl] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[f_date] [datetime] NULL ,
	[f_time] [datetime] NULL ,
	[f_hits] [int] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[t_admin] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_admin] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_daily] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_daily] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_from] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_from] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_global] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_global] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_hour] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_hour] PRIMARY KEY  CLUSTERED 
	(
		[f_date]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_ip] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_ip] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_keyword] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_keyword] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_onlineuser] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_onlineuser] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_page] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_page] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_hour] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_hour_f_h00] DEFAULT (0) FOR [f_h00],
	CONSTRAINT [DF_t_hour_f_h01] DEFAULT (0) FOR [f_h01],
	CONSTRAINT [DF_t_hour_f_h02] DEFAULT (0) FOR [f_h02],
	CONSTRAINT [DF_t_hour_f_h03] DEFAULT (0) FOR [f_h03],
	CONSTRAINT [DF_t_hour_f_h04] DEFAULT (0) FOR [f_h04],
	CONSTRAINT [DF_t_hour_f_h05] DEFAULT (0) FOR [f_h05],
	CONSTRAINT [DF_t_hour_f_h06] DEFAULT (0) FOR [f_h06],
	CONSTRAINT [DF_t_hour_f_h07] DEFAULT (0) FOR [f_h07],
	CONSTRAINT [DF_t_hour_f_h08] DEFAULT (0) FOR [f_h08],
	CONSTRAINT [DF_t_hour_f_h09] DEFAULT (0) FOR [f_h09],
	CONSTRAINT [DF_t_hour_f_h10] DEFAULT (0) FOR [f_h10],
	CONSTRAINT [DF_t_hour_f_h11] DEFAULT (0) FOR [f_h11],
	CONSTRAINT [DF_t_hour_f_h12] DEFAULT (0) FOR [f_h12],
	CONSTRAINT [DF_t_hour_f_h13] DEFAULT (0) FOR [f_h13],
	CONSTRAINT [DF_t_hour_f_h14] DEFAULT (0) FOR [f_h14],
	CONSTRAINT [DF_t_hour_f_h15] DEFAULT (0) FOR [f_h15],
	CONSTRAINT [DF_t_hour_f_h16] DEFAULT (0) FOR [f_h16],
	CONSTRAINT [DF_t_hour_f_h17] DEFAULT (0) FOR [f_h17],
	CONSTRAINT [DF_t_hour_f_h18] DEFAULT (0) FOR [f_h18],
	CONSTRAINT [DF_t_hour_f_h19] DEFAULT (0) FOR [f_h19],
	CONSTRAINT [DF_t_hour_f_h20] DEFAULT (0) FOR [f_h20],
	CONSTRAINT [DF_t_hour_f_h21] DEFAULT (0) FOR [f_h21],
	CONSTRAINT [DF_t_hour_f_h22] DEFAULT (0) FOR [f_h22],
	CONSTRAINT [DF_t_hour_f_h23] DEFAULT (0) FOR [f_h23]
GO

insert into t_admin(adminname,adminpass) values('admin','21232f297a57a5a743894a0e4a801fc3')