@@ -11,63 +11,83 @@ To declare a table column of type `BOOLEAN`, either use the `BOOLEAN` or `BOOL`
1111[source,sql]
1212[subs="verbatim"]
1313----
14+ -- Create a new table containing two boolean columns
1415CREATE TABLE email_addresses
1516(
1617 user_id NUMBER NOT NULL,
1718 email VARCHAR2(255) NOT NULL,
1819 active BOOLEAN NOT NULL,
1920 primary BOOL NOT NULL
2021);
22+
23+ -- Insert values into the table
24+ INSERT INTO email_addresses
25+ (user_id, active, primary, email)
26+ VALUES ( 1, true, true, 'jon.doe@example.com'),
27+ ( 2, true, true, 'jane.smith@gmail.com'),
28+ ( 2, false, false, 'jsmith@gmail.com'),
29+ ( 3, true, true, 'max.well@example.com'),
30+ ( 3, true, false, 'mwell@gmail.com');
31+
32+ COMMIT;
33+
34+ -- Select all email addresses that are active
35+ SELECT email FROM email_addresses
36+ WHERE active;
37+
38+ -- Select all email addresses that are active but not primary
39+ SELECT email FROM email_addresses
40+ WHERE active AND NOT primary;
2141----
2242
23- .Example
43+ .Result
2444[source,sql]
2545[subs="verbatim"]
2646----
47+ SQL> -- Create a new table containing two boolean columns
2748SQL> CREATE TABLE email_addresses
28- 2 (
29- 3 user_id NUMBER NOT NULL,
30- 4 email VARCHAR2(255) NOT NULL,
31- 5 active BOOLEAN NOT NULL,
32- 6 primary BOOL NOT NULL
33- 7 );
49+ (
50+ user_id NUMBER NOT NULL,
51+ email VARCHAR2(255) NOT NULL,
52+ active BOOLEAN NOT NULL,
53+ primary BOOL NOT NULL
54+ );
3455
35- Table EMAIL_ADDRESSES created.
56+ Table created.
3657
58+ SQL> -- Insert values into the table
3759SQL> INSERT INTO email_addresses
38- 2 (user_id, active, primary, email)
39- 3 VALUES ( 1, true, true, 'jon.doe@example.com'),
40- 4 ( 2, true, true, 'jane.smith@gmail.com'),
41- 5 ( 2, false, false, 'jsmith@gmail.com'),
42- 6 ( 3, true, true, 'max.well@example.com'),
43- 7 ( 3, true, false, 'mwell@gmail.com');
60+ (user_id, active, primary, email)
61+ VALUES ( 1, true, true, 'jon.doe@example.com'),
62+ ( 2, true, true, 'jane.smith@gmail.com'),
63+ ( 2, false, false, 'jsmith@gmail.com'),
64+ ( 3, true, true, 'max.well@example.com'),
65+ ( 3, true, false, 'mwell@gmail.com');
4466
45- 5 rows inserted .
67+ 5 rows created .
4668
4769SQL> COMMIT;
4870
4971Commit complete.
5072
5173SQL> -- Select all email addresses that are active
5274SQL> SELECT email FROM email_addresses
53- 2 WHERE active;
75+ WHERE active;
5476
5577EMAIL
56- --------------------
78+ --------------------------------------------------------------------------------
5779jon.doe@example.com
5880jane.smith@gmail.com
5981max.well@example.com
6082mwell@gmail.com
6183
62- SQL> -- Select all email addresses that are active and primary
84+ SQL> -- Select all email addresses that are active but not primary
6385SQL> SELECT email FROM email_addresses
64- 2 WHERE active AND primary;
86+ WHERE active AND NOT primary;
6587
6688EMAIL
67- --------------------
68- jon.doe@example.com
69- jane.smith@gmail.com
70- max.well@example.com
89+ --------------------------------------------------------------------------------
90+ mwell@gmail.com
7191----
7292
7393== Benefits
@@ -77,6 +97,6 @@ The `BOOLEAN` data type standardizes the storage of "Yes" and "No" values.
7797== Further information
7898
7999* Introduced: xref:versions:{database-version}/index.adoc[]
80- * Availability: all editions
100+ * Availability: All Offerings
81101* link:https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html[Documentation]
82102* link:https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html[Example]
0 commit comments