boolean over char(1) 
Author Message
 boolean over char(1)
Is there any advantages of using datatype boolean over char(1)? If there
isn't I think char(1) is more portable across other DBM?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.***.com/



Wed, 22 Jun 2005 03:59:04 GMT
 boolean over char(1)


Quote:
> Is there any advantages of using datatype boolean over char(1)?

boolean fits in 1 byte; char(1) requires 5 bytes (maybe more, depending
on alignment considerations).

boolean will be considerably faster to operate on, being pass-by-value.

char(1) will happily accept values that don't correspond to booleans
(eg, if you use 't' and 'f' to represent booleans in a char(1), what
will you do with 'y' or 'z'?)  You could possibly fix that with a
check constraint, but that slows things down still more.

boolean is, um, boolean: it behaves as expected in boolean expressions.
You can't do AND, OR, NOT directly on chars.

Quote:
> If there isn't I think char(1) is more portable across other DBM?

The boolean datatype is standard in SQL99.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command



Wed, 22 Jun 2005 05:27:31 GMT
 boolean over char(1)

Also, we do support "char", which is one byte.  You need to specify the
quotes when creating the column.

---------------------------------------------------------------------------

Quote:


> > Is there any advantages of using datatype boolean over char(1)?

> boolean fits in 1 byte; char(1) requires 5 bytes (maybe more, depending
> on alignment considerations).

> boolean will be considerably faster to operate on, being pass-by-value.

> char(1) will happily accept values that don't correspond to booleans
> (eg, if you use 't' and 'f' to represent booleans in a char(1), what
> will you do with 'y' or 'z'?)  You could possibly fix that with a
> check constraint, but that slows things down still more.

> boolean is, um, boolean: it behaves as expected in boolean expressions.
> You can't do AND, OR, NOT directly on chars.

> > If there isn't I think char(1) is more portable across other DBM?

> The boolean datatype is standard in SQL99.

>                    regards, tom lane

> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command


--
  Bruce Momjian                        |  http://candle.pha.pa.us

  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Wed, 22 Jun 2005 09:00:27 GMT
 boolean over char(1)

Quote:

> Also, we do support "char", which is one byte.  You need to specify the
> quotes when creating the column.

But he's looking for "more standard", which "char" surely is not.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------



Wed, 22 Jun 2005 09:12:23 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Altering a CHAR(4) column CHAR(5) changing

2. char(9) or char(13) do not work in my query

3. Can't insert char into CHAR column

4. subset_filterclause in sp_addmergearticle allows 2000 chars vs sysmergearticles allows 1000 chars

5. Altering a CHAR(4) column CHAR(5) changing pg_attribute

6. registerIndexTableOutParameter with TABLE OF CHAR(20), corresponding JDBC datatype of Oracle's CHAR

7. Equivalents for CHAR(10) + CHAR(13)?

8. Char(8) to Char(13)

9. CHAR TO NUMBER - NUMBER TO CHAR

10. Searching Char(0) to Char(31) in NVARCHAR column

11. Ordering char. field w/numeric + char data

12. Always 6 chars in char


 
Powered by phpBB® Forum Software