如何将所有文件流varbinary(max)字段设置为NULL ?

时间:2022-05-22 12:27:50

I need to create a test database out of a huge database where the most data is contained as filestream data.

我需要从一个巨大的数据库中创建一个测试数据库,在这个数据库中,大多数数据都包含在filestream数据中。

I need to test not filestream related data, so what I'd like to do is to remove the varbinary(max) info.

我需要测试与filestream相关的数据,所以我想要做的是删除varbinary(max)信息。

These are the fields I have in my FILE_REPOSITORY_TABLE table:

这些是我在FILE_REPOSITORY_TABLE表中拥有的字段:

[ID_FILE] [int] NOT NULL,
[FILE_DATA] [varbinary](max) FILESTREAM  NULL,
[GUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL

What I tried to do is

我想做的是!

Update FILE_REPOSITORY_TABLE
SET FILE = NULL

I was expecting this to delete the files too, but it didn't happen.

我本来也想删除这些文件的,但这并没有发生。

I cannot delete the records, since ID_FILE has FK links. (when deleting records from a table containing filestream data also the related files are deleted). I also tried to do a backup anyway but the file size was big, even if the table is full of NULLs.

我不能删除记录,因为ID_FILE有FK链接。(当从包含文件流数据的表中删除记录时,也会删除相关文件)。我也尝试做备份,但是文件大小很大,即使表中满是空。

How can I do?

我怎么能做什么?

Final note: my goal is to have a 500MB backup instead of a 10GB one (I have 9,5 GB of docs). THis is only for testing purposes.

最后注意:我的目标是拥有500MB的备份,而不是10GB的(我有95gb的文档)。这仅用于测试目的。

1 个解决方案

#1


4  

The file data is reclaimed through a garbage collection process, rather then being removed immediately. Related blog post, so you might need to force checkpointing to occur.

通过垃圾收集过程回收文件数据,而不是立即删除。相关的博客文章,所以您可能需要强制执行检查点。

#1


4  

The file data is reclaimed through a garbage collection process, rather then being removed immediately. Related blog post, so you might need to force checkpointing to occur.

通过垃圾收集过程回收文件数据,而不是立即删除。相关的博客文章,所以您可能需要强制执行检查点。