Database Reference
In-Depth Information
The following script is the multiple-table INSERT command, filling all
three tables with the appropriate rows in the three new tables. In this case,
an ELSE clause is not required, and the FIRST option can be used.
INSERT FIRST
WHEN RETAILER_ID = (SELECT RETAILER_ID FROM RETAILER
WHERE NAME = 'Amazon') THEN INTO AMAZON
WHEN RETAILER_ID = (SELECT RETAILER_ID FROM RETAILER
WHERE NAME = 'Barnes and Noble') THEN INTO BANDN
WHEN RETAILER_ID = (SELECT RETAILER_ID FROM RETAILER
WHERE NAME = 'CD Shop') THEN INTO CDSHOP
SELECT * FROM SALES;
Figure 15.11 shows resulting table counts after the execution of the mul-
tiple-table INSERT command, distributing sales entries to the three sepa-
rate retailer tables. The correct row counts can be verified by comparing row
counts between those shown in Figures 15.10 and 15.11.
That covers the INSERT command and adding data. Let's look at other
DML commands, starting with the UPDATE command used to change
existing data.
Figure 15.11
SALES Table
Entries Distributed
into Three Separate
Retailer Tables.
 
Search WWH ::




Custom Search