创建数据库和表例子

CREATE DATABASE test
ON PRIMARY
(
      NAME =test_MDF,
      FILENAME = 'D:\0330141013\test_data.mdf',
      SIZE = 5MB,
      MAXSIZE = 100mb,
      FILEGROWTH = 15%
)
LOG ON
(
      NAME = test_log,
      FILENAME = 'D:\0330141013\test_log.ldf',
      SIZE = 2MB,
      FILEGROWTH = 1MB
)
GO

--定义当前操作的数据库
use  test

create table students
(
  stu_ID int not null primary key,
  sName varchar(10),
  sSex bit,     --bool类型
  sBirthday datetime,
  sSeat int,      --学生的座位号
  sEmail varchar(20),
  sAddress varchar(50),
  sPhone varchar(15)
)


create table score
(
  score_ID int not null identity(1,1) primary key,
  stu_ID int,
  course_ID int,
  score int  
)

create table course
(
  course_ID int not null primary key,
  course_name varchar(50)  
)

posted @ 2016-08-14 09:08  小-波  阅读(669)  评论(0编辑  收藏  举报