Skip to content

Commit

Permalink
Update Listing 1.7 and 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
bclothier committed Jun 7, 2016
1 parent 6c8214e commit f69725c
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 14 deletions.
15 changes: 15 additions & 0 deletions IBM DB2/Chapter 01/Listing 1.008.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- This table already exists in the Sales Orders sample database.
-- You can create the Sales Orders sample database by executing
-- SalesOrdersStructure.sql and SalesOrdersData.sql in the Sample Databases folder.
-- If you attempt to run this listing, you will get an error.

SET SCHEMA SalesOrdersSample;

CREATE TABLE Order_Details (
OrderNumber int NOT NULL ,
ProductNumber int NOT NULL ,
QuotedPrice decimal(15,2) NULL DEFAULT 0 ,
QuantityOrdered smallint NULL DEFAULT 0 ,
ExtendedPrice decimal(15,2)
GENERATED ALWAYS AS (QuotedPrice * QuantityOrdered)
);
3 changes: 1 addition & 2 deletions IBM DB2/Chapter 01/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ This folder contains samples and scripts for chapter 1.

The following listings are NOT included:

1-006 -- NOT included - specific to SQL Server
1-008 -- NOT included - specific to Oracle
1-006 -- NOT included - specific to SQL Server
Binary file modified Listings.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions Microsoft Access/Chapter 01/README
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This folder contains samples and scripts for chapter 1.
Listing 1-004a (Drop table)
1-005 -- Contained as query Listing 1-005 in the SalesOrdersSample.accdb file (in the Sample Databases folder)
1-006 -- NOT included - specific to SQL Server
1-007 -- NOT included - specific to DB2
1-008 -- NOT included - specific to Oracle
1-007 -- NOT included - indexing on calculated column is not supported
1-008 -- NOT included - indexing on calculated column is not supported
1-009 -- Contained as query Listing 1-009 in the SalesOrdersSample.accdb file (in the Sample Databases folder)
1-010 -- Contained as queries in the SalesOrdersSample.accdb file (in the Sample Databases folder)
Listing 1-010a (Create Orders table)
Expand Down
17 changes: 17 additions & 0 deletions Microsoft SQL Server/Chapter 01/Listing 1.008.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- This table already exists in the Sales Orders sample database.
-- You can create the Sales Orders sample database by executing
-- SalesOrdersStructure.sql and SalesOrdersData.sql in the Sample Databases folder.
-- If you attempt to run this listing, you will get an error.

USE SalesOrdersSample;

GO

CREATE TABLE Order_Details (
OrderNumber int NOT NULL ,
ProductNumber int NOT NULL ,
QuotedPrice decimal(15,2) DEFAULT 0 NULL ,
QuantityOrdered smallint DEFAULT 0 NULL ,
ExtendedPrice
AS (QuotedPrice * QuantityOrdered)
);
4 changes: 0 additions & 4 deletions Microsoft SQL Server/Chapter 01/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
This folder contains samples and scripts for chapter 1.

The following listings are NOT included:

1-007 -- NOT included - specific to DB2 & MySQL
1-008 -- NOT included - specific to Oracle
15 changes: 15 additions & 0 deletions MySQL/Chapter 01/Listing 1.008.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- This table already exists in the Sales Orders sample database.
-- You can create the Sales Orders sample database by executing
-- SalesOrdersStructure.sql and SalesOrdersData.sql in the Sample Databases folder.
-- If you attempt to run this listing, you will get an error.

USE SalesOrdersSample;

CREATE TABLE Order_Details (
OrderNumber int NOT NULL ,
ProductNumber int NOT NULL ,
QuotedPrice decimal(15,2) DEFAULT 0 NULL ,
QuantityOrdered smallint DEFAULT 0 NULL ,
ExtendedPrice decimal(15,2)
GENERATED ALWAYS AS (QuotedPrice * QuantityOrdered)
);
3 changes: 1 addition & 2 deletions MySQL/Chapter 01/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ This folder contains samples and scripts for chapter 1.

The following listings are NOT included:

1-006 -- NOT included - specific to SQL Server
1-008 -- NOT included - specific to Oracle
1-006 -- NOT included - specific to SQL Server
17 changes: 17 additions & 0 deletions Oracle/Chapter 01/Listing 1.007.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Ensure you've run SalesOrdersStructure.sql
-- and SalesOrdersData.sql in the Sample Databases folder
-- in order to run this example.

ALTER SESSION SET CURRENT_SCHEMA = SalesOrdersSample;

-- Create the calculated column using an expression
ALTER TABLE Order_Details
ADD ExtendedPrice decimal (15, 2)
GENERATED ALWAYS AS (QuantityOrdered * QuotedPrice);

-- Index the calculated column
CREATE INDEX Order_Details_ExtendedPrice
ON Order_Details (ExtendedPrice);

-- Now clean it up
ALTER TABLE Order_Details DROP COLUMN ExtendedPrice;
3 changes: 1 addition & 2 deletions Oracle/Chapter 01/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ The folder contains samples and scripts for chapter 1.

The following listings are NOT included:

1.006 -- Specific to SQL Server
1.007 -- Specific to DB2 & MySQL
1.006 -- Specific to SQL Server
4 changes: 2 additions & 2 deletions PostgreSQL/Chapter 01/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ The folder contains samples and scripts for chapter 1.
The following listings are NOT included:

1.006 -- Specific to SQL Server
1.007 -- Specific to DB2 & MySQL
1.008 -- Specific to Oracle
1.007 -- Calculated column not supported
1.008 -- Calculated column not supported

0 comments on commit f69725c

Please sign in to comment.