create database databaseName
on primary
(
  Name =dbName1,
  FileName='C:\mydatabase1\dbName1.mdf',
  Size =10MB,
   MaxSize=20MB,
  FileGrowth=10mb),
(
  Name =dbName2,
  FileName='C:\mydatabase2\dbName2.mdf',
  Size =10MB,
   MaxSize=20MB,
  FileGrowth=10mb)
Log on
(
  Name =dbLogName1,
  Filename= 'C:\mydatabaseLog\dbLogName1.ldf',
  Size=10mb,
  MaxSize=20mb,
FileGrowth=10mb) 
/*
Name sql server使用的逻辑名称
Filename 完全限定的NT Server 文件名
Size 文件的初始大小 ,默认值是model数据库主文件[model.mdf]的大小
MaxSize 最大的文件尺寸,默认值是占满整个空间
FileGrowth 当需要时,SQL Server拓展文件的量 。默认值10%
*/

------------
---修改数据库----
--添加文件--
alter database  databaseName
add File
(
  Name= dbName3,
  size=10MB,
  MaxSize=20mb,
 FileName='C:\dbName3.mdf',
FileGrowth=10mb
)
---移除文件-----

Alter Database databaseName
remove File dbName3

------修改文件---------
alter database  databaseName
Modify File
(
 Name=dbName2,
 Size=15mb
)

数据库之study

create database study /*数据文件 前三行必写*/ on

(

name = study_data,

filename = 'f:\20160303\study.mdf',

size=20,

maxsize=unlimited,

filegrowth=20%

)

log on (

name = study_log,

filename = 'f:\20160303\study.log',

size=5,

maxsize=20,

filegrowth=2

)

/*GO的作用是先执行上面的语句  数据库建好之后再往下运行*/

use study

create table class (

class_no char(6) primary key,

class_name char(20) not null,

class_special varchar(20),

class_dept char(20)

)

GO

create table student (

s_no char(6) primary key,

class_no char(6) not null references class(class_no),

s_name varchar(10) not null,

s_sex char(2) check(s_sex ='男' or s_sex='女'),

s_birthday datetime

)

GO

create table course (

course_no char(5) primary key,

course_name char(20) not null,  course_score numeric(6,2)

)

GO create table choice (

s_no char(6) references student(s_no),

course_no char(5) references course(course_no),

score numeric(6,1)

)

GO

create table teacher (

t_no char(6) primary key,

t_name varchar(10) not null,

t_sex char(2) check(t_sex ='男' or t_sex='女'),

t_birthday datetime,  t_title char(10)

)

GO

create table teaching (

course_no char(5) references course(course_no),

t_no char(6) references teacher(t_no)

)

select * from choice

insert into class values('js9901','计算机99-1','计算机','计算机系')

insert into class values('js9902','计算机99-2','计算机','计算机系')

insert into class values('js0001','计算机00-1','计算机','计算机系')

insert into class values('js0002','计算机00-2','计算机','计算机系')

insert into class values('xx0001','信息00-1','信息','信息系') insert into class values('xx0002','信息00-1','信息','信息系')

insert into student values('991101','js9901','张斌','男','1981-10-1')

insert into student values('991102','js9901','王蕾','女','1980-8-8')

insert into student values('991103','js9901','李建国','男','1981-4-5')

insert into student values('991104','js9901','李平方','男','1981-5-12')

insert into student values('991201','js9902','陈东辉','男','1980-2-8')

insert into student values('991202','js9902','葛鹏','男','1979-12-23')

insert into student values('991203','js9902','潘耀志','女','1980-2-6')

insert into course values('01001','计算机基础','3')

insert into course values('01002','程序设计语言','5')

insert into course values('01003','数据结构','6')

insert into course values('02001','数据库原理与应用','6')

insert into course values('02002','计算机网络','6')

insert into choice values('991101','01001','88.0')

insert into choice(s_no,course_no) values('991102','01001')

insert into choice values('991103','01001','91.0')

insert into choice values('991104','01001','78.0')

insert into teacher values('000001','李英','女','1964-11-3','讲师')

insert into teacher values('000002','王大山','男','1955-3-3','副教授')

insert into teacher values('000003','张朋','男','1974-10-3','讲师')

insert into teacher values('000004','陈伟军','男','1963-11-1','助教')

insert into teacher values('000005','宋浩然','男','1966-12-4','讲师')

insert into teacher values('000006','徐红霞','女','1964-5-8','副教授')

insert into teaching values('01001','000001')

insert into teaching values('01002','000002')

insert into teaching values('01003','000003')

insert into teaching values('02001','000004')

select * from choice; select * from class select * from course select * from student select * from teacher select * from teaching

最新文章

  1. 基于Libevent的HTTP Server
  2. AIX下如何根据端口号查找相应的进程
  3. Lojic X
  4. PHP笔记(PHP高级篇)
  5. 关于那些难改的bug
  6. 查找字符串的 KMP 算法
  7. PHP学习心得(七)——常量
  8. 从一个App跳转到另一个App
  9. hadoop三个配置文件的参数含义说明core-site.xml,hdfs-site.xml,mapred-site.xml
  10. Python字符串的encode与decode研究心得——解决乱码问题
  11. Spring-AOP标签scoped-proxy
  12. vim永久显示行号
  13. XX-NET史上最详细完整教程
  14. linux笔记——一些命令工具
  15. Java DateUtil,日期整理
  16. python-day16--内置函数
  17. C#HttpUtility.UrlEncode 大写问题
  18. Linux 虚拟终端:screen
  19. Spring配置项<context:annotation-config/>解释说明
  20. 塔防游戏 Day2

热门文章

  1. 解决JPA懒加载典型的N+1问题-注解@NamedEntityGraph
  2. Master定理学习笔记
  3. XPath语法和CSS选择器介绍
  4. JZYZOJ 1542 [haoi2015]str 矩阵乘法 dp
  5. 【哈希表】Ural Championship April 30, 2017 Problem H. Hamburgers
  6. [BalkanOI2016]Cruise
  7. volitale最经典理解
  8. linq直接执行sql语句
  9. LINUX之文件操作权限讲解
  10. SecureCRT配置文件保存和导入