Q: 51 Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) HIRE_DATE DATE NEW_EMPLOYEES EMPLOYEE_ID NUMBER Primary Key NAME VARCHAR2(60) Which UPDATE statement is valid? A. UPDATE new_employees SET name = (SELECT last_name|| first_name FROM employees WHERE employee_id =180) WHERE employee_id =180; B. UPDATE new_employees SET name = (SELECT last_name||first_name FROM employees ) WHERE employee_id =180; C. UPDATE new_employees SET name = (SELECT last_name ||first_name FROM employees WHERE employee_id =180) WHERE employee_id =(SELECT employee_id FROM new_employees); D. UPDATE new_employees SET name = (SELECT last_name|| first_name FROM employees WHERE employee_id = (SELECT employee_id FROM new_employees)) WHERE employee_id =180; 答案:A 解析:=值表达式,右边如果是子查询,只能返回单值。Q: 52 Which two statements about subqueries are true? (Choose two.)
A. A subquery should retrieve only one row. B. A subquery can retrieve zero or more rows. C. A subquery can be used only in SQL query statements. D. Subqueries CANNOT be nested by more than two levels. E. A subquery CANNOT be used in an SQL query statement that uses group functions. F. When a subquery is used with an inequality comparison operator in the outer SQL statement, the column list in the SELECT clause of the subquery should contain only one column. 答案:B,F 解析:subquery 分为sigle-row和multiple-rowQ: 53 You need to modify the STUDENTS table to add a primary key on the
STUDENT_ID column. The table is currently empty. Which statement accomplishes this task? A. ALTER TABLE students ADD PRIMARY KEY student_id; B. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id); C. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id; D. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id); E. ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id); 答案:DQ: 54 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 1000 bytes. The column can currently hold 500 bytes per value. The table contains 20000 rows. Which statement is valid? A. ALTER TABLE commercials MODIFY (description CHAR2(1000)); B. ALTER TABLE commercials CHANGE (description CHAR2(1000)); C. ALTER TABLE commercials CHANGE (description VARCHAR2(1000)); D. ALTER TABLE commercials MODIFY (description VARCHAR2(1000)); E. You cannot increase the size of a column if the table has rows. 答案:D 解析:对非空表修改字段大小,要求修改后字段取值范围比原来的大。Q: 55 In which case would you use a FULL OUTER JOIN?
A. Both tables have NULL values. B. You want all unmatched data from one table. C. You want all matched data from both tables. D. You want all unmatched data from both tables. E. One of the tables has more data than the other. F. You want all matched and unmatched data from only one table. 答案:D 解析:full outer join 结果返回所有matched 和 unmatched data from both tables;Q: 56 Which are DML statements? (Choose all that apply.) A. COMMIT B. MERGE C. UPDATE D. DELETE E. CREATE F. DROP... 答案:B,C,D 解析:COMMIT 为DCL语句; E,F为DDL语句;
Q: 57 Examine the description of the EMPLOYEES table: EMP_ID NUMBER(4) NOT NULL LAST_ NAME VARCHAR2(30) NOT NULL FIRST_NAME VARCHAR2(30) DEPT_ID NUMBER(2) JOB_CAT VARCHAR2(30) SALARY NUMBER(8,2) Which statement shows the department ID, minimum salary, and maximum salary paid in that department, only if the minimum salary is less than 5000 and maximum salary is more than 15000? A. SELECT dept_id, MIN(salary), MAX(salary) FROM employees WHERE MIN(salary) < 5000 AND MAX(salary) > 15000; B. SELECT dept_id, MIN(salary), MAX(salary) FROM employees WHERE MIN(salary) < 5000 AND MAX(salary) > 15000 GROUP BY dept_id; C. SELECT dept_id, MIN(salary), MAX(salary) FROM employees HAVING MIN(salary) < 5000 AND MAX(salary) > 15000; D. SELECT dept_id, MIN(salary), MAX(salary) FROM employees GROUP BY dept_id HAVING MIN(salary) < 5000 AND MAX(salary) > 15000; E. SELECT dept_id, MIN(salary), MAX(salary) FROM employees GROUP BY dept_id, salary HAVING MIN(salary) < 5000 AND MAX(salary) > 15000; 答案:D 解析:考group by和having的使用,组函数不能在where条件中使用。
Q: 58 Which four statements correctly describe functions that are available in
SQL? (Choose four.) A. INSTR returns the numeric position of a named character. B. NVL2 returns the first non-null expression in the expression list. C. TRUNCATE rounds the column, expression, or value to n decimal places. D. DECODE translates an expression after comparing it to each search value. E. TRIM trims the heading or trailing characters (or both) from a character string. F. NVL compares two expressions and returns null if they are equal, or the first expression if they are not equal. G. NULLIF compares two expressions and returns null if they are equal, or the first expression if they are not equal. 答案:A,D,E,G 解析: B-NVL2 (expr1, expr2, expr3) If expr1 is not null, NVL2 returns expr2. If expr1 is null, NVL2 returns expr3. The argument expr1 can have any data type. C-truncate 是删除表中数据,trunc才是截取函数 F-Converts a null value to an actual valueQ: 59 Which iSQL*Plus feature can be used to replace values in the WHERE clause?
A. substitution variables B. replacement variables C. prompt variables D. instead-of variables E. This feature cannot be implemented through iSQL*Plus. 答案:A 解析:替换变量Q: 60 Which is an iSQL*Plus command?
A. INSERT B. UPDATE C. SELECT D. DESCRIBE E. DELETE F. RENAME 答案:DQ: 61 The EMP table contains these columns:
EMPLOYEE_ID NUMBER(4) EMPNAME VARCHAR2 (25) SALARY NUMBER(9,2) HIRE_DATE DATE You query the database with this SQL statement: SELECT empname,hire_date HIREDATE, salary FROM EMP ORDER BY hire_date; How will the results be sorted? A. randomly B. ascending by date C. descending by date D. ascending alphabetically E. descending alphabetically 答案:B 解析:默认order by 是采用asc升序。Q: 62 Click the Exhibit button and examine the data from the ORDERS and
CUSTOMERS tables. Evaluate the SQL statement:SELECT *
FROM orders WHERE cust_id = (SELECT cust_id FROM customers WHERE cust_name = 'Smith'); What is the result when the query is executed?答案:D
Q: 63 What is true about updates through a view?
A. You cannot update a view with group functions. B. When you update a view group functions are automatically computed. C. When you update a view only the constraints on the underlying table will be in effect. D. When you update a view the constraints on the views always override the constraints on the underlying tables. 答案:AQ: 64 What does the FORCE option for creating a view do?
A. creates a view with constraints B. creates a view even if the underlying parent table has constraints C. creates a view in another schema even if you don't have privileges D. creates a view regardless of whether or not the base tables exist 答案:DQ: 65 The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(4) LAST_NAME VARCHAR2 (25) JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do you use? A. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA\_%' ESCAPE '\'; B. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'; C. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_' ESCAPE "\"; D. SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_'; 答案:AQ: 66 Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) DEFAULT 'SA_REP' SAL NUMBER COMM_PCT NUMBER MGR_ID NUMBER DEPARTMENT_ID NUMBER You need to update the records of employees 103 and 115. The UPDATE statement you specify should update the rows with the values specified below: JOB_ID: Default value specified for this column definition. SAL: Maximum salary earned for the job ID SA_REP. COMM_PCT: Default value specified for this commission percentage column, if any. If no default value is specified for the column, the value should be NULL. DEPARTMENT_ID: Supplied by the user during run time through substitution variable. Which UPDATE statement meets the requirements? A. UPDATE employees SET job_id = DEFAULT AND Sal = (SELECT MAX(sal) FROM employees WHERE job_id = 'SA_REP') AND comm_pct = DEFAULT AND department_id = &did WHERE employee_id IN (103,115); B. UPDATE employees SET job_id = DEFAULT AND Sal = MAX(sal) AND comm_pct = DEFAULT OR NULL AND department_id = &did WHERE employee_id IN (103,115) AND job_id = 'SA_REP'; C. UPDATE employees SET job_id = DEFAULT, Sal = (SELECT MAX(sal) FROM employees WHERE job_id = 'SA_REP'), comm_pct = DEFAULT, department_id = &did WHERE employee_id IN (103,115); D. UPDATE employees SET job_id = DEFAULT, Sal = MAX(sal), comm_pct = DEFAULT, department_id = &did WHERE employee_id IN (103,115) AND job_id = 'SA_REP'; E. UPDATE employees SET job_id = DEFAULT, Sal = (SELECT MAX(sal) FROM employees WHERE job_id = 'SA_REP'), comm_pct = DEFAULT OR NULL, department_id = &did WHERE employee_id IN (103,115); 答案:C 解析:update不同的列用逗号隔开,COMM_PCT如果default没有定义就返回null,不能default or null;Q: 67 Click the Exhibit button to examine the structures of the EMPLOYEES and
TAX tables. You need to find the percentage tax applicable for each employee. Which SQL statement would you use? A. SELECT employee_id, salary, tax_percent FROM employees e JOIN tax t ON e.salary BETWEEN t.min_salary AND t.max_salary; B. SELECT employee_id, salary, tax_percent FROM employees e JOIN tax t WHERE e.salary > t.min_salary AND < t.max_salary; C. SELECT employee_id, salary, tax_percent FROM employees e JOIN tax t ON (MIN(e.salary) = t.min_salary AND MAX(e.salary) = t.max_salary); D. You cannot find the information because there is no common column between the two tables. 答案:AQ: 68 Examine the description of the CUSTOMERS table:
CUSTOMER_ID NUMBER(4) NOT NULL CUSTOMER_NAME VARCHAR2(100) NOT NULL STREET_ADDRESS VARCHAR2(150) CITY_ADDRESS VARCHAR2(50) STATE_ADDRESS VARCHAR2(50) PROVINCE_ADDRESS VARCHAR2(50) COUNTRY_ADDRESS VARCHAR2(50) POSTAL_CODE VARCHAR2(12) CUSTOMER_PHONE VARCHAR2(20) The CUSTOMER_ID column is the primary key for the table. Which statement returns the city address and the number of customers in the cities Los Angeles or San Francisco? A. SELECT city_address, COUNT(*) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco'); B. SELECT city_address, COUNT(*) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco') GROUP BY city_address; C. SELECT city_address, COUNT(customer_id) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco') GROUP BY city_address, customer_id; D. SELECT city_address, COUNT(customer_id) FROM customers GROUP BY city_address IN ('Los Angeles', 'San Francisco'); 答案:BQ: 69 You need to perform certain data manipulation operations through a view
called EMP_DEPT_VU, which you previously created. You want to look at the definition of the view (the SELECT statement on which the view was created.) How do you obtain the definition of the view? A. Use the DESCRIBE command on the EMP_DEPT_VU view. B. Use the DEFINE VIEW command on the EMP_DEPT_VU view. C. Use the DESCRIBE VIEW command on the EMP_DEPT_VU view. D. Query the USER_VIEWS data dictionary view to search for the EMP_DEPT_VU view. E. Query the USER_SOURCE data dictionary view to search for the EMP_DEPT_VU view. F. Query the USER_OBJECTS data dictionary view to search for the EMP_DEPT_VU view. 答案:D 解析:describe 是查看表结构,要看view的定义语句要用,user_views视图,查看text字段内容。Q: 70 Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) SAL NUMBER MGR_ID NUMBER DEPARTMENT_ID NUMBER You want to create a SQL script file that contains an INSERT statement. When the script is run, the INSERT statement should insert a row with the specified values into the EMPLOYEES table. The INSERT statement should pass values to the table columns as specified below: EMPLOYEE_ID: Next value from the sequence EMP_ID_SEQ EMP_NAME and JOB_ID: As specified by the user during run time, through substitution variables SAL: 2000 MGR_ID: No value DEPARTMENT_ID: Supplied by the user during run time through substitution variable. The INSERT statement should fail if the user supplies a value other than 20 or 50. Which INSERT statement meets the above requirements? A. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did); B. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did IN (20,50)); C. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50)) VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did); D. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50) WITH CHECK OPTION) VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did); E. INSERT INTO (SELECT * FROM employees WHERE (department_id = 20 AND department_id = 50) WITH CHECK OPTION ) VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did); 答案:DQ: 71 Which three are DATETIME data types that can be used when specifying
column definitions? (Choose three.) A. TIMESTAMP B. INTERVAL MONTH TO DAY C. INTERVAL DAY TO SECOND D. INTERVAL YEAR TO MONTH E. TIMESTAMP WITH DATABASE TIMEZONE 答案:A,C,DQ: 72 Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID NUMBER SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You created a sequence called EMP_ID_SEQ in order to populate sequential values for the EMPLOYEE_ID column of the EMPLOYEES table. Which two statements regarding the EMP_ID_SEQ sequence are true? (Choose two.) A. You cannot use the EMP_ID_SEQ sequence to populate the JOB_ID column. B. The EMP_ID_SEQ sequence is invalidated when you modify the EMPLOYEE_ID column. C. The EMP_ID_SEQ sequence is not affected by modifications to the EMPLOYEES table. D. Any other column of NUMBER data type in your schema can use the EMP_ID_SEQ sequence. E. The EMP_ID_SEQ sequence is dropped automatically when you drop the EMPLOYEES table. F. The EMP_ID_SEQ sequence is dropped automatically when you drop the EMPLOYEE_ID column. 答案:C,DQ: 73 Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) HIRE_DATE DATE You issue these statements: CREATE table new_emp ( employee_id NUMBER, name VARCHAR2(30)); INSERT INTO new_emp SELECT employee_id , last_name from employees; Savepoint s1; UPDATE new_emp set name = UPPER(name); Savepoint s2; Delete from new_emp; Rollback to s2; Delete from new_emp where employee_id =180; UPDATE new_emp set name = 'James'; Rollback to s2; UPDATE new_emp set name = 'James' WHERE employee_id =180; Rollback; At the end of this transaction, what is true? A. You have no rows in the table. B. You have an employee with the name of James. C. You cannot roll back to the same savepoint more than once. D. Your last update fails to update any rows because employee ID 180 was already deleted. 答案:A 解析:Rollback 退回到最近一次commit的状态。Q: 74 Which two tasks can you perform using only the TO_CHAR function? (Choose two.) A. convert 10 to 'TEN' B. convert '10' to 10 C. convert 10 to '10' D. convert 'TEN' to 10 E. convert a date to a character expression F. convert a character expression to a date 答案:C,E
Q: 75 You need to create a table named ORDERS that contains four columns:
1. an ORDER_ID column of number data type 2. a CUSTOMER_ID column of number data type 3. an ORDER_STATUS column that contains a character data type 4. a DATE_ORDERED column to contain the date the order was placed When a row is inserted into the table, if no value is provided when the order was placed, today's date should be used instead. Which statement accomplishes this? A. CREATE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2 (10), date_ordered DATE = SYSDATE); B. CREATE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2 (10), date_ordered DATE DEFAULT SYSDATE); C. CREATE OR REPLACE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2 (10), date_ordered DATE DEFAULT SYSDATE); D. CREATE OR REPLACE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2 (10), date_ordered DATE = SYSDATE); E. CREATE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status NUMBER (10), date_ordered DATE = SYSDATE); F. CREATE TABLE orders ( order_id NUMBER(10), customer_id NUMBER(8), order_status NUMBER (10), date_ordered DATE DEFAULT SYSDATE); 答案:BQ: 76 In which three cases would you use the USING clause? (Choose three.)
A. You want to create a nonequijoin. B. The tables to be joined have multiple NULL columns. C. The tables to be joined have columns of the same name and different data types. D. The tables to be joined have columns with the same name and compatible data types. E. You want to use a NATURAL join, but you want to restrict the number of columns in the join condition. 答案:C,D,E 解析:using是在对两边进行join时,指定关联的两列,必须名称一样,字段类型可不同,也可用于natural连接时,指定部分相同的 列作为关联条件。Q: 77 The EMP table contains these columns:
LAST_NAME VARCHAR2 (25) SALARY NUMBER (6,2) DEPARTMENT_ID NUMBER (6) You need to display the employees who have not been assigned to any department. You write the SELECT statement: SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; What is true about this SQL statement ? A. The SQL statement displays the desired results. B. The column in the WHERE clause should be changed to display the desired results. C. The operator in the WHERE clause should be changed to display the desired results. D. The WHERE clause should be changed to use an outer join to display the desired results. 答案:C 解析:判断是否为空值要用is null 不能用=null;Q: 78 Examine the SQL statement that creates ORDERS table:
CREATE TABLE orders (SER_NO NUMBER UNIQUE, ORDER_ID NUMBER, ORDER_DATE DATE NOT NULL, STATUS VARCHAR2(10) CHECK (status IN ('CREDIT', 'CASH')), PROD_ID NUMBER REFERENCES PRODUCTS(PRODUCT_ID), ORD_TOTAL NUMBER, PRIMARY KEY (order_id, order_date)); For which columns would an index be automatically created when you execute the above SQL statement? (Choose two.) A. SER_NO B. ORDER_ID C. STATUS D. PROD_ID E. ORD_TOTAL F. composite index on ORDER_ID and ORDER_DATE 答案:A,F 解析:当字段为unique和primary key约束时,系统会自动生成唯一性索引。Q: 79 Examine the description of the MARKS table:
STD_ID NUMBER(4) STUDENT_NAME VARCHAR2(30) SUBJ1 NUMBER(3) SUBJ2 NUMBER(3) SUBJ1 and SUBJ2 indicate the marks obtained by a student in two subjects. Examine this SELECT statement based on the MARKS table: SELECT subj1+subj2 total_marks, std_id FROM marks WHERE subj1 > AVG(subj1) AND subj2 > AVG(subj2) ORDER BY total_marks; What is the result of the SELECT statement? A. The statement executes successfully and returns the student ID and sum of all marks for each student who obtained more than the average mark in each subject. B. The statement returns an error at the SELECT clause. C. The statement returns an error at the WHERE clause. D. The statement returns an error at the ORDER BY clause. 答案:C 解析:where中不能使用avg组函数,只能在having中过来Q: 80 The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER(4) NOT NULL CUSTOMER_NAME VARCHAR2(100) NOT NULL CUSTOMER_ADDRESS VARCHAR2(150) CUSTOMER_PHONE VARCHAR2(20) You need to produce output that states "Dear Customer customer_name, ". The customer_name data values come from the CUSTOMER_NAME column in the CUSTOMERS table. Which statement produces this output? A. SELECT dear customer, customer_name, FROM customers; B. SELECT "Dear Customer", customer_name || ',' FROM customers; C. SELECT 'Dear Customer ' || customer_name ',' FROM customers; D. SELECT 'Dear Customer ' || customer_name || ',' FROM customers; E. SELECT "Dear Customer " || customer_name || "," FROM customers; F. SELECT 'Dear Customer ' || customer_name || ',' || FROM customers; 答案:D