如何在SQL中释放内存 [英] How to free memory in sql

查看:304
本文介绍了如何在SQL中释放内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个存储过程,因为我只有一列(区域varchar(50)).如果用户仅使用10个字符,以及如何通过使用sql

Hi,
I have one stored procedure in that i have one column (Area varchar(50)). If a user use only 10 characters and how to free the other memory by using sql

推荐答案

释放其他内存,则不必. :)

SQL Server不会真正根据表中的数据类型定义分配空间.它分配了足够的空间来保存数据(因此,如果您有10个字符,则只会分配10个字符的空间).

如果使用SQL Server 2005或更高版本,则可以使用varchar(max)数据类型,该数据类型最多可容纳2GB的数据,而您不必真正担心大小. SQL Server将为您做正确的事.仅当您的数据大于8K时,使用varchar(max)可能会导致性能下降,因为它不再适合单个页面,但是如果您有很多小于8K的数据,则您最好在引擎内部使用varchar(max),只要数据小于8K,就可以非常模拟varchar(N)和varchar(max).
You don''t really have to. :)

SQL Server does not really allocate space based on the datatype definition in your table. It allocates enough space to hold the data (so if you have 10 chars, it only allocates space for 10 chars).

If you use SQL Server 2005 or above, you can use the varchar(max) datatype, which will hold data up to 2GB, and you never really have to worry about the size. SQL Server will do the right thing for you. Only when your data gets bigger than 8K, you might get a small perf hit when using varchar(max) as it won''t fit on a single page anymore, but if you have a lot of data that is smaller than 8K, you might as well use varchar(max) as internally in the engine varchar(N) and varchar(max) are treated very simular as long as the data is less than 8K.


这篇关于如何在SQL中释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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