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
基础教程推荐
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在多列上分布任意行 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
