首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 數據庫知識 >  >> SQL Server 資料庫 >> 關於SqlServer

SQL Server 2012 FileTable T-SQL 操作目錄完整實例

     編輯:關於SqlServer

先決條件:啟用 Filestream

EXEC sp_configure 'filestream access level', 2; RECONFIGURE;

建立支援 FileTable 的資料庫

CREATE DATABASE LearnFileTable
ON PRIMARY (NAME=LearnFileTable_Primary, FILENAME='E:\...\LearnFileTable_Data.mdf'),
FILEGROUP MyFS CONTAINS FILESTREAM DEFAULT (NAME=LearnFileFS, FILENAME='E:\...\LearnFileFS', MAXSIZE=UNLIMITED)
LOG ON (NAME=LearnFileTable_Log, FILENAME='E:\...\LearnFileTable_Log.ldf')
WITH FILESTREAM (NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'LearnFileTable');

圖示檔案群組與 Filestream 容器(圖 1)。

資料庫建立結果

建立 FileTable 資料表

CREATE TABLE MyFileTable01 AS FileTable
WITH (FileTable_Directory = 'MyFileTable01', FileTable_Collate_Filename = database_default);

系統自動建立含 `stream_id`、`file_stream`、`name`、`path_locator` 等欄位的表(圖 2-3),即可透過 T-SQL 或 Windows 檔案總管雙向操作檔案。

FileTable 結構

FileTable 資料

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved