FILESTREAM (SQL Server)
FILESTREAM (SQL Server) is a SQL data type in the Data Types category. SQL Server: stores BLOB data directly in the filesystem while maintaining transactional consistency. The syntax is column VARBINARY(MAX) FILESTREAM. It returns filestream BLOB. A typical example: -- Requires FILESTREAM enabled at server level CREATE DATABASE document_db CONTAINS FILESTREAM ... CREATE TABLE documents ( id INT PRIMARY KEY, file_name NVARCHAR(100), file_data VARBINARY(MAX) FILESTREAM, file_type VARCHAR(10) ); -- FILESTREAM data is stored as files on disk -- Benefits: -- 1. Stores data larger than 2GB -- 2. Backup can exclude FILESTREAM data -- 3. Integrates with NTFS streaming -- 4. Transactional consistency with SQL Server A close relative is INT, which standard integer type. Range: -2147483648 to 2147483647 (signed). Use BIGINT for larger values. A close relative is VARCHAR(n), which variable-length string with a maximum length. Most common string type. Efficient for varying-length data. A close relative is TEXT, which for large text content (up to 65535 bytes in MySQL). Variants: TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT.