Storing HTML in SQL Server(在 SQL Server 中存储 HTML)
问题描述
我应该使用什么数据类型在 SQL Server 2008 中存储 HTML 内容?
用于 CMS 的动态内容.
VARCHAR(MAX)
如果一切都基于 ascii,比如基本的 HTML 模板
NVARCHAR(MAX)
如果 HTML 可以包含任何内容
NVARCHAR 将使您的存储使用量增加一倍,因为它使用的空间量是 VARCHAR 的两倍.HTML 本身不需要 NVARCHAR,只有 HTML 标签之间的内容可以基于语言等.
从给出这个答案多年后,如果标签内容之间有任何内容,我现在几乎总是使用 NVARCHAR.Unicode 流行...
我只在存储简单的 html 模板时才使用 VARCHAR,例如标签和占位符
例如:
根据您的用例拨打电话..
What data type should I use to store HTML content in SQL Server 2008?
It's for dynamic content for a CMS.
VARCHAR(MAX)
if it's all going to be ascii-based, say for basic HTML tepmplates
NVARCHAR(MAX)
if the HTML could contain any content
NVARCHAR will double your storage use as it uses double the amount of space as VARCHAR. HTML itself does not require NVARCHAR, only the content in-between the HTML tags could based on the language, etc..
Edit:
Many years on from giving this answer I almost always use NVARCHAR now if there is any between the tag content. Unicode is popular...
I only use VARCHAR if just storing simple html templates, eg tags and placeholders
eg: <div><span>[PLACEHOLDER]</span><div>
Make the call based on your use-case..
这篇关于在 SQL Server 中存储 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 SQL Server 中存储 HTML


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01