populate a table using the result
set of a SELECT statement. The SELECT statement can be summarized as follows:
SELECT
FROM
WHERE
Figure 1-1. The parts distributor model
SALESPERSON
SALESPERSON_ID: NUMBERS(5)
NAME: VARCHAR2(50)
PRIMARY_REGION_ID: NUMBER(5)MONTHS
YEAR: NUMBER(4)
MONTH: NUMBER(2)
ORDERS
YEAR: NUMBER(4)
MONTH: NUMBER(2)
CUST_NBR: NUMBER(5)
REGION_ID: NUMBER(5)
SALESPERSON_ID: NUMBERS(5)
TOT_ORDERS: NUMBER(7)
TOT_SALES: NUMBER(11,2)REGION
REGION_ID: NUMBER(5)
NAME: VARCHAR2(50)
SUPER_REGION_ID: NUMBER(5)
CUSTOMER
CUST_NBR: NUMBER(5)
NAME: VARCHAR2(30)
REGION_ID: NUMBER(5)
INACTIVE_DT: DATE
INACTIVE_IND: CHAR(1)
TOT_ORDERS: NUMBER(5)
LAST_ORDER_DT: DATECUST_ORDER
ORDER_NBR: NUMBER(5)
CUST_NBR: NUMBER(5)
SALES_EMP_ID: NUMBER(5)
SALE_PRICE: NUMBER(9,2)
ORDER_DT: DATE
EXPECTED_SHIP_DT: DATE
CANCELLED_DATE: DATE
SHIP_DT: DATE
STATUS: VARCHAR(20)EMPLOYEE
EMP_ID: NUMBER(5)
FNAME: VARCHAR2(20)
LNAME: VARCHAR(20)
DEPT_ID: NUMBER(5)
SALARY: NUMBER(5)
HIRE_DATE: DATE
JOB_ID: : NUMBER(3)
MANAGER_EMP_ID: NUMBER(5)
PART
PART_NBR: VARCHAR2(20)
NAME: VARCHAR(30)
SUPPLIER_ID: NUMBER(5)
STATUS: VARCHAR2(10)
INVENTORY_QTY: NUMBER(5)
UNIT_COST: : NUMBER(8,2)
RESUPPLY_DATE: DATELINE_ITEM
ORDER_NBR: NUMBER(5)
PART_NBR: NUMBER2(20)
QTY: NUMBER(5)
FILLED_QTY: NUMBER(5)DEPARTMENT
Dept_ID: NUMBER(5)
NAME: VARCHAR2(20)
LOCATION_ID: NUMBER(3)
SUPPLIER
SUPPLIER_ID: NUMBER(5)
NAME: VARCHAR2(30)INVENTORY_CLASS
INV_CLASS: VARCHAR2(3)
LOW_COST: NUMBER(8,2)
HIGH_COST: NUMBER(8,2)LOCATION
LOCATION_ID: NUMBER(5)
REGIONAL_GROUP: VARCHAR2(20) JOB
JOB_ID: NUMBER(3)
FUNCTION: VARCHAR2(20)
Order warehouse
,ch01.8459 Page 5 Wednesday, March 27, 2002 2:18 PM
This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved. 6|
Chapter 1: Introduction to SQL
While the SELECT and FROM clauses are required, the WHERE clause is optional
(although you will seldom see it omitted).We therefore begin with a simple example
that retrieves three columns from every row of the customer table:
SELECT cust_nbr, name, region_id
FROM customer;
CUST_NBR NAME REGION_ID
---------- ------------------------------ ----------
1 Cooper Industries 5
2 Emblazon Corp. 5
3 Ditech Corp. 5
4 Flowtech Inc. 5
5 Gentech Industries 5
6 Spartan Industries 6
7 Wallace Labs 6
8 Zantech Inc. 6
9 Cardinal Technologies 6
10 Flowrite Corp. 6
11 Glaven Technologies 7
12 Johnson Labs 7
13 Kimball Corp. 7
14 Madden Industries 7
15 Turntech Inc. 7
16 Paulson Labs 8
17 Evans Supply Corp.
![](qr/37161/6.png)
Continue reading on your phone by scaning this QR Code
Tip: The current page has been bookmarked automatically. If you wish to continue reading later, just open the
Dertz Homepage, and click on the 'continue reading' link at the bottom of the page.