Friday 8 February 2013

Storing C# Strings in an Oracle Database

This is not an Oracle blog, and Windows Joe has no intention of turning it into such. However, since Oracle coding is occasionally required by the Windows programmer, occasional clarifications on the aforementioned technology are sometimes warranted.

In addition, such posts may be of interest to database enthusiasts wanting to refresh the basics.

One such, is the popular newbie question (and also asked by experienced bods who haven't touched Oracle in a long time) is what datatype to use for string data?

VARCHAR - not to be used. Why - because Oracle says so. It may work, but is not recommended.
VARCHAR2 - the recommended way to store strings (or more precisely, VARIABLE LENGTH character strings).
CHAR - for fixed length character strings.Using this type to store variable length strings is a waste of space.

So in 95% of cases, you need a VARCHAR2 to represent strings in an Oracle database.

No comments: