Examine The Structure of The EMP - DEPT - VU View
Examine The Structure of The EMP - DEPT - VU View
Examine The Structure of The EMP - DEPT - VU View
2. with 9i SQL Plus, What kinds of commands can you enters at the command prompt (Choose all that apply)?
A. PL/SQL blocks
B. SQL*Plus commands
C. security commands
D. SQL commands
4 .The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) ENAME VARCHAR2 (25) JOB_ID
VARCHAR2(10) Which SQL statement will return the ENAME, length of the ENAME, and the numeric position of the letter
"a" in the ENAME column, for those employees whose ENAME ends with a the letter "n"?
A. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) = 'n';
B. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, ,-1,1) FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) =
'n';
C. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, 1, 1) = 'n';
D. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, -1, 1) = 'n';
6. Which statement adds a constraint that ensures the CUSTOMER_NAME column of the CUSTOMERS table holds a
value?
A. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name IS NOT NULL;
B. ALTER TABLE customers MODIFY CONSTRAINT cust_name_nn CHECK customer_name IS NOT NULL;
C. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn NOT NULL;
D. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn IS NOT NULL;
E. ALTER TABLE customers MODIFY name CONSTRAINT cust_name_nn NOT NULL;
F. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name NOT NULL;
A. DELETE employees;
B. DESCRIBE employees;
C. ROLLBACK TO SAVEPOINT C;
D. GRANT SELECT ON employees TO SCOTT;
E. ALTER TABLE employees SET UNUSED COLUMN sal;
F. SELECT MAX(sal) FROM employees WHERE department_id = 20;
9 Administration
You want to retrieve all employees, whether or not they have matching departments in the departments table. Which query
would you use?
11 Mark for review. Which two statements are true about constraints? (Choose two.)
A. The UNIQUE constraint does not permit a null value for the column.
B. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
C. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.
D. The NOT NULL constraint ensures that null values are not permitted for the column.
12 . Mark for review. Which four are types of functions available in SQL? (Choose 4)
A. string
B. character
C. integer
D. calendar
E. numeric
F. translation
G. date
H. conversion
13. Click the Exhibit button and examine the data in the EMPLOYEES and DEPARTMENTS tables.
EMPLOYEES
EMP_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 IT_ADMIN 5000
106 Smith 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EX_DIR 8000
120 Ravi 20 110 SI_DIR 6500
DEPARTMENTS
Also examine the SQL statements that create the EMPLOYEES and DEPARTMENTS tables:
CREATE TABLE departments (department_id NUMBER PRIMARY KEY, department_name VARCHAR2 (30));
CREATE TABLE employees (EMPLOEE_ID NUMBER PRIMARY KEY, EMP_NAME VARCHAR2 (20), DEPT_ID NUMBER
REFERENCES departments (department_id) MGR_ID NUMBER REFERENCES employees (employee id), JOB_ID VARCHAR2
(15). SALARY NUMBER);
On the EMPLOYEES table, EMPLOYEE_ID is the primary key MGR_ID is the ID of mangers and refers to the EMPLOYEE_ID
DEPT_ID is foreign key to DEPARTMENT_ID column of the DEPARTMENTS table
On the DEPARTMENTS table, DEPARTMENT_ID is the primary key. Examine this DELETE statement: DELETE FROM
departments WHERE department id=40;
What happens when you execute the DELETE statement?
Answer: B, E
A. ALTER TABLE student_grades ADD FOREIGN KEY (student_id) REFERENCES students (student_id);
B. ALTER TABLE student_grades ADD CONSTRAINT NAME=student_id_fk FOREIGN KEY (student_id) REFERENCES
student(student_id);
C. ALTER TABLE student_grades ADD CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students
(student_id);
D. ALTER TABLE student grades ADD NAMED CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES
students (student_id)
E. ALTER TABLE student grades ADD NAME student_id_fk FOREIGN KEY (student_id) REFERENCES students
(student_id)
17 You need to produce a report for mailing labels for all customers. The mailing label must have only the customer name
and address. The CUSTOMER table has these columns:
CUST_ID NUMBER (4) NOT NULL
CUST_NAME VARCHAR2 (100) NOT NULL
CUST_ADDRESS VARCHAR2 (150)
CUST_PHONE VARCHAR (20)
A. SELECT customer_id, order_id, order_total FROM orders RANGE ON order_total (100 AND 2000) INCLUSIVE
B. SELECT customer_id, order_id, order_total FROM orders HAVING order total BETWEEN 100 and 2000
C. SELECT customer_id, order_id, order_total FROM orders WHERE order_total BETWEEN 100 and 2000
D. SELECT customer_id, order_id, order_total FROM orders WHERE order_total >= 100 and <=2000
E. SELECT customer_id, order_id, order _total FROM orders WHERE order_total>= 100 and order_total <=2000.
20 You need to calculate the total of all salaries in the accounting department. Which group function should you use?
A. A. MAX
B. B. MIN
C. C. SUM
D. D. COUNT
E. E. TOTAL
F. F. LARGEST
Evaluate this DELETE statement: DELETE employee_id, salary, job_id FROM employees WHERE dept_id = 90; Why does
the DELETE statement fail when you execute it?
THE CUSTOMER_ID column is the primary key for the table which two statements find the number of customer? (Choose
two.)
28. Mark for review. Which constraint can be defined only at the column level?
A. UNIQUE
B. NOT NULL
C. CHECK
D. PRIMARY KEY
E. FOREIGN KEY
29. You need to change the definition of an existing table. The COMMERCIALS table needs its DESCRIPTION column
changed to hold varying length characters up to 2000 bytes. The column can currently hold 1000 bytes per value. The table
contains 20000 rows. Which statement is valid?
A. ALTER TABLE commercials MODIFY (description CHAR2(2000));
B. B. ALTER TABLE commercials CHANGE (description CHAR2(2000));
C. C. ALTER TABLE commercials CHANGE (description VARCHAR2(2000));
D. D. ALTER TABLE commercials MODIFY (description VARCHAR2(2000));
E. E. You cannot increase the size of a column if the table has rows.
31Which of the following lines in the PL/SQL source code will return an error?
c. select status into statchar from EMP where EMPID = eid; end;
A.
-00000 and -99999
B.
-01200 and -01299
C.
-00030 and -00039
D.
-20000 and -20999
Answer: d
33.In which areas of the PL/SQL block must code be placed in order to handle Oracle-
defined exceptions?