Create a FILESTREAM-enabled database?

I need to use FILESTREAM data storage functions in SQL database, so I want to know how to create this database.

+3


source to share


1 answer


If you want to use the FILESTREAM data storage functionality in a database, you must create a FILESTREAM-enabled database. You must specify a CONTAINS FILESTREAM clause for at least one filegroup.

Here is a sample script to create a FILESTREAM enabled database:

    CREATE DATABASE AccountSystem
    ON
    PRIMARY ( NAME = accountsystem1,
        FILENAME = 'c:\data\accountsystemdat1.mdf'),
    FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM( NAME = accountsystem3,
        FILENAME = 'c:\data\filestream1')
    LOG ON  ( NAME = Archlog1,
        FILENAME = 'c:\data\accountsystemlog1.ldf')
    GO

      

Here script Create database name "AccountSystem". This database contains three filegroups PRIMARY, accountystem1 AND FileStreamGroup1. PRIMARY and accounting system1 are normal filegroups that cannot contain FILESTREAM data. FileStreamGroup1 is a FILESTREAM filegroup.



For a FILESTREAM filegroup, FILENAME refers to a path. The path to the last folder must exist and the last folder must not exist. In this example, the data c: \ must exist. However, the filestream1 subfolder cannot exist when the CREATE DATABASE statement is executed.

After running this script, the filestream.hdr file and the $ FSLOG folder will appear in the c: \ Data \ filestream1 folder. The filestream.hdr file is the header file for the FILESTREAM container.

Important The filestream.hdr file is an important system file. It contains the FILESTREAM header information. Do not delete or modify this file.

You can use the ALTER DATABASE statement to add a FILESTREAM filegroup for an existing database.

+4


source







All Articles