Oracle's lack of a Bit datatype for table columns

后端 未结 9 1001
醉酒成梦
醉酒成梦 2021-02-05 03:13

Oracle does not support a bit datatype or any other type for true/false scenarios. Does one use the char(1) field instead by using a specific letter to

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 04:09

    Here is an Ask Tom discussion on the topic. Gives an Oracle-centric view on the issue.

    As for storage, char(1) is actually a bit (no pun intended) more efficient:

    SQL> CREATE TABLE xx (c CHAR(1), n NUMBER);
    
    Table created
    
    SQL> insert into xx values('T', 1);
    
    1 row inserted
    
    SQL> select dump(c), dump(n) from xx;
    
    DUMP(C)             DUMP(N)
    ------------------- -------------
    Typ=96 Len=1: 84    Typ=2 Len=2: 193,2
    

提交回复
热议问题