操作表结构的语句

转载 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

顺序性,一致性,原子性:现代多核体系结构与原子操作·CAS与自旋锁·自旋锁与并发编程的原语·语句原子性和编程逻辑的原子性·行锁与数据库事务原子性·binlog与数据库同

顺序性: 乱序执行·逻辑正确性  现代体系结构的每一个核的指令流水是乱序执行的,但是他能够保证其执行效果等同于顺序执行。 一致性: 各核及线程缓存·volatile 各核缓存及线...

数据库建表操作SQL语句大全

  • 2016年01月28日 15:53
  • 440KB
  • 下载

mysql数据库表操作语句

  • 2014年09月26日 11:00
  • 15KB
  • 下载

[疯狂Java]SQL:DDL语句(定义、修改表结构)

1. DDL的概念:     1) 即Data Definition Language,即数据定义语言,操作的对象是数据库对象,主要用来定义数据对象;     2) 数据对象:共8种,分为4大类   ...

oracle父子结构表递归查询sql语句

select j.*,j.rowid from SJ_LIB_CATEGORY j start with j.id ='c8759461-9b5e-4375-90f7-94f9c84dbe51' c...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:操作表结构的语句
举报原因:
原因补充:

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