SQL Final Exam

Test: Final Exam – Database Programming with SQL 1. You are creating the EMPLOYEES table. This table should contain the COMMISSION_PCT column and use a value of 10 percent if no commission value is provided when a record is inserted. Which line should you include in the CREATE TABLE statement to accomplish this task? ♦commission_pct…

Mid Term Exam Sem 2 #2

1. Examine the data from the LINE_ITEM table: LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT 890898 847589 848399 8.99 0.10 768385 862459 849869 5.60 0.05 867950 985490 945809 5.60 954039 439203 438925 5.25 0.15 543949 349302 453235 4.50 You query the LINE_ITEM table and a value of 3 is returned. Which SQL statement did you execute? ♦SELECT…

Mid Term Exam Sem 2 #1

1. You need to return a portion of each employee”s last name, beginning with the first character up to the fifth character. Which character function should you use? ♦INSTR ♦TRUNC ♦SUBSTR (*) ♦CONCAT 2. You query the database with this SQL statement: SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) “ID” FROM employee; In which order are the…

SQL Programming #16

Oracle Database Programming with SQL Section 16 1.         Steven King’s row in the EMPLOYEES table has EMPLOYEE_ID = 100 and SALARY = 24000. A user issues the following statements in the order shown: UPDATE employees SET salary = salary * 2 WHERE employee_id = 100; COMMIT; UPDATE employees SET salary = 30000 WHERE employee_id =…

SQL Programming #15

Oracle Database Programming with SQL Section 15 1.         Regular expressions used as check constraints are another way to ensure data is formatted correctly prior to being written into the database table. True or False? ♦True (*) ♦False 2.         Regular expressions are a method of describing both simple and complex patterns for searching and manipulating. True…

SQL Programming #14

Oracle Database Programming with SQL Section 14 1.         Sequences can be used to: (Choose three) (Choose all correct answers) ♦Generate a range of numbers and optionally cycle through them again (*) ♦Set a fixed interval between successively generated numbers. (*) ♦Ensure primary key values will be unique and consecutive ♦Guarantee that no primary key values…

SQL Programming #13

Oracle Database Programming with SQL Section 13 1.            Evaluate this CREATE VIEW statement: CREATE VIEW emp_view AS SELECT SUM(salary) FROM employees; Which statement is true? ♦You cannot update data in the EMPLOYEES table using the EMP_VIEW view. (*) ♦You can update any data in the EMPLOYEES table using the EMP_VIEW view. ♦You can update only…

SQL Programming #12

Oracle Database Programming with SQL Section 12 1.         Examine the structures of the PRODUCTS and SUPPLIERS tables. PRODUCTS: PRODUCT_ID NUMBER NOT NULL, PRIMARY KEY PRODUCT_NAME VARCHAR2 (25) SUPPLIER_ID NUMBER FOREIGN KEY to SUPPLIER_ID of the SUPPLIER table LIST_PRICE NUMBER (7,2) COST NUMBER (7,2) QTY_IN_STOCK NUMBER QTY_ON_ORDER NUMBER REORDER_LEVEL NUMBER REORDER_QTY NUMBER SUPPLIERS: SUPPLIER_ID NUMBER NOT…

SQL Programming #11

Oracle Database Programming with SQL Section 11 1.         To store time with fractions of seconds, which datatype should be used for a table column? ♦DATE ♦INTERVAL DAY TO SECOND ♦INTERVAL YEAR TO MONTH ♦TIMESTAMP (*) 2.         The ELEMENTS column is defined as: NUMBER(6,4) How many digits to the right of the decimal point are allowed…

SQL Programming #10

Oracle Database Programming with SQL Section 10 1.         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 2.         In developing…

SQL Programming #9

Oracle Database Programming with SQL Section 9 1.         A multiple-row operator expects how many values? ♦One or more (*) ♦Only one ♦Two or more ♦None 2.         The salary column of the f_staffs table contains the following values: 4000 5050 6000 11000 23000 Which of the following statements will return the last_name and first_name…

SQL Programming #8

Oracle Database Programming with SQL Section 8 1.         If you want to include subtotals and grand totals for all columns mentioned in a GROUP BY clause, you should use which of the following extensions to the GROUP BY clause? ♦HAVING ♦ROLLUP ♦CUBE (*) ♦GROUP BY ALL COLUMNS 2.         Examine the following statement: SELECT…