操作表结构的语句

转载 2006年06月07日 21:36:00
看看这个论坛的数据库结构吧,比较经典:
if exists (select * from sysobjects where id = object_id(N'[dbo].
[Announce]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Announce]
GO

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

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

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

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

CREATE TABLE [dbo].[Announce] (
[AnnounceID] [int] IDENTITY (1, 1) NOT NULL ,
[ParentID] [int] NULL ,
[Child] [int] NULL ,
[BoardID] [int] NULL ,
[UserName] [nvarchar] (50) NULL ,
[UserEmail] [nvarchar] (255) NULL ,
[URL] [nvarchar] (255) NULL ,
[URLTitle] [nvarchar] (255) NULL ,
[URLPic] [nvarchar] (255) NULL ,
[Topic] [nvarchar] (255) NULL ,
[Body] [ntext] NULL ,
[DateAndTime] [nvarchar] (50) NULL ,
[hits] [int] NULL ,
[length] [int] NULL ,
[RootID] [int] NULL ,
[layer] [int] NULL ,
[orders] [int] NULL ,
[emote] [int] NULL ,
[ip] [nvarchar] (20) NULL ,
[signature] [nvarchar] (255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[board] (
[BoardID] [int] IDENTITY (1, 1) NOT NULL ,
[BoardName] [nvarchar] (100) NULL ,
[BoardMaster] [int] NULL ,
[ignoreip] [nvarchar] (255) NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[essence] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[announceid] [int] NULL ,
[boardid] [int] NULL ,
[username] [nvarchar] (50) NULL ,
[useremail] [nvarchar] (255) NULL ,
[url] [nvarchar] (255) NULL ,
[urlTitle] [nvarchar] (255) NULL ,
[urlPic] [nvarchar] (255) NULL ,
[Topic] [nvarchar] (255) NULL ,
[Body] [ntext] NULL ,
[dateAndTime] [nvarchar] (50) NULL ,
[hits] [int] NULL ,
[length] [int] NULL ,
[emote] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[site] (
[SiteMasterPwd] [nvarchar] (50) NULL
) ON [PRIMARY]
GO

INSERT INTO [site]([SiteMasterPwd]) VALUES("intels")
GO

CREATE TABLE [dbo].[user] (
[UserID] [int] IDENTITY (1, 1) NOT NULL ,
[UserName] [nvarchar] (50) NULL ,
[UserEmail] [nvarchar] (255) NULL ,
[UserPassword] [nvarchar] (11) NULL ,
[icq] [nvarchar] (20) NULL ,
[homepage] [nvarchar] (255) NULL ,
[sex] [nvarchar] (10) NULL ,
[passanswer] [nvarchar] (100) NULL ,
[lastvisit] [smalldatetime] NULL ,
[incometime] [smalldatetime] NULL ,
[birthday] [smalldatetime] NULL ,
[points] [int] NULL ,
[visits] [int] NULL ,
[country] [nvarchar] (20) NULL ,
[city] [nvarchar] (20) NULL ,
[passquest] [nvarchar] (100) NULL ,
[signature] [nvarchar] (255) NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Announce] WITH NOCHECK ADD
CONSTRAINT [PK_Announce] PRIMARY KEY NONCLUSTERED
(
[AnnounceID]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[board] WITH NOCHECK ADD
CONSTRAINT [PK_board] PRIMARY KEY NONCLUSTERED
(
[BoardID]
) ON [PRIMARY]
GO


ALTER TABLE [dbo].[essence] WITH NOCHECK ADD
CONSTRAINT [PK_essence] PRIMARY KEY NONCLUSTERED
(
[id]
) ON [PRIMARY]
GO


ALTER TABLE [dbo].[user] WITH NOCHECK ADD
CONSTRAINT [PK_user] PRIMARY KEY NONCLUSTERED
(
[UserID]
) ON [PRIMARY]
GO

CREATE INDEX [announce_i] ON [dbo].[Announce]([RootID], [ParentID])
ON [PRIMARY]
GO

CREATE INDEX [Boardid] ON [dbo].[Announce]([BoardID]) ON [PRIMARY]
GO

CREATE INDEX [Boardid] ON [dbo].[essence]([boardid]) ON [PRIMARY]
GO

CREATE INDEX [points] ON [dbo].[user]([points]) ON [PRIMARY]
GO

CREATE INDEX [username] ON [dbo].[user]([UserName]) ON [PRIMARY]
GO

相关文章推荐

SQL语句显示表结构

select 字段名=a.name,序号=a.colorder, 主键=case when exists(select 1 from sysobjects where xtype='pk' and...

mysql数据库表操作语句

  • 2014-09-26 11:00
  • 15KB
  • 下载

Sql语句获取表结构

SQL SERVER --查看所有表名: select    name    from    sysobjects    where    ty...

delphi TShellListView控件尝试使用及sql语句修改表的结构

今天第一次使用TShellListView控件,用它的目的是为了向资源管理器一样显示一个目录的文件,用TListView的话显示文件图标有困难,也就是这点求完美的性格让我尝试着TShellListVi...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)