溫馨提示:您的每一次轉(zhuǎn)載,體現(xiàn)了我寫(xiě)此文的意義!!!煩請(qǐng)您在轉(zhuǎn)載時(shí)注明出處http://www.aygfsteel.com/sxyx2008/謝謝合作!!!

          雪山飛鵠

          溫馨提示:您的每一次轉(zhuǎn)載,體現(xiàn)了我寫(xiě)此文的意義!!!煩請(qǐng)您在轉(zhuǎn)載時(shí)注明出處http://www.aygfsteel.com/sxyx2008/謝謝合作!!!

          BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
            215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks
          創(chuàng)建數(shù)據(jù)庫(kù)表
          use master --切換到master數(shù)據(jù)庫(kù)
          go
          --檢測(cè)是否存在同名的數(shù)據(jù)庫(kù)
          if exists(select 1 from sysdatabases where name = 'tour')
          begin
            drop database tour
          end
          go
          create database tour
          on --數(shù)據(jù)文件
          (
            name = 'tour_mdf', --數(shù)據(jù)文件邏輯名
            filename = 'D:\tour.mdf',--數(shù)據(jù)文件存放路徑
            size = 1MB,--初始大小
            maxsize = 10MB,--最大大小
            filegrowth = 1MB--增長(zhǎng)速度
          )
          log on --日志文件
          (
            name = 'tour_ldf', --日志文件邏輯名
            filename = 'D:\tour.ldf',--日志文件存放路徑
            size = 1MB,--初始大小
            maxsize = 10MB,--最大大小
            filegrowth = 1MB--增長(zhǎng)速度
          )
          go
          use tour
          go
          創(chuàng)建數(shù)據(jù)庫(kù)表
          if exists(select * from sysobjects where name='stuInfo') drop table stuInfo
          create table   stuInfo    /*-創(chuàng)建學(xué)員信息表-*/
          (

          stuNo   varchar(6) not null unique,   --學(xué)號(hào),非空(必填)
          stuName  varchar(20) not null ,  --姓名,非空(必填)
          stuAge  int  not null,  --年齡,INT類型默認(rèn)為4個(gè)字節(jié)
          stuID  NUMERIC(18,0),     --身份證號(hào)
          stuSeat   int  IDENTITY (1,1),   --座位號(hào),自動(dòng)編號(hào)
          stuAddress   text   --住址,允許為空,即可選輸入
          )
          go

          if exists(select * from sysobjects where name='stuMarks') drop table stuMarks
          create table  stuMarks
          (
          ExamNo  varchar(6)  not null foreign key references stuInfo(stuNo) ,  --考號(hào)
          stuNo  varchar(6) not null,   --學(xué)號(hào)
          writtenExam  int  not null,  --筆試成績(jī)
          LabExam  int  not null    --機(jī)試成績(jī)
          )
          go

          if exists(select * from sysobjects where name='users') drop table users
          create table users
          (
              userID int not null primary key identity(1,1),
              userName varchar(255) not null unique,
              userPWD varchar(255) not null,
              userAge int,
              userBirthDay datetime,
              userEmail varchar(255)
          )
          go
          posted on 2010-06-27 01:34 雪山飛鵠 閱讀(4525) 評(píng)論(0)  編輯  收藏 所屬分類: database
          主站蜘蛛池模板: 长子县| 故城县| 即墨市| 雅江县| 陈巴尔虎旗| 金华市| 曲沃县| 汉川市| 新宁县| 贡山| 新丰县| 玛曲县| 绍兴县| 宁都县| 舞钢市| 民乐县| 娄烦县| 广平县| 太原市| 嘉义县| 得荣县| 东台市| 元氏县| 丁青县| 招远市| 扎兰屯市| 库尔勒市| 甘孜县| 大城县| 卢氏县| 房产| 莆田市| 尉犁县| 鱼台县| 滨州市| 固始县| 宁明县| 阿拉善左旗| 道孚县| 普宁市| 汉中市|