Database Programming with SQL Final Exam

Section 12
(Answer all questions in this section)

1. What keyword in an UPDATE statement speficies the column that you want to change?



WHERE


SET (*)


HAVING


SELECT






2. What would happen if you issued a DELETE statement without a WHERE clause?



No rows would be deleted.


All the rows in the table would be deleted. (*)


Only one row would be deleted.


An error message would be returned.






3. DELETE statements can use correlated subqueries? (True or False)



True (*)


False






4. Evaluate this statement:
DELETE FROM customer;

Which statement is true?





The statement deletes all the rows from the CUSTOMER table. (*)


The statement deletes the CUSTOMER column.


The statement removes the structure of the CUSTOMER table from the database.


The statement deletes the first row in the CUSTOMERS table.






5. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)

You want to add the following row of data to the PRODUCTS table:

(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column

You issue this statement:

INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);

What row data did you add to the table?





The row was created with the  data in all three columns. (*)


The row was created completely wrong. No data ended up in the  columns.


The row was created with the  data in two of three columns.


The row was created with the  data in one of the three columns.




Section 12
(Answer all questions in this section)

6. Which statement about the VALUES clause of an INSERT statement is true?



Character, date, and numeric data must be enclosed within single quotes in the VALUES clause.


If no column list is specified, the values must be listed in the same order that the columns are listed in the table. (*)


The VALUES clause in an INSERT statement is mandatory in a subquery.


To specify a null value in the VALUES clause, use an empty string (" ").






7. Multi-table inserts can be conditional or unconditional. True or False?



True (*)


False






8. A column in a table can be given a default value. This option prevents NULL values from automatically being assigned to the column if a row is inserted without a specified value for the column. True or False ?



True (*)


False








Section 13
(Answer all questions in this section)

9. Which statement about table and column names is true?



If any character other than letters or numbers is used in a table or column name, the name must be enclosed in double quotation marks.


Table and column names must begin with a letter. (*)


Table and column names can begin with a letter or a number.


Table and column names cannot include special characters.






10. Examine this CREATE TABLE statement:
CREATE TABLE emp_load
(employee_number CHAR(5),
employee_dob CHAR(20),
employee_last_name CHAR(20),
employee_first_name CHAR(15),
employee_middle_name CHAR(15),
employee_hire_date DATE)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY def_dir1
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS (employee_number CHAR(2),
      employee_dob CHAR(20),
      employee_last_name CHAR(18),
      employee_first_name CHAR(11),
      employee_middle_name CHAR(11),
      employee_hire_date CHAR(10) date_format DATE mask "mm/dd/yyyy"))
LOCATION ('info.dat'));

What kind of table is created here?





An external table with the data stored in a file outside the database. (*)


A View.


An external table with the data stored in a file inside the database.


None. This is in invalid statement.
Section 13
(Answer all questions in this section)

11. CREATE TABLE student_table
    (id NUMBER(6),
     lname VARCHAR(20),
     fname VARCHAR(20),
     lunch_num NUMBER(4));
Which of the following statements best describes the above SQL statement:





Creates a table named student with four columns: id, lname, fname, lunch_num


Creates a table named student_table with four columns: lname, fname, lunch, num


Creates a table named student_table with four columns: id, lname, fname, lunch_num (*)


Creates a table named student_table with four columns: lname, fname, lunch, num






12. The BLOB datatype can max hold 128 Terabytes of data. True or False?



True (*)


False






13. You are designing a table for the Sales department. You need to include a column that contains each sales total. Which data type should you specify for this column?



VARCHAR2


DATE


CHAR


NUMBER (*)






14. Evaluate this statement:
ALTER TABLE employees SET UNUSED (fax);
Which task will this statement accomplish?





Prevents data in the FAX column from being displayed, by performing a logical drop of the column (*)


Frees the disk space used by the data in the FAX column


Deletes the FAX column


Prevents a new FAX column from being added to the EMPLOYEES table






15. Which of the following will ly change the name of the LOCATIONS table to NEW_LOCATIONS?



ALTER TABLE LOCATIONS RENAME NEW_LOCATIONS


MODIFY TABLE LOCATIONS RENAME NEW_LOCATIONS


