I tried to look here:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i3253
And I understand that I have to provide string length for the column, I'm just not able to find out how many bytes oracle uses when storing a character. My limit is 500 characters, so if its 1 byte / character, I can create the column with 500, if its 2 byte / character then 1000, etc.
Anyone have a link to the documentation or know for certain?
In case it matters, the SQL is being called from PHP, so these are PHP strings I'm inserting into the database. Thanks.
The datatype code of a column or object attribute is returned by the DUMP function. Variable-length character string having maximum length size bytes or characters. Maximum size is 4000 bytes or characters, and minimum is 1 byte or 1 character.
Eight bits are called a byte. One byte character sets can contain 256 characters. The current standard, though, is Unicode which uses two bytes to represent all characters in all writing systems in the world in a single set.
The VarChar data type can store a character string of a maximum length of 4000 bytes.
the number of bytes needed to store a character will depend upon the character set. If you want to store 500 characters and don't know the character set of the target database you should create the column (or variable) as a VARCHAR2(500 CHAR) or CHAR(500 CHAR).
A plain CHAR
is not necessarily one byte, depending on the setting of NLS_LENGTH_SEMANTICS
.
See Oracle's SQL Language Reference as a starting point. If you need to dig deeper, have a look at Oracle's Globalization Support Guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With