--방명록 테이블 설계
Create Table GuestBooks
(
ItemID Int Identity(1,1) Primary Key,
Name VarChar(25) Not Null,
Content Varchar(8000) Not Null,
Password VarChar(20) Not Null,
PostDate SmallDateTime Default(GetDate()),
PostIP VarChar(15)
)
Go
--예시문 6개 티이핑
--Insert Into GuestBooks Values('김용원',1234,GETDATE(),'192.168.10.133')
--Go
--Insert Into GuestBooks Values('이준철',4321,GETDATE(),'192.168.10.134')
--Go
Select *From GuestBooks
--샘플 데이터 100개 입력
Declare @i Int
Set @i = 1
While @i <= 100
Begin
If @i % 2 = 0
Begin
Insert Into GuestBooks Values('김용원', '안녕', '1234', GetDate
(),'127.0.0.1');
End
Else
Begin
Insert Into GuestBooks Values('이준철', '방가', '1234', GetDate
(),'127.0.0.1');
End
Set @i = @i + 1
End
Go |
Select COUNT(*) From GuestBooks
--Select *From GuestBooks
--6개 저장 프로시저 생성 : 하세요
--입력
Create Proc AddGuestBook
@Name VarChar(25),
@Content VarChar(8000),
@Password VarChar(20),
@PostIP VarChar(15)
As
Insert Into GuestBooks Values(@Name,@Content, @Password,
GetDate(),@PostIP);
Go |
--출력
Create Proc GetGuestBooks
As
Select *From GuestBooks Order By ItemID Desc
Go |
|