I need a number column to serve as an indicator for something I am working on, but I don't want it to take up more than a single byte per record. If I use NUMBER(1), would this satisfy my requirement?
A NUMBER(1)
column will take up however much space it requires to store a 1 digit number. That is likely to be more than 1 byte (negative numbers will require 3 bytes, a 0 requires 1 byte, the numbers 1-9 require 2 bytes)
SQL> create table foo( col1 number(1) );
Table created.
SQL> insert into foo values( 1 );
1 row created.
SQL> insert into foo values( 9 );
1 row created.
SQL> insert into foo values( -7 );
1 row created.
SQL> select vsize(col1), col1 from foo;
VSIZE(COL1) COL1
----------- ----------
2 1
2 9
3 -7
A table with a VARCHAR2(1 BYTE)
column, on the other hand, will use at most 1 byte per row of storage
SQL> create table bar( col1 varchar2(1) );
Table created.
SQL> insert into bar values( 'Y' );
1 row created.
SQL> insert into bar values( 'N' );
1 row created.
SQL> select vsize(col1), col1 from bar;
VSIZE(COL1) C
----------- -
1 Y
1 N
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With