Data Type for Storing Rich Text Format (rtf)

This article will describe which data type to use when you want to store rich formatted text (RTF) in a data base table.

To make a more correct decision on what data type to use for storing Rich Text Format files in your database, it is important to know what Rich Text Format files are. The data in a Rich Text Format file actually still is normal text, but it contains tags for all the text formatting. For example the Rich Text for a string that is bold, italic, underlined in Times Roman 14 points looks like this:

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;} {\f1\froman\fcharset2 Symbol;}{\f2\fswiss MS Sans Serif;} {\f3\froman\fprq2 Times New Roman;}}


\deflang1033\pard\plain\f3\fs28\b\i\ul Carpe diem.\plain\f2\fs17

\par }

Since the Rich Text Format is in fact text, you can store it in a column with a text data type. Be aware of the length to choose. When the length is smaller than 4000 characters, you can use a varchar. When the length is bigger than 4000 characters you better look to an alternative datatype. For ORACLE databases there is a datatype called CLOB that is introduced especially to store large character arrays. Other databases offer MEMO's, TEXT....


Learn Get products and technologies
  • Build your next data model with DeZign for Databases trial software, available for download directly from Datanamic's download section.