Difference in Datatype
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Difference in Datatype

  1. #1
    Join Date
    Feb 2001
    Posts
    119

    Difference in Datatype

    What's the Difference between these two.
    VARCHAR2(128)
    VARCHAR2(128 CHAR)

  2. #2
    Join Date
    May 2005
    Location
    AZ, USA
    Posts
    131
    One works and one doesn't ?

    busted2 varchar2(128 char);
    *
    ERROR at line 4:
    ORA-06550: line 4, column 22:
    PLS-00103: Encountered the symbol "CHAR" when expecting one of the following:
    ) , * & | = - + < / > at in mod not rem => ..
    <> or != or ~= >= <= <> and or like
    between is null is not || is dangling
    The symbol "," was substituted for "CHAR" to continue.

    Didn't you try it?

  3. #3
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Quote Originally Posted by dbtoo
    One works and one doesn't ?

    busted2 varchar2(128 char);
    *
    ERROR at line 4:
    ORA-06550: line 4, column 22:
    PLS-00103: Encountered the symbol "CHAR" when expecting one of the following:
    ) , * & | = - + < / > at in mod not rem => ..
    <> or != or ~= >= <= <> and or like
    between is null is not || is dangling
    The symbol "," was substituted for "CHAR" to continue.

    Didn't you try it?
    Code:
    SQL> create table w (col1 varchar2(10 char));
    
    Table created.
    Documented here
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  4. #4
    Join Date
    May 2005
    Location
    AZ, USA
    Posts
    131
    Hmm, Seems to be vergin dependant...


    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
    JServer Release 8.1.7.4.1 - Production

    SQL> create table w (col1 varchar2(10 char));
    create table w (col1 varchar2(10 char))
    *
    ERROR at line 1:
    ORA-00907: missing right parenthesis


    SQL>


    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production

    SQL> create table w (col1 varchar2(10 char));

    Table created.


    I stand somewhat corrected... or maybe that should be squat?

  5. #5
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,684
    Hi.

    By default the database uses byte-semantics, such that VARCHAR2(10) means 10 bytes. This is fine in a DB using a single-byte characterset, but in a DB with a multi-byte characterset VARCHAR2(10) may not hold 10 characters. As such the character-semantics can be used to specify the column should hold 10 characters, ergardless of the byte-size it takes to store.

    As a rule, people think of column sizes in characters, so when using multi-byte charactersets you should define all your string columns using character-symantics, or switch your default so you can do it implicitly.

    See:

    http://www.oracle-base.com/articles/...lization9i.php

    Cheers

    Tim...
    Tim...
    OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
    OCA PL/SQL Developer
    Oracle ACE Director
    My website: www.oracle-base.com
    My blog: www.oracle-base.com/blog

  6. #6
    Join Date
    Feb 2001
    Posts
    119

    Thanks.

    Thanks for the info.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width