Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2008
    Posts
    53

    Unanswered: is 'bool' in oracle ?

    I need to create table with column with values: true/false. Is 'bool' in Oracle because I can't find ?

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    No, Oracle doesn't support a Boolean datatype for columns. A common work-around is VARCHAR2(1) with a constraint to permit only 'Y' and 'N'' as values.

  3. #3
    Join Date
    Dec 2008
    Posts
    53
    thx very much

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    why VARCHAR2(1)?

    if the constraint requires 'Y' or 'N', do you seriously expect it to be a varying length column?

    why not just CHAR(1)?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Quote Originally Posted by r937 View Post
    why VARCHAR2(1)?

    if the constraint requires 'Y' or 'N', do you seriously expect it to be a varying length column?

    why not just CHAR(1)?
    It just happens that in Oracle, a VARCHAR2(1) and a CHAR(1) are identical in storage, performance and behaviour, unlike VARCHAR2(n) and CHAR(n) for any n > 1. Therefore, normal practice is to use VARCHAR2 for all n rather than change to CHAR when n = 1 just because you can. I never use CHAR at all.

  6. #6
    Join Date
    Aug 2009
    Posts
    262
    There is a very meaningful discussion at AskTom regarding boolean datatype and implementation of varchar2(1) .. and its usage .
    Ask Tom "Boolean Datatype"


    Kindly look onto it

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Ah yes, I remember that discussion - I even participated in (good grief) November 2002!

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that's gotta be the longest discussion about the shortest subject evar

    i have to be honest, i did not read it all

    did they ever reach a conclusion?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Do these discussion ever reach conclusions?

  10. #10
    Join Date
    Aug 2009
    Posts
    262
    it never ends

Posting Permissions

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