-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters