IF EXISTS (SELECT Name FROM master.dbo.sysdatabases WHERE name = N'GuestBook')
DROP DATABASE GuestBook
GO
CREATE DATABASE GuestBook
go
use GuestBook
go
/*==============================================================*/
/*1 Table: Users */
/*==============================================================*/
CREATE TABLE Users (
ID bigint IDENTITY(1000,1) not null,
Name varchar(20) NOT NULL,
Pwd varchar(20) NOT NULL,
Popedom int NOT NULL,
)
go
ALTER TABLE Users
ADD PRIMARY KEY (ID ASC)
go
/*==============================================================*/
/*2 Table: Messages */
/*==============================================================*/
CREATE TABLE Messages (
Id bigint IDENTITY(1,1) not null,
L_Id bigint NOT NULL references Users(id),
Re_Id bigint NULL references Users(id),
Contents varchar(500) NOT NULL,
Title varchar(50) NOT NULL,
Re_Contents varchar(500) NULL,
L_time datetime NOT NULL default getdate(),
Re_time datetime NULL,
)
go
ALTER TABLE Messages
ADD PRIMARY KEY (Id ASC)
go
insert Users values ("admin","admin","1")
insert Users values ("Member","123","0")
go