SQL-简单的代码

2022-07-12 05:19:16   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《SQL-简单的代码》,欢迎阅读!
代码,简单,SQL
创建数据库

CREAT DATABASE student ON PRIMARY ( NAME=std_dat1, FILENAME=d:\data\student1.mdf, SIZE=10MB, MAXSIZE=200MB, FILEGROWTH=20 ), ( NAME=std_dat2, FILENAME=d:\data\student2.ndf, SIZE=10MB, MAXSIZE=200MB, FILEGROWTH=20 ),

FILEGROUP business_group ( NAME=business_dat3, FILENAME=d:\data\businessdat3.ndf, SIZE=10MB, MAXSIZE=50MB, FILEGROWTH=10% )

LOG ON NAME=business_log, FILENAME=d:\data\businesslog.ldf,

SIZE=8MB, MAXSIZE=100MB, FILEGROWTH=10MB )

查看数据库属性 sp_helpdb;查看所有

sp_helpdbstudent查看student数据库属性 添加数据文件和日志文件 ALTER DATABASE sample ADD FILE ( NAME=sample_dat2, FILENAME=d:\data\sample_dat2.ndf, SIZE=4, MAXSIZE=10, FILEGROWTH=1

)

ALTER DATABASE sample ADD LOG FILE ( NAME=sample_log2, FILENAME=d:\data\sample_log2.ldf, SIZE=4, MAXSIZE=10, FILEGROWTH=1 )

添加文件组USER1,并向该文件组添加数据文件

ALTER DATABASE sample ADD FILEGROUP USER1



ALTER DATABASE sample ADD FILE ( NAME=sampuser_dat1, FILENAME=d:\data\sampuser_dat1.ndf, SIZE=4, MAXSIZE=10, FILEGROWTH=1 ), ( NAME=sampuser_dat2, FILENAME=d:\data\sampuser_dat2.ndf, SIZE=4, MAXSIZE=10, FILEGROWTH=1 )TO FILEGROUP USER1

删除数据库中的文件sampuser_dat2 ALTER DATABASE sample REMOVE FLIE sampuser_dat2 删除数据库中的文件组USER1 ALTER DATABASE sample REMOVE FLIE sampuser_dat1 ALTER DATABASE sample REMOVE FLIEGROUP USER1

删除文件组时必须先删除文件组包含的文件,否则报错


本文来源:https://www.wddqxz.cn/4bb10e0e05087632311212c3.html

相关推荐