Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Posts
    127

    Unanswered: integer byte sizes

    Hi,

    can i ask, if specifying a type as an integer, will all integer values embedded within the column associated with this type, be of the same byte size? or are do they equate to 1 byte per actual number character?

    i.e. 1 = 1 byte, 123, 3 bytes & so forth.

    its just that im designing columns to contain boolean-type values, & am [far too obsessed when] concerning physical storage space efficiency.

    thanks in advance

  2. #2
    Join Date
    Mar 2002
    Location
    Reading, UK
    Posts
    1,137
    No you cant unless you define them as varchar2. Also if your worried about space why do you want 3 bytes for 123 when you can fit that in to 7 bits?

    Alan

  3. #3
    Join Date
    Jun 2004
    Posts
    127
    hi alan, yes i know this. my boolean column will be:

    isAbstract NUMBER CHECK (isAbstract IN (0,1))

    as opposed to say

    isAbstract VARCHAR2(3) CHECK (isAbstract IN ('Yes','No'))

    obviously with using numbers opp to varchar2 i do not have to worry with upper/lower casing insertion issues.

    my main Q (which i probably didnt make clear enough) was to find out how many bytes a single (number type defined) number equates to?

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    "CHECK (isAbstract IN ('Yes','No'))" - you know that only 'Yes' and 'No' are valid values? 'yes' and 'no' will be invalid, just like 'YES' and 'NO' and other combinations. Do you really want to keep that in mind? Will you, for example, user something like

    ... WHERE initcap(some_column) = 'Yes' or
    ... WHERE upper(some_column) = upper('Yes') etc.

    Not that this is wrong or impossible, but - perhaps - 0 and 1 are simpler.

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Quote Originally Posted by FAC51
    my main Q (which i probably didnt make clear enough) was to find out how many bytes a single (number type defined) number equates to?
    Use the DUMP function:
    Code:
    SQL> select dump(123), dump(100), dump(1) from dual;
    
    DUMP(123)             DUMP(100)          DUMP(1)
    --------------------- ------------------ ------------------
    Typ=2 Len=3: 194,2,24 Typ=2 Len=2: 194,2 Typ=2 Len=2: 193,2
    See the Concepts Guide for more details of the internal storage of numbers.

  6. #6
    Join Date
    Jun 2004
    Posts
    127
    thanks tony, this is just what im looking for!

Posting Permissions

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