3 Replies Latest reply: May 7, 2012 11:02 PM by indra budiantho RSS

    VARCHAR to BYTE comparison

    921009
      Hi,

      I have always defined my columns as varchar2(n) n ranging from 1 to 4000. I have inherited a table where the field is defined as varchar2(70 Byte). How can I determine the maximum string length that can fit in this field?

      Thanks

      Scott
        • 1. Re: VARCHAR to BYTE comparison
          Tubby
          918006 wrote:
          Hi,

          I have always defined my columns as varchar2(n) n ranging from 1 to 4000. I have inherited a table where the field is defined as varchar2(70 Byte). How can I determine the maximum string length that can fit in this field?

          Thanks

          Scott
          http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS99940
          • 2. Re: VARCHAR to BYTE comparison
            rp0428
            >
            I have always defined my columns as varchar2(n) n ranging from 1 to 4000. I have inherited a table where the field is defined as varchar2(70 Byte). How can I determine the maximum string length that can fit in this field?
            >
            The same way you always did - nothing has changed.

            varchar2(n) IS varchar2(n Byte) so you have been using 'byte' all along.

            So the method you used before will still work.

            See 'Length Semantics for Character Datatypes' in the Database Concepts doc
            http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CDEFDGFE
            >
            The length semantics of character datatypes can be measured in bytes or characters.
            Byte semantics treat strings as a sequence of bytes. This is the default for character datatypes.
            >
            The default is 'byte'
            • 3. Re: VARCHAR to BYTE comparison
              indra budiantho
              SELECT VSIZE (max_column_value) "BYTES"  from your_table;