1: | Is the syntax correct for the following compound queries? If not, what would correct the syntax? Use the EMPLOYEE_TBL and the EMPLOYEE_PAY_TBL shown as follows:
CONSTRAINT EMP_PK PRIMARY KEY (EMP_ID)
CONSTRAINT EMP_FK FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE_TBL (EMP_ID)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2: | Match the correct operator to the following statements.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A2: |
|
Using the CUSTOMER_TBL and the ORDERS_TBL as listed:
CUSTOMER_TBL | |||
---|---|---|---|
CUST_IN | VARCHAR2(10) | NOT NULL | PRIMARY KEY |
CUST_NAME | VARCHAR2(30) | NOT NULL | |
CUST_ADDRESS | VARCHAR2(20) | NOT NULL | |
CUST_CITY | VARCHAR2(15) | NOT NULL | |
CUST_STATE | CHAR(2) | NOT NULL | |
CUST_ZIP | NUMBER(5) | NOT NULL | |
CUST_PHONE | NUMBER(10) | ||
CUST_FAX | NUMBER(10) |
ORDERS_TBL | |||
---|---|---|---|
ORD_NUM | VARCHAR2(10) | NOT NULL | PRIMARY KEY |
CUST_ID | VARCHAR2(10) | NOT NULL | |
PROD_ID | VARCHAR2(10) | NOT NULL | |
QTY | NUMBER(6) | NOT NULL | |
ORD_DATE | DATE |
1: | Write a compound query to find the customers that have placed an order. |
A1: | SELECT CUST_ID FROM CUSTOMER_TBL INTERSECT SELECT CUST_ID FROM ORDERS_TBL; |
2: | Write a compound query to find the customers that have not placed an order. |
A2: | SELECT CUST_ID FROM CUSTOMER_TBL EXCEPT SELECT CUST_ID FROM ORDERS_TBL; |