我可以更改文件表共享磁盘吗?
我已经使用这样的脚本在我的数据库上启用了文件流
DECLARE @dbName varchar(50),
@pathFileStream varchar(max),
@directoryNameFS varchar(max),
@sql varchar(max)
SET @dbName = 'mydb'
SET @pathFileStream = 'D:\fs'
SET @directoryNameFS = 'FileTableStream'
SET @sql = '
--0° set file stream full
ALTER DATABASE ' + @dbName + ' SET FILESTREAM( NON_TRANSACTED_ACCESS = FULL ) WITH NO_WAIT
--1° Add FileGroup
ALTER DATABASE ' + @dbName + '
ADD FILEGROUP FileStreamFileGroup CONTAINS FILESTREAM
GO
ALTER DATABASE ' + @dbName + '
ADD FILE (NAME = FileStreamData, FILENAME = ''' + @pathFileStream + ''')
TO FILEGROUP FileStreamFileGroup
GO
ALTER DATABASE ' + @dbName + ' SET FILESTREAM( DIRECTORY_NAME = ''' + @directoryNameFS + ''' ) WITH NO_WAIT
GO
'
PRINT @sql
然后我创建一个文件表:
IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'documentStore')
BEGIN
CREATE TABLE [dbo].[documentStore] AS FILETABLE ON [PRIMARY] FILESTREAM_ON [FileStreamFileGroup]
WITH
(
FILETABLE_DIRECTORY = N'documentStore', FILETABLE_COLLATE_FILENAME = Latin1_General_CI_AS
)
END
此时我的“documentStore”正在同一个数据库磁盘(磁盘C:\
)上共享。我需要指向文件流 ( D:
) 的同一个磁盘。