Difference between BYTE & CHAR

hi all,
In Oracle, As per below syntax, what is the difference between BYTE & CHAR used as datatype size for NAME column:
CREATE TABLE CLIENT
NAME VARCHAR2(11 BYTE),
ID_CLIENT NUMBER
and
CREATE TABLE CLIENT
NAME VARCHAR2(11 CHAR), -- or even VARCHAR2(11)
ID_CLIENT NUMBER
rgds,
pc

First of - do not use reserved words for columns (NAME).
If the database character set is UTF-8, which I believe is the default in recent version of Oracle. In this case, some characters take more than 1 byte to store in the database.
If you define the field as VARCHAR2(11 BYTE), Oracle will allocate 11 bytes for storage, but you may not actually be able to store 11 characters in the field, because some of them take more than one byte to store, e.g. non-English characters.
By defining the field as VARCHAR2(11 CHAR) you tell Oracle to allocate enough space to store 11 characters, no matter how many bytes it takes to store each one. I believe that in Oracle 10g, 3 bytes per character were used.
regards,
Robert.

Similar Messages

  • Difference between Reference char and template

    Hi Guys,
      Can anybody explain me what is tthe difference between  Reference char and template.
    Thanks,
    chinna
    Points will be awarded

    Reference Char:
    when a new Infoobject is referenced to another, all the technical properties will be inhereted by the new InfoObject.Also check this,
    http://help.sap.com/saphelp_nw04/helpdata/en/ff/f470375fbf307ee10000009b38f8cf/frameset.htm

  • Difference between Byte mode & Character mode

    Hi,
    what is the difference between Byte mode & Character Mode, could u make me clear which is the best in which situation.
    Thanks & Regards,
    [email protected]

    This becomes relevant in unicode environments. A character in Unicode can consist of more then one byte, espacially fpr national characters. So i counting by character can reveal 4 characters, but it might be that 5 bytes or even more are used.
    String/Characterhandling can completly fail in unicode environments using the wrong clause.

  • JMS paging store - what is difference between bytes and messages threshholds?

              You can activate and configure both "bytes paging" and "message paging". What
              is the difference? Why use one or the other or are both required?
              Thanks,
              John
              

    Hi Mr. Black,
              Cool name.
              Message paging is based on number of messages. Bytes paging is based
              on the size of message payload (properties, body, corr-id, and type),
              where the payload does not include the header size. One can set
              either or both -- if both are set, paging kicks in as soon
              as the first threshhold is reached.
              As for which one to use, you may wish to set both. The former
              accounts for large numbers of small messages, and the latter
              handles large messages. (eg 1000 small 10 byte messages
              will charge 10,000 bytes toward quota but actually use up
              128,000 bytes of JVM memory once the header is thrown in...)
              Tom
              John Black wrote:
              > You can activate and configure both "bytes paging" and "message
              paging". What
              > is the difference? Why use one or the other or are both required?
              >
              > Thanks,
              > John
              

  • Interpreting results - difference between bar char...

    Hi,
    I'd like some help interpreting the results of my recent BT speedtest
    The results said that my max achievable is 2000kbps and that my DSL connection rate is 5008 kbps (or thereabouts)
    I thought the DSL connection rate was the max achievable - so why the barchart figure only going to 2000kbps
    I'd appreciate any explanation/help anyone might be able to provide
    Thanks
    Dominic

    Thanks...yes
    FAQ
    Test1 comprises of Best Effort Test: -provides background information.
    Download  Speed
    1608 Kbps
    0 Kbps
    2000 Kbps
    Max Achievable Speed
     Download speedachieved during the test was - 1608 Kbps
     For your connection, the acceptable range of speeds is 400-2000 Kbps.
     Additional Information:
     Your DSL Connection Rate :5088 Kbps(DOWN-STREAM), 448 Kbps(UP-STREAM)
     IP Profile for your line is - 1750 Kbps
    So my question is why is the max achievable speed at 2000 kbps but the DSL connection rate is 5088kbps - I have a PlusNet teleworker contract that goes up to 8mbps. BTW, I'm working on various ways of getting the IP Profile up - changing telephone, router etc to find out why the IP profile isn't nearer the max speed.
    Thanks for any insight here

  • Difference between CHAR & BYTE with respect to Storage

    Hi,
    I HAVE CREATED THREE TABLES WITH DIFFERENT STORAGE FORMATS.
    SQL> CREATE TABLE A
    2 (ENAME CHAR);
    Table created.
    SQL> CREATE TABLE AA
    2 (ENAME CHAR(1 CHAR));
    Table created.
    SQL> CREATE TABLE AAA
    2 (ENAME CHAR(1 BYTE));
    WHEN I AM TRYING TO INSERT THE VALUES
    CASE1) INSERTING A SINGLE CHARACTER ONLY
    SQL> INSERT INTO A
    2 VALUES
    3 ('A');
    1 row created.
    SQL> INSERT INTO AA
    2 VALUES
    3 ('A');
    1 row created.
    SQL> INSERT INTO AAA
    2 VALUES
    3 ('A');
    1 row created.
    INSERTING MORE THAN ONE CHARACTER IN AAA TABLE
    SQL> INSERT INTO AA
    2 VALUES
    3 ('AA');
    ('AA')
    ERROR at line 3:
    ORA-12899: value too large for column "RAVI1"."AA"."ENAME" (actual: 2, maximum:
    1)
    SQL> INSERT INTO AAA
    2 VALUES
    3 ('AAA');
    ('AAA')
    ERROR at line 3:
    ORA-12899: value too large for column "RAVI1"."AAA"."ENAME" (actual: 3,
    maximum: 1)
    please can any one tell me the differences.
    Thanks & Regards
    SAI***BABA

    This one might help: Re: What is the difference between VARCHAR2(5 BYTE) & VARCHAR2(5 CHAR)?
    Jim P.

  • Difference between varchar2(4000 byte) & varchar2(4000 char

    Hi,
    My existing database NLS parameters as follows
    CHARACTER SET US7ASCII
    NATIONAL CHARACTER SET AL16UTF16
    created a test database to support globalization, I changed as follows
    CHARACTER SET UTF8
    NATIONAL CHARACTER SET UTF8
    some of the table column datatypes are varchar2(4000)
    I would like to know what is difference between VARCHAR2(4000 BYTE) and VARCHAR2(4000 CHAR).
    Thanks

    Indeed, VARCHAR2(x BYTE) means that the column will hold as much characters as will fit into x bytes. Depending on the character set and particular characters this may be x or less characters.
    For example, a VARCHAR2(20 BYTE) column in an AL32UTF8 database can hold 20 characters from the ASCII range, 10 Latin letters with umlaut, 10 Cyryllic, 10 Hebrew, or 10 Arabic letters (2 bytes per character), or 6 Chinese, Japanese, Korean, or Devanagari (Indic) characters. Or a mixture of these characters of any total length up to 20 bytes.
    VARCHAR2(x CHAR) means that the column will hold x characters but not more than can fit into 4000 bytes. Internally, Oracle will set the byte length of the column (DBA_TAB_COLUMNS.DATA_LENGTH) to MIN(x * mchw, 4000), where mchw is the maximum byte width of a character in the database character set. This is 1 for US7ASCII or WE8MSWIN1252, 2 for JA16SJIS, 3 for UTF8, and 4 for AL32UTF8.
    For example, a VARCHAR2(3000 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 4000 bytes. It will hold up to 3000 characters from the ASCII range (the character limit), but only 1333 Chinese characters (the byte limit, 1333 * 3 bytes = 3999 bytes). A VARCHAR2(100 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 400 bytes. It will hold up to any 100 Unicode characters.
    The above implies that the CHAR limit works optimally if it is lower than 4000/mchw. With such restriction, the CHAR limit guarantees that the defined number of characters will fit into the column. Because the widest character in any Oracle character set has 4 bytes, if x <= 1000, VARCHAR2(x CHAR) is guaranteed to hold up to x characters in any database character set.
    The declaration VARCHAR2(x):
    - for objects defined in SYS schema means VARCHAR2(x BYTE),
    - for objects defined in other schemas it means VARCHAR2(x BYTE) or VARCHAR2(x CHAR), depending on the value of the NLS_LENGTH_SEMANTICS parameter of the session using the declaration (see the NLS_SESSION_PARAMETERS view).
    After an object is defined, its BYTE vs CHAR semantics is stored in the data dictionary and it does not depend on the NLS_LENGTH_SEMANTICS any longer. Even Export/Import will not change this.
    Character length semantics rules are valid for table columns and for PL/SQL variables.
    -- Sergiusz

  • Difference between VARCHAR2(40 BYTE) and VARCHAR2(40 CHAR)

    What is the difference between using VARCHAR2(40), VARCHAR2(40 BYTE0, and VARCHAR2(40 CHAR)

    With a single byte character set the two definitions are effictively equal, but with a multibyte character set the two definitions will be different. Say you have built Oracle using a fixed 2 byte character set. 40 characters would be 80 bytes so the varchar2(40 BYTES) would hold only 20 characters.
    Search on NLS parameters and database character set for more information.
    HTH -- Mark D Powell --

  • Difference between char and varchar, also the difference between varchar2

    Hi,
    Can anyone explain me the difference between char and varchar, and also the difference between varchar and varchar2...

    Varchar2 is variable width character data type, so if you define column with width 20 and insert only one character to tis column only, one character will be stored in database. Char is not variable width so when you define column with width 20 and insert one character to this column it will be right padded with 19 spaces to desired length, so you will store 20 characters in the dattabase (follow the example 1). Varchar data type from Oracle 9i is automaticlly promoted to varchar2 (follow example 2)
    Example 1:
    SQL> create table tchar(text1 char(10), text2 varchar2(10))
    2 /
    Table created.
    SQL> insert into tchar values('krystian','krystian')
    2 /
    1 row created.
    SQL> select text1, length(text1), text2, length(text2)
    2 from tchar
    3 /
    TEXT1 LENGTH(TEXT1) TEXT2 LENGTH(TEXT2)
    krystian 10 krystian 8
    Example 2:
    create table tvarchar(text varchar(10))
    SQL> select table_name,column_name,data_type
    2 from user_tab_columns
    3 where table_name = 'TVARCHAR'
    4 /
    TABLE_NAME COLUMN_NAME DATA_TYPE
    TVARCHAR TEXT VARCHAR2
    Best Regards
    Krystian Zieja / mob

  • Difference between CHAR and VARCHAR2 datatype

    Difference between CHAR and VARCHAR2 datatype
    CHAR datatype
    If you have an employee name column with size 10; ename CHAR(10) and If a column value 'JOHN' is inserted, 6 empty spaces will be inserted to the right of the value. If this was a VARCHAR column; ename VARCHAR2(10). How would it handle the column value 'JOHN' ?

    The CHAR datatype stores fixed-length character strings, and Oracle compares CHAR values using blank-padded comparison semantics.
    Where as the VARCHAR2 datatype stores variable-length character strings, and Oracle compares VARCHAR2 values using nonpadded comparison semantics.
    This is important when comparing or joining on the columns having these datatypes;
    SQL*Plus: Release 10.2.0.1.0 - Production on Pzt Au 6 09:16:45 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    SQL> conn hr/hr
    Connected.
    SQL> set serveroutput on
    SQL> DECLARE
    2 last_name1 VARCHAR2(10) := 'TONGUC';
    3 last_name2 CHAR(10) := 'TONGUC';
    4 BEGIN
    5 IF last_name1 = last_name2 THEN
    6 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is equal to -' || last_name2
    || '-');
    7 ELSE
    8 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is NOT equal to -' || last_n
    ame2 || '-');
    9 END IF;
    10 END;
    11 /
    -TONGUC- is NOT equal to -TONGUC -
    PL/SQL procedure successfully completed.
    SQL> DECLARE
    2 last_name1 CHAR(6) := 'TONGUC';
    3 last_name2 CHAR(10) := 'TONGUC';
    4 BEGIN
    5 IF last_name1 = last_name2 THEN
    6 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is equal to -' || last_name2
    || '-');
    7 ELSE
    8 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is NOT equal to -' || last_n
    ame2 || '-');
    9 END IF;
    10 END;
    11 /
    -TONGUC- is equal to -TONGUC -
    PL/SQL procedure successfully completed.
    Also you may want to read related asktom thread - "Char Vs Varchar" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1542606219593
    and http://tahitiviews.blogspot.com/2007/05/less-is-more-more-or-less.html
    Best regards.

  • Difference between int and byte

    what is the main difference between int and byte?

    A byte is the format data is stored in memory in past. 8 bits.
    An int is a format likewise you get it as value from the accumulator. For X64 that is Int64.
    For compatibility the "Integer" is kept currently on Int32, the register format from the X86 computers. 
    Older computers likewise the 8088 had an 8 bit Int and therefore that was the same as the byte.
    The 80286 had a 16 bits Integer.
    Success
    Cor

  • Byte count difference between Unix and Windows

    Hi,
    I use sun.net.ftp.FtpClient to transfer files from a windows machine to a unix server.
    The transfer works fine.
    However, due to a problem I had a few days ago with the file not completing it's transfer but no side (not my FtpClient object nor the UNIX Ftp server) has thrown an exception or reported an error, I need to verify the transfer is complete.
    from the byte count I see that on my machine, the file size is 120743 bytes, and on the server side it's 121047 bytes.
    The file has 14172 records, when the last one is an empty line.
    There is a 304 bytes difference between the 2 reports.
    I downloaded the file I transferred there manually and compared the 2 and they match.
    How can I know from my program if the transfer is complete?
    Thanks,
    Omer.

    The file size isn't 304 byte, that's the difference between the 2 files.
    I use FtpClient.binary() to set the mode to binary prior to sending the file.
    The file has 14172 records which should add up to a total difference of 14172 bytes (maybe 1 or 2 more if there is a difference in the EOF), but not 304.
    here's the code:
    putClient=new FtpClient(host, port); //initialize the client object
    putClient.login(user, password);
    putClient.binary(); //set transfer mode to binary
    putClient.cd(remotePath); //change directory to the target one
    FileInputStream fileIn=new FileInputStream(sourcePath + File.separator + sourceFileName);
    long fileSize=fileIn.getChannel().size(); //get the size of the file
    TelnetOutputStream telnetOut=putClient.put(remoteFileName);//acquire an input stream from the server
    byte[] byteBuff=new byte[8192]; //8 kb buffer
    int readSuccesfull=0;
    while((readSuccesfull=fileIn.read(byteBuff))!=-1){ // now transfer the file
    telnetOut.write(byteBuff, 0, readSuccesfull);
    totalByetsSent+=readSuccesfull;
    fileIn.close();//release the file stream resource
    TelnetInputStream inStream = putClient.list(); // acquire a stream for verifying the file was received
    /* now I read the lines of the list() command and parse the lines for the size and date and I get that the file that I sent has a size of 121047, and the line that represents it is this:
    -rwxrwxrwx   1 owner    group          121047 Jan 10 17:49 ivory.txt
    However, the size from my machine's report is 120743 which I get from the fileSize variable*/According to what has been said here, and to my intuition, the size on UNIX should be smaller than the size on Windows, but yet, it's not the case.
    This would add up fine if the file that I downloaded from the server wouldn't match the file that I sent, but they do.
    I'm pretty much a noob at developing and even more a noob at Java, so there is a very good chance that I do something wrong here, could be with the use of the FileChannel.size() method usage.
    Thanks.

  • DIFFERENCE BETWEEN THE DATA DECLARATIONS NVARCHAR2 AND VARCHAR2(x CHAR)

    CAN ANYONE HELP ME FIND THE DIFFERENCE BETWEEN THE DATA DECLARATIONS; NVARCHAR2 AND VARCHAR2(x CHAR), WHERE X IS THE SIZE OF DATA TO BE HELD WITH THE VARIABLE OR ATTRIBUTE

    Duplicate posting....
    Difference between nvarchar2(10) and varchar2(10 char )
    Difference between nvarchar2( 10) and varchar2( 10 char)
    Please refer also...
    Nvarchar2

  • Difference between nvarchar2( 10) and varchar2( 10 char)

    Hi ,
    I had to enhance my application's DB to support unicode data entries(Multilingual data entries) and retrieval. I want to know the basic difference between the following data type decalrations:
    nvarchar2( 10) and varchar2( 10 char)
    Can any one suggest me which would be a optimum choice?
    regards,
    Siddarth

    Yes, you are almost correct.
    Can you read Japanese Character ? (There is no need to understand Japanese words meanings).
    Are you ready? Let's go!
    SQL> create table tab_size(col varchar(3));
    Table created.
    SQL> insert into tab_size values ('abc');
    1 row created.
    SQL> insert into tab_size values ('abcd');
    insert into tab_size values ('abcd')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
    SQL> insert into tab_size values('アイウ'); /* This is  3 characters (3byte) */
    1 row created.
    SQL> insert into tab_size values('アイウエ'); /* This is  4 characters (4byte) */
    insert into tab_size values('アイウエ')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
    SQL> insert into tab_size values ('あ'); /* This is 1 character (2bytes) */
    1 row created.
    SQL> insert into tab_size values ('あい'); /* This is 2 characters (4bytes) */
    insert into tab_size values ('あい')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
    SQL> insert into tab_size values ('aあ'); /* This is 2 characters (3bytes) */
    1 row created.
    SQL> insert into tab_size values ('abあ'); /* This is 3 characters (4bytes) */
    insert into tab_size values ('abあ')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
    SQL> drop table tab_size;
    Table dropped.
    SQL> create table tab_char (col varchar2(3 char));
    Table created.
    SQL> insert into tab_char values ('abc');
    1 row created.
    SQL> insert into tab_char values ('abcd');
    insert into tab_char values ('abcd')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4,
    maximum: 3)
    SQL> insert into tab_char values ('あいう');  /* This is 3 characters (6bytes) */
    1 row created.
    SQL> insert into tab_char values ('あいうえ'); /* This is 4 characters (8bytes) */
    insert into tab_char values ('あいうえ')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4, maximum: 3)
    SQL> insert into tab_char values ('aあい'); /* This is 3 characters (5bytes) */
    1 row created.
    SQL> insert into tab_char values ('abあい'); /* This is 4 characters (6bytes) */
    insert into tab_char values ('abあい')
    ERROR at line 1:
    ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4, maximum: 3)谢谢。
    ありがとう。
    Thank you for reading.

  • Difference between the user_bytes and the bytes of dba_data_files

    What's the difference between the user_bytes and the bytes column of the dba_data_file view?

    Hi,
    >>Bytes : Size Occupied
    No. The size of the datafile. Doesn't matter free or used space.
    >>User Bytes: Size available for Occupying.
    No and Yes. Keep in mind that it shows the total size of the file available for user data since it was creation minus the related metadata information.
    In resume, take a look at below:
    You can see below, that datafile has 1,500 MB of size but it has 1,499.9375 MB available for user data.
    LEGATTI@ORACLE10> select file_id,file_name,bytes,user_bytes from dba_data_files where tablespace_name='USERS2';
       FILE_ID FILE_NAME                                         BYTES USER_BYTES
             7 /u02/oradata/DB01/user02.dbf                 1572864000 1572798464
    LEGATTI@ORACLE10> SELECT Substr(df.tablespace_name,1,20) "Tablespace Name",
      2         Substr(df.file_name,1,40) "File Name",
      3         Round(df.bytes/1024/1024,2) "Size (M)",
      4         df.increment_by "Increment By",
      5         Round(e.used_bytes/1024/1024,2) "Used (M)",
      6         Round(f.free_bytes/1024/1024,2) "Free (M)"
      7  FROM   DBA_DATA_FILES DF,
      8         (SELECT file_id,
      9                 Sum(Decode(bytes,NULL,0,bytes)) used_bytes
    10          FROM dba_extents
    11          GROUP by file_id) E,
    12         (SELECT Max(bytes) free_bytes,
    13                 file_id
    14          FROM dba_free_space
    15          GROUP BY file_id) f
    16  WHERE  e.file_id (+) = df.file_id
    17  AND    df.file_id  = f.file_id (+)
    18  AND    df.file_id = 7
    19  ORDER BY df.tablespace_name,
    20           df.file_name;
    Now, you can see that just 874 MB has been used from 1,499.9375 MB real space available.
    Tablespace Name      File Name                                  Size (M) Increment By   Used (M)   Free (M)
    USERS2               /u02/oradata/DB01/user02.dbf                  1,500            0     874.88     625,05Now, is that clear?
    Cheers
    Legatti

Maybe you are looking for