苏童 发表于 2017-12-14 08:32:34

Microsoft SQL Server学习(二)

----------------------  ----数据库语法(一)
  ----Author=“Mr zhong”
  ----------------------
  --创建学生数据库
  create database student
  on primary(
  name="student",
  filename="F:\Micro SQL Express\workplace\student",
  size=5MB,
  maxsize=20MB,
  filegrowth=1MB
  )
  log on(
  name="student_log",
  filename="F:\Micro SQL Express\workplace\student_log",
  size=5MB
  )
  --切换数据库
  use student
  --数据库文件的增、删、改、查
  --添加文件 ADD
  alter database student
  add file(
  name="test_file_3",
  filename="F:\Micro SQL Express\workplace\test_file_3",
  size=1MB
  )
  --修改文件 MODIFY
  alter database student
  modify file(
  name="test_file",
  size=4MB,
  filegrowth=10%
  )
  --查找数据库文件
  exec sp_helpfile test_file
  --删除文件 drop
  alter database student
  remove file test_file
  --重命名
  --数据库重命名
  exec sp_renamedb student,newstudent
  exec sp_renamedb newstudent,student
  --文件重命名
  alter database student
  modify file(
  name="test_file",
  newname="new_test_file"
  )
  alter database student
  modify file(
  name="new_test_file",
  newname="test_file"
  )
  exec sp_helpfile new_test_file
  --添加文件组
  alter database student

  add filegroup>  --添加文件到组内
  alter database student
  add file(
  name="test_file_4",
  filename="F:\Micro SQL Express\workplace\test_file_4"

  )to filegroup>  --查找文件组

  exec sp_helpfilegroup>  --删除文件组
  alter database student

  remove filegroup>
页: [1]
查看完整版本: Microsoft SQL Server学习(二)