1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

how many bytes has the longest char ?

Discussion in 'SQL PL/SQL' started by monkey, Jun 5, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Please, how many bytes do we need for the longest character (char) and which one(s) is/are that?
    (are that kanji(s) in UTF-8?)

    many thanks!!!
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Re: how many bytes has the longest char ?

    Oracle has different types of character:
    - CHAR ( and NCHAR) : max 2000 bytes
    - VARCHAR2 (and NVARCHAR2): max. 4000 bytes

    You also have character large objects - CLOB: max. size is (4 gigabytes - 1) * (database block size).
     
    monkey likes this.
  3. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,348
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Re: how many bytes has the longest char ?

    You need to know that 4000 bytes may not be the same as 4000 characters, as Oracle supports multi-byte character sets that can hold Chinese, Korean and other languages where characters can't be represented by a single byte.
     
    monkey likes this.
  4. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    It also depends on if you are referring to datatypes for a table or for PL/SQL. In PL/SQL, VARCHAR2 variables can be up to 32K.

    With Oracle 12c, the new extended datatypes are available. When enabled, character datatypes (i.e. CHAR, VARCHAR2) have the same restrictions as LOBs (and in fact they are treated as LOBs in how they get stored when this feature is used).
     
    monkey likes this.
  5. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Re: how many bytes has the longest char ?

    Hello, David, right that was what I thought.
    For most characters I need just one byte per character, some need 2, and I wonder WHICH particular characters need most number of bites (seemed that some asian need 3 bytes per character and that is ment to me maximal number of bites per char, so I am just checking!)

    many thanks!!!
     
  6. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    Hi,
    You mentioned "kanji" in your post (Is it linked to Japanese characters ??) - I had read something some times ago that it's generally 3 bytes but MAY (I don't know in which cases...) take up to 4 bytes (or preferable to reserve 4 bytes).
     
    monkey likes this.
  7. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Thanks!
    No panick, have no tendnncy to use kanjis- at least not for now!
    Just curious!
    Many thanks!!!