这篇文章主要为大家详细介绍了SQL Server 的FileStream和FileTable深入示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
互联网时代数据是爆炸式增长,我们常常需要把结构化数据和非结构化数据(如文档,演示文稿,视频,音频,图像)存储在一起。通常有几种方案:代码如下:
USE master GO
EXEC sp_configure 'filestream access level', 2
Go
RECONFIGURE GO
--You can use this statement to see current
--config value and running value
EXEC sp_configure filestream_access_level;
GO
代码如下:
USE master
GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'LearnFileTable')
DROP DATABASE LearnFileTable
GO
CREATE DATABASE LearnFileTable
--Details of primary file group
ON PRIMARY
( NAME = LearnFileTable_Primary,
FILENAME =N'D:\FileTable\LearnFileTable_Data.mdf',
SIZE = 10MB,
MAXSIZE = 50MB,
FILEGROWTH = 5MB),
--Details of additional filegroup to be used to store data
FILEGROUP DataGroup
( NAME = LearnFileTable_Data,
FILENAME =N'D:\FileTable\LearnFileTable_Data.ndf',
SIZE = 10MB,
MAXSIZE = 50MB,
FILEGROWTH = 5MB),
--Details of special filegroup to be used to store FILESTREAM data
FILEGROUP FSDataGroup CONTAINS FILESTREAM
( NAME = FileStream,
--FILENAME refers to the path and not to the actual file name. It
--creates a folder which contains a filestream.hdr file and
--also a folder $FSLOG folder as depicted in image below
FILENAME =N'D:\FileTable\FSData')
--Details of log file
LOG ON
(Name = LearnFileTable_Log,
FILENAME = 'D:\FileTable\LearnFileTable_Log.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB
)
WITH FILESTREAM (NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'LearnFileTable')
--Other option for NON_TRANSACTED_ACCESS is READ_ONLY or OFF
GO
代码如下:
-- Check the Filestream/FileTable Options
SELECT DB_NAME(database_id), non_transacted_access, non_transacted_access_desc, directory_name FROM sys.database_filestream_options
WHERE DB_NAME(database_id) = 'LearnFileTable'
代码如下:
USE LearnFileTable
GO
CREATE TABLE MyFirstFileTable AS FileTable
WITH
(
FileTable_Directory = 'MyFirstFileTable',
FileTable_Collate_Filename = database_default
);
GO
本文来自:http://www.q1010.com/179/7815-0.html
注:关于SQL Server 的FileStream和FileTable深入示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:SQL SERVER
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。