This page is part of the book SQL-99 Complete, Really, by Peter Gulutzan & Trudy Pelzer. The authors have graciously allowed us to reproduce the contents of the book here. Because the book is about the SQL-99 standard, the contents of this and other pages in the book may not directly apply to MariaDB. Use the navigation bar to navigate the book.

A Boolean <data type> is defined by a descriptor that contains one piece of information: The <data type>'s name: BOOLEAN.


The required syntax for a BOOLEAN <data type> specification is:

BOOLEAN <data type> ::=

BOOLEAN defines a set of truth values: either TRUE, FALSE or UNKNOWN (as the null value).

The SQL Standard doesn't differentiate between BOOLEAN's null value (that is, UNKNOWN) and the UNKNOWN truth value that is returned by an SQL predicate, search condition or by any argument or expression that returns a Boolean value it allows both to be used interchangeably to mean the same thing. Warning: by saying that UNKNOWN and NULL are the same thing, one is saying that the answers "I don't know" and "I know that the data is missing" are the same thing. The drafters of the SQL Standard apparently forgot the distinction, and they have been justly criticized for this error.

If you want to restrict your code to Core SQL, don't define any BOOLEAN <data type>s.

Now that we've described SQL's Boolean <data type>, let's look at some example SQL statements that put it to use.

These SQL statements make a Table with three Boolean Columns, insert a row, then search for a pair of equal Column values.

  boolean_1 BOOLEAN,
  boolean_2 BOOLEAN,
  boolean_3 BOOLEAN);

INSERT INTO Logicals (

SELECT boolean_1
FROM   Logicals
WHERE  boolean_1 = boolean_3;


Comments loading...