BOOLEAN टाइप
boolean true, false, या unknown (NULL) store करता है।
In this page:
Syntax
column_name boolean DEFAULT false
WHERE column_name IS TRUE
BOOLEAN
PostgreSQL boolean input की तरह TRUE, FALSE, t, f, yes, no, on, off, 1, और 0 accept करता है और psql में t और f display करता है। Conditions सीधे WHERE में इस्तेमाल हो सकती हैं, और IS TRUE, IS FALSE, और IS NOT DISTINCT FROM NULL को safely handle करते हैं।
Booleans AND, OR, और NOT से combine होते हैं।
Note:
एक boolean column true, false, या NULL हो सकता है, इसलिए decide करें कि NULL allowed है या नहीं।
उदाहरण: BOOLEAN
shop=# CREATE TABLE tasks (id serial PRIMARY KEY, title text, done boolean DEFAULT false);
shop=# INSERT INTO tasks (title, done) VALUES ('write', true), ('test', false), ('ship', NULL);
shop=# SELECT title, done FROM tasks;
title | done
-------+------
write | t
test | f
ship |
shop=# SELECT title FROM tasks WHERE done;
title
-------
write
shop=# SELECT title FROM tasks WHERE done IS NOT TRUE;
title
-------
test
ship
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- yes/no को text की तरह store करना
- यह भूल जाना कि NULL एक third state है
- column को सीधे इस्तेमाल करने की बजाय = TRUE से compare करना
चैप्टर सारांश
- Values true, false, और NULL
- कई input spellings accepted हैं
- IS TRUE और IS NOT DISTINCT FROM इस्तेमाल करें
- WHERE में column सीधे इस्तेमाल करें
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: