Buffer_z Buffer_z - 2 months ago 7
SQL Question

SQL data type for a specific string

I have a string format like below:



++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>
++++++++++++++++++++++++++++<br/>
Sender ==> "Testsender"<br/>
Subject ==> "testsubject"<br/>
Content ==> "test Content ..."<br/>
++++++++++++++++++++++++++++++<br/>


There might be a lot of lines like those.

My question is: which data type should I use to store those lines (I think maximum will be 100 lines) in a SQL database.?

Answer

To answer your specific question: TEXT or VARCHAR(n) would be suitable to store such strings.

Though, I would definitely reconsider the model and I'm strongly advising against storing your data like that in databases in general. It seems that you are neither creating relations for that data nor you are using well-known and supported markup languages.

Is it possible that you are trying to reinwent the wheel (with formatting) or put the data inside database just the way you want to present it to a user? If so, I believe this is not the way to go. Try putting your data into a relational model (if that is your case) or any applicable format/design and build the presentation layer within your application code instead.