RENAME LOCATIONS TO NEW_LOCATIONS (*)


None of the above; you cannot rename a table, you can only CREATE, ALTER and DROP a table.
Section 13
(Answer all questions in this section)

16. You can use DROP COLUMN to drop all columns in a table, leaving a table structure with no columns. True or False?



True


False (*)






17. The data type of a column can never be changed once it has been created. True or False?



True


False (*)






18. The previous administrator created a table named CONTACTS, which contains outdated data. You want to remove the table and its data from the database. Which statement should you issue?



DELETE


TRUNCATE TABLE


DROP TABLE (*)


ALTER TABLE






19. RENAME old_name to new_name can be used to:



Rename a row.


Rename a column.


Rename a table. (*)


All of the above.








Section 14
(Answer all questions in this section)

20. The number of check constraints that can be defined on a column is:



10


5


100


There is no limit (*)




Section 14
(Answer all questions in this section)

21. You need to create the PROJECT_HIST table. The table must meet these requirements:
The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for numeric data.
The table must contain the START_DATE and END_DATE column for date values.
The table must contain the HOURLY_RATE and PROJECT_COST columns for numeric data with precision and scale of 5,2 and 10,2 respectively.
The table must have a composite primary key on the EMPLOYEE_ID and START_DATE columns.
Evaluate this CREATE TABLE statement:

CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));

How many of the requirements does the CREATE TABLE statement satisfy?





None of the four requirements


All four of the requirements (*)


Only three of the requirements


Only two of the requirements






22. All of a user's constraints can be viewed in the Oracle Data Dictionary view called:



USER_CONSTRAINTS (*)


TABLE_CONSTRAINTS


USER_TABLES


CONSTRAINTS






23. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEES table. Which ALTER TABLE statement should you use?



ALTER TABLE employees
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY(emp_id); (*)


ALTER TABLE employees
MODIFY CONSTRAINT PRIMARY KEY (emp_id);


ALTER TABLE employees
ADD CONSTRAINT PRIMARY KEY (emp_id);


ALTER TABLE employees
MODIFY emp_id PRIMARY KEY;






24. You need to add a NOT NULL constraint to the COST column in the PART table. Which statement should you use to complete this task?



ALTER TABLE part
MODIFY (cost CONSTRAINT part_cost_nn NOT NULL);
(*)



ALTER TABLE part
MODIFY (cost part_cost_nn NOT NULL);


ALTER TABLE part
ADD (cost CONSTRAINT part_cost_nn NOT NULL);


ALTER TABLE part
MODIFY COLUMN (cost part_cost_nn NOT NULL);



In In. Refer to Section 14 Lesson 1.


25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
    (customer_id NUMBER,
     customer_name VARCHAR2(25),
     address VARCHAR2(25),
     city VARCHAR2(25),
     region VARCHAR2(25),
     postal_code VARCHAR2(11),
     CONSTRAINT customer_id_un UNIQUE(customer_id),
     CONSTRAINT customer_name_nn NOT NULL(customer_name));

Why does this statement fail when executed?





NOT NULL constraints CANNOT be defined at the table level. (*)


The NUMBER data types require precision values.


The CREATE TABLE statement does NOT define a PRIMARY KEY.


UNIQUE constraints must be defined at the column level.
Section 14
(Answer all questions in this section)

26. A unique key constraint can only be defined on a not null column. True or False?



True


False (*)








Section 15
(Answer all questions in this section)

27. Which keyword(s) would you include in a CREATE VIEW statement to create the view whether or not the base table exists?



OR REPLACE


WITH READ ONLY


FORCE (*)


NOFORCE






28. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
    (SELECT first_name, last_name, status, courseid, subject, term
     FROM faculty f, course c
     WHERE f.facultyid = c.facultyid);

Which type of view will this statement create?





Nested


Simple


Inline


Complex (*)






29. Given the following CREATE VIEW statement, what data will be returned?
CREATE OR REPLACE VIEW emp_dept
AS SELECT SUBSTR(e.first_name,1,1) ||' '||e.last_name emp_name,
    e.salary,
    e.hire_date,
    d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND d.department_id >=50;





First character from employee first_name concatenated to the last_name, the salary, the hire_date, and the department_name of all employees working in department number 50 or higher. (*)


First character from employee first_name concatenated to the last_name, the salary, the hire_date, and department_id of all employees working in department number 50 or higher.


First character from employee first_name concatenated to the last_name, the salary, the hire_date, and department_id of all employees working in department number 50.


First character from employee first_name concatenated to the last_name, the salary, the hire_date, and department_name of all employees working in department number 50.






30. You cannot insert data through a view if the view includes ______.



A GROUP BY clause (*)


A column alias


A WHERE clause


A join

Section 15
(Answer all questions in this section)

31. Only one type of view exists. True or False?



True


False (*)






32. Which of the following is TRUE regarding simple views?



Simple views retrieve data from many tables, so they typically contain joins.


Simple views contain functions or groups of data.


Simple views are not stored in the Data Dictionary.


Simple views can be used to perform DML operations. (*)






33. Which statement about an inline view is true?



An inline view is a schema object.


An inline view is a subquery in the FROM clause, often named with an alias. (*)


An inline view is a complex view.


An inline view can be used to perform DML operations.






34. Which of the following is true about ROWNUM?



It is the number assigned to each row returned from a query after it is ordered.


It is the number assigned to each row returned from a query as it is read from the table. (*)


It is the number of rows in a table.


None of the above








Section 16
(Answer all questions in this section)

35. When used in a CREATE SEQUENCE statement, which keyword specifies that a range of sequence values will be preloaded into memory?



CACHE (*)


NOCACHE


MEMORY


LOAD


NOCYCLE
Section 16
(Answer all questions in this section)

36. Which of the following best describes the function of the CURRVAL virtual column?



The CURRVAL virtual column will display the integer that was most recently supplied by a sequence. (*)


The CURRVAL virtual column will increment a sequence by a specified value.


The CURRVAL virtual column will display either the physical locations or the logical locations of the rows in the table.


The CURRVAL virtual column will return a value of 1 for a parent record in a hierarchical result set.






37. A gap can occur in a sequence because a user generated a number from the sequence and then rolled back the transaction. True or False?



True (*)


False






38. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;

Which task was accomplished by this statement?





You created a private synonym on the EMPLOYEES table that you own.


You created a private synonym on the EMPLOYEES table owned by user Sam. (*)


You created a public synonym on the EMP table owned by user Sam.


You created a public synonym on the EMPLOYEES table owned by user Sam.






39. You must use a synonym to access another users table. True or False?



True


False (*)






40. Which of the following statements best describes indexes and their use?



They are just copies of data in no particular order.


They contain the column value and pointers to the data in the table, but the data is sorted. (*)


They contain all the rows and columns from the table


None of the above
Section 17
(Answer all questions in this section)

41. The database administrator wants to allow user Marco to create new tables in his own schema. Which privilege should be granted to Marco?



SELECT


CREATE OBJECT


CREATE TABLE (*)


CREATE ANY TABLE






42. Which Object Privilege (other than Alter) can be granted to a Sequence?



UPDATE


SELECT (*)


DELETE


INSERT






43. _________________ are special characters that have a special meaning, such as a wildcard character, a repeating character, a non-matching character, or a range of characters. You can use several of these symbols in pattern matching.



Clip Art


Meta characters (*)


Alphanumeric values


Reference checks






44. REGULAR EXPRESSIONS does exactly the same as LIKE--no more and no less. (True or False?)



True


False (*)






45. Which of the following simplifies the administration of privileges?



A view


An index


A trigger


A role (*)
Section 17
(Answer all questions in this section)

46. Which keyword would you use to grant an object privilege to all database users?



ADMIN


PUBLIC (*)


ALL


USERS






47. What Oracle feature simplifies the process of granting and revoking privileges?



Schema


Data dictionary


Role (*)


Object








Section 18
(Answer all questions in this section)

48. When you logout of Oracle, your data changes are automatically rolled back. True or False?



True


False (*)






49. If UserB has privileges to see the data in a table, as soon as UserA has entered data into that table, UserB can see that data. True or False?



True


False (*)








Section 19
(Answer all questions in this section)

50. Unit testing is done prior to a database going into production to ensure a random number of business requirements functions properly. True or False?



True


False (*)

Comments