Oracle CHAR data type1

1.    It is used to store fixed length values.

2.    By default, the size is 1 character, and max size is 2000 chars or bytes.

3.    If you insert a value that is shorter than the column length, then Oracle blank-pads the     value to column length.

4.     If you try to insert a value that is too long for the column, then Oracle returns an error.

5.    A 1-byte string can be inserted into a CHAR(10) column, but the string is
blank-padded to 10 bytes before it is stored.

6.    When you create a table with a CHAR column, by default you supply the column length
in bytes. The BYTE qualifier is the same as the default.

7.    If you use the CHAR qualifier, for example CHAR(10 CHAR), then you supply the column length in characters.

Ex:        id     char(5)
    --------------------
    e0001
    e0002
    e0003

Ex:      FLAG     CHAR
    -----------    ---------
         Y
         N
         Y
         N 

 

CREATE TABLE test (col1 NUMBER(5,2), col2 FLOAT(5));

 

INSERT INTO test VALUES (1.23, 1.23);

INSERT INTO test VALUES (7.89, 7.89);

INSERT INTO test VALUES (12.79, 12.79);

INSERT INTO test VALUES (123.45, 123.45);

 

 

No comments:

Post a Comment