diff --git a/features/boolean.adoc b/features/boolean.adoc index f628b5f..a523f96 100644 --- a/features/boolean.adoc +++ b/features/boolean.adoc @@ -11,6 +11,7 @@ To declare a table column of type `BOOLEAN`, either use the `BOOLEAN` or `BOOL` [source,sql] [subs="verbatim"] ---- +-- Create a new table containing two boolean columns CREATE TABLE email_addresses ( user_id NUMBER NOT NULL, @@ -18,31 +19,52 @@ CREATE TABLE email_addresses active BOOLEAN NOT NULL, primary BOOL NOT NULL ); + +-- Insert values into the table +INSERT INTO email_addresses + (user_id, active, primary, email) + VALUES ( 1, true, true, 'jon.doe@example.com'), + ( 2, true, true, 'jane.smith@gmail.com'), + ( 2, false, false, 'jsmith@gmail.com'), + ( 3, true, true, 'max.well@example.com'), + ( 3, true, false, 'mwell@gmail.com'); + +COMMIT; + +-- Select all email addresses that are active +SELECT email FROM email_addresses + WHERE active; + +-- Select all email addresses that are active but not primary +SELECT email FROM email_addresses + WHERE active AND NOT primary; ---- -.Example +.Result [source,sql] [subs="verbatim"] ---- +SQL> -- Create a new table containing two boolean columns SQL> CREATE TABLE email_addresses - 2 ( - 3 user_id NUMBER NOT NULL, - 4 email VARCHAR2(255) NOT NULL, - 5 active BOOLEAN NOT NULL, - 6 primary BOOL NOT NULL - 7 ); +( + user_id NUMBER NOT NULL, + email VARCHAR2(255) NOT NULL, + active BOOLEAN NOT NULL, + primary BOOL NOT NULL +); -Table EMAIL_ADDRESSES created. +Table created. +SQL> -- Insert values into the table SQL> INSERT INTO email_addresses - 2 (user_id, active, primary, email) - 3 VALUES ( 1, true, true, 'jon.doe@example.com'), - 4 ( 2, true, true, 'jane.smith@gmail.com'), - 5 ( 2, false, false, 'jsmith@gmail.com'), - 6 ( 3, true, true, 'max.well@example.com'), - 7 ( 3, true, false, 'mwell@gmail.com'); + (user_id, active, primary, email) + VALUES ( 1, true, true, 'jon.doe@example.com'), + ( 2, true, true, 'jane.smith@gmail.com'), + ( 2, false, false, 'jsmith@gmail.com'), + ( 3, true, true, 'max.well@example.com'), + ( 3, true, false, 'mwell@gmail.com'); -5 rows inserted. +5 rows created. SQL> COMMIT; @@ -50,24 +72,22 @@ Commit complete. SQL> -- Select all email addresses that are active SQL> SELECT email FROM email_addresses - 2 WHERE active; + WHERE active; EMAIL --------------------- +-------------------------------------------------------------------------------- jon.doe@example.com jane.smith@gmail.com max.well@example.com mwell@gmail.com -SQL> -- Select all email addresses that are active and primary +SQL> -- Select all email addresses that are active but not primary SQL> SELECT email FROM email_addresses - 2 WHERE active AND primary; + WHERE active AND NOT primary; EMAIL --------------------- -jon.doe@example.com -jane.smith@gmail.com -max.well@example.com +-------------------------------------------------------------------------------- +mwell@gmail.com ---- == Benefits @@ -77,6 +97,6 @@ The `BOOLEAN` data type standardizes the storage of "Yes" and "No" values. == Further information * Introduced: xref:versions:{database-version}/index.adoc[] -* Availability: all editions +* Availability: All Offerings * link:https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html[Documentation] * link:https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html[Example] diff --git a/features/feature.adoctemplate b/features/feature.adoctemplate index 5bcf34b..f31e22f 100644 --- a/features/feature.adoctemplate +++ b/features/feature.adoctemplate @@ -25,6 +25,6 @@ Replace this text with the benefits the feature provides == Further information * Introduced: xref:versions:{database-version}/index.adoc[] -* Availability: ###Oracle Database feature edition availability, use "all editions" if it is not factored### +* Availability: ###Oracle Database feature edition availability, use "All Offerings" if it is not factored### * link:###URL Link to the Doc###[Documentation] * link:###URL Link to an example###[Example] diff --git a/features/identity-columns.adoc b/features/identity-columns.adoc index eeb823e..6fbdb7d 100644 --- a/features/identity-columns.adoc +++ b/features/identity-columns.adoc @@ -13,6 +13,7 @@ To declare a column as an identity in a table, use the `GENERATED AS IDENTITY` c [source,sql] [subs="verbatim"] ---- +-- Create a table with the column "ID" generated as Identity column CREATE TABLE employees ( id NUMBER GENERATED AS IDENTITY NOT NULL PRIMARY KEY, @@ -20,6 +21,22 @@ CREATE TABLE employees last_name VARCHAR2(10) NOT NULL, job_title VARCHAR2(20) NOT NULL ); + +-- Note the absence of the "ID" column in the INSERT statement. +-- Although it is a primary key and NOT NULL, the inserts succeed. +INSERT INTO employees (first_name, last_name, job_title) + VALUES ('Gerald', 'Venzl', 'Developer'); + +INSERT INTO employees (first_name, last_name, job_title) + VALUES ('Andres', 'Almiray', 'Developer'); + +INSERT INTO employees (first_name, last_name, job_title) + VALUES ('Chris', 'Saxon', 'Developer Evangelist'); + +COMMIT; + +-- The SELECT statement will show the "ID" column with values filled by the generated identity values. +SELECT * FROM employees; ---- The identity column provides additional syntax modifiers to: @@ -33,6 +50,7 @@ The identity column provides additional syntax modifiers to: [source,sql] [subs="verbatim"] ---- +SQL> -- Create a table with the column "ID" generated as Identity column SQL> CREATE TABLE employees 2 ( 3 id NUMBER GENERATED AS IDENTITY NOT NULL PRIMARY KEY, @@ -43,18 +61,21 @@ SQL> CREATE TABLE employees Table EMPLOYEES created. +SQL> -- Note the absence of the "ID" column in the INSERT statement. +SQL> -- Although it is a primary key and NOT NULL, the inserts succeed. + SQL> INSERT INTO employees (first_name, last_name, job_title) - 2 VALUES ('Gerald', 'Venzl', 'Developer'); + VALUES ('Gerald', 'Venzl', 'Developer'); 1 row inserted. SQL> INSERT INTO employees (first_name, last_name, job_title) - 2 VALUES ('Andres', 'Almiray', 'Developer'); + VALUES ('Andres', 'Almiray', 'Developer'); 1 row inserted. SQL> INSERT INTO employees (first_name, last_name, job_title) - 2 VALUES ('Chris', 'Saxon', 'Developer Evangelist'); + VALUES ('Chris', 'Saxon', 'Developer Evangelist'); 1 row inserted. @@ -62,6 +83,7 @@ SQL> COMMIT; Commit complete. +SQL> -- The SELECT statement will show the "ID" column with values filled by the generated identity values. SQL> SELECT * FROM employees; ID FIRST_NAME LAST_NAME JOB_TITLE @@ -82,6 +104,6 @@ Identity columns ensure that the value for a new row will always be unique by us == Further information * Introduced: xref:versions:{database-version}/index.adoc[] -* Availability: all editions +* Availability: All Offerings * link:https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CREATE-TABLE.html#GUID-F9CE0CC3-13AE-4744-A43C-EAC7A71AAAB6__CJAECCFH[Documentation - CREATE TABLE identity_clause] * link:https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CREATE-TABLE.html#GUID-F9CE0CC3-13AE-4744-A43C-EAC7A71AAAB6__CJAHCAFF[Example] diff --git a/features/plsql-function-in-sql.adoc b/features/plsql-function-in-sql.adoc index 6534a40..7a50de1 100644 --- a/features/plsql-function-in-sql.adoc +++ b/features/plsql-function-in-sql.adoc @@ -95,6 +95,6 @@ but the user does either not have the necessary privileges to create a named fun == Further information * Introduced: xref:versions:{database-version}/index.adoc[] -* Availability: all editions +* Availability: All Offerings * link:https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6__BABFAFID[Documentation] * link:https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6__BABJFIDC[Example]