在SQL Server的varchar字段上将大文本另存为压缩文件 [英] Saving a large text as zipped on a varchar field on sql server

查看:44
本文介绍了在SQL Server的varchar字段上将大文本另存为压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.net,实体框架6和SQL Server 2008R2.

I'm using VB.net , Entity framework 6 , SQL server 2008R2.

在varchar字段上,我应该保存一个很大的文本.但是未指定此文本上的字符数,因此我认为该字段的字符数将非常大.(我知道有一个VARCHAR(MAX),但我也在考虑使该字段中的数据大小尽可能小).同样由于多种原因,我无法使用文件来保存此文本(仅将文件名保留在数据库中).

I have a case when on a varchar field I should save a very large text. But the number of characters on this text is not specified so I think that will be very large for that field. ( I know there's a VARCHAR(MAX) but I'm thinking also to have the data size in this field as low as possible ). Also for several reasons I can't use a file to save this text ( keeping only the filename on database ).

所以我想问是否有什么办法可以将大文本压缩在数据库上,并且当从数据库中读取时当然要解压缩.

So I'm asking if is there any way to keep this large text zipped on database and of course to unzip when reading from database.

但是我正在寻找一种适用于实体框架的解决方案.所以,如果现在我正在使用:

But I'm searching for a solution that will work with entity framework. So if now I'm using :

Myobject.mytext="..... My text...."

如何转换此格式以放置压缩文本(如果可能的话)

How can I transform this in order to put the zipped text ( if is possible )

谢谢!

推荐答案

Sql Server不支持LOB的开箱即用"压缩(VARCHAR(MAX),其中Length> 8k).因此,最好的方法是在将客户端放入SQL Server的网络之前,先在客户端上进行压缩/解压缩

Sql Server does not support compression 'out of the box' of LOBs (VARCHAR(MAX) where Length>8k). So, the best approach would be to handle compression/decompression on the client, before you put it in the network towards SQL Server

所以

阅读时:

  • 使用压缩数据(使用EF)读取列
  • 解压缩您的字符串

这篇关于在SQL Server的varchar字段上将大文本另存为压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