吉大《数据库应用技术》在线作业一答案试卷总分:100 测试时间:-- 试卷得分:100单选题一、单选题(共25 道试题,共100 分。
)得分:100V1. Given the following table:TestTable C1 ----------- 12345 And if the following CLI calls are made:SQLAlloc Handle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv); SQLSetEnvAttr( henv,SQL_A TTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3,0); SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc); SQLConnect( hdbc, (SQLCHAR *)"db",SQL_NTS, (SQLCHAR *)"userid", SQL_NTS, (SQLCHAR *)"password", SQL_NTS );SQLSetConnectAttr( hdbc, SQL_A TTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0);SQLAlloc Handle(SQL_HANDLE_STMT,hdbc,&hstmt); SQLPrepare(hstmt,(unsignedchar*)"select *from Test order by C1',SQL_NTS);SQLBindCol(hstmt,1,SQL_C_SHORT,&data,0,NULL); SQLExecute(hstmt);SQLFetch(hstmt); printf(Data:%i\n",data); SQLFetch(hstmt);printf(Data:%i\n",data); SQLFetch(hstmt); printf(Data:%i\n",data);SQLEndTran(SQL_HANDLE_ENV,henv,SQL_COMMIT); SQLFetch(hstmt);printf(Data:%i\n",data); Which of the following will be returned by theprogram?A. Data: 1 Data: 2 Data: 3 Data: 3B. Data: 1 Data: 2 Data: 3 Data: 4C. Data: 1 Data: 2 Data: 3 Data: 1D. Data: 1 Data: 2 Data: 3 Data: 5满分:4 分得分:42. Given the code: EXEC SQL DECLARE cursor1 CURSOR FOR SELECTname,age,b_date FROM person; EXEC SQL OPEN cursor1; Under which of thefollowing situations will the above cursor be implicitly closed?A. When a CLOSE statement is issuedB. When a COMMIT statement is issuedC. When there are no rows in the result setD. When all rows are FETCHed from the result set满分:4 分得分:43. Given the application code: EXEC SQL DECLARE cur CURSOR WITH HOLD FORSELECT c1 FROM t1 EXEC SQL OPEN cur EXEC SQL FETCH cur INTO :hv /*Statement 1 */ EXEC SQL COMMIT /* Statement 2 */ EXEC SQL FETCH cur INTO:hv /* Statement 3 */ EXEC SQL ROLLBACK /* Statement 4 */ EXEC SQL CLOSEcur /* Statement 5 */ If the table T1 has no rows in it, which statementwill cause the cursor "cur" to be closed first?A. Statement 1B. Statement 2C. Statement 3D. Statement 4满分:4 分得分:44. How many rows can be retrieved using a single SELECT INTO statement?A. Only one rowB. As many as are in the resultC. As many as are host variables used in the callD. As many as host variable array structures can hold满分:4 分得分:45. Given the table T1 with the following data: COL1 IDX ---- ---- Asingle-threaded CLI application executes the following pseudocode insequence: SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv ) SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hDbc ) SQLConnect( hDbc, "SAMPLE", SQL_NTS, NULL,SQL_NTS, NULL, SQL_NTS ) SQLSetConnectAttr( hDbc, SQL_A TTR_AUTOCOMMIT,SQL_AUTOCOMMIT_ON ) SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt ) SQLExecDirect( hStmt, "UPDA TE table1 SET col1=10 WHERE idx=1", SQL_NTS )SQLExecDirect( hStmt, "UPDA TE table1 SET col1=20 WHERE idx=2", SQL_NTS )SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_COMMIT ) SQLExecDirect( hStmt,"UPDA TE table1 SET col1=30 WHERE idx=1", SQL_NTS ) SQLExecDirect( hStmt,"UPDA TE table1 SET col1=40 WHERE idx=1", SQL_NTS ) SQLEndTran(SQL_HANDLE_DBC, hDbc, SQL_ROLLBACK ) SQLExecDirect( hStmt, "SELECT col1FROM table1 WHERE idx=1", SQL_NTS ) Which of the following values for COL1will be fetched when the sequence for the pseudocode listed above issuccessfully executed?A. 10B. 20C. 30D. 40满分:4 分得分:46. Given the table T1 with the following data: C1 C2 -- -- 1 1 2 2 Anapplication issues the following SQL statements with AUTOCOMMIT disabled:UPDA TE t1 SET c1 = 10 WHERE c2 = 1 UPDA TE t1 SET c1 = 20 WHERE c2 = 2SA VEPOINT sp1 UPDA TE t1 SET c1 = 30 WHERE c2 = 1 UPDA TE t1 SET c1 = 40, c2 = 3 WHERE c2 = 2 SA VEPOINT sp1 UPDA TE t1 SET c1 = 50 WHERE c2 = 1 UPDA TE t1 SET c1 = 60 WHERE c2 = 2 ROLLBACK TO SA VEPOINT sp1 UPDA TE t1 SET c1 =50 WHERE c2 = 3 COMMIT What is the result of the following query? SELECTc1, c2 FROM t1 ORDER BY c2A. 10 1 20 2B. 30 1 50 3C. 30 1 40 3D. 10 1 50 3满分:4 分得分:47. Which of the following cursor definitions will define a cursor calledc2 that will fetch rows from table t2, and for every row fetched willupdate column c1 in table t2?A. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDA TE OF t2B. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDA TE OF c2C. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDA TE OF c1D. DECLARE c2 CURSOR WITH HOLD FOR SELECT * FROM t2 FOR UPDA TE OF t2满分:4 分得分:48. Given an ODBC/CLI program with a single connection, two threads andthe following actions which complete successfully: Thread 1: INSERT INTOmytab V ALUES (1) Thread 2: INSERT INTO mytab V ALUES (2) Thread 1: COMMITThread 2: INSERT INTO mytab V ALUES (3) Thread 1: ROLLBACK Thread 2: COMMIT How many records will be inserted and retained in the table MYTAB?A. 0B. 1C. 2D. 3满分:4 分得分:49. Given the following code: EXEC SQL EXECUTE IMMEDIA TE :sqlstmt Which ofthe following values must sqlstmt contain so that all rows are deletedfrom the STAFF table?A. DROP TABLE staffB. DELETE FROM staffC. DROP * FROM staffD. DELETE * FROM staff满分:4 分得分:410. Given the expression: WITH most_cities AS ( SELECTb.id,,a.cities FROM country a, staff b WHERE a.person = b.id ANDcities > :threshold ) SELECT * FROM most_cities In which of the followingdoes MOST_CITIES exist?A. user tablesB. server memoryC. user table spaceD. system catalog tables满分:4 分得分:411. Given the following statements: EXEC SQL INSERT INTO employeeV ALUES(:new_emp, :new_name) EXEC SQL UPDA TE company SETnum_employees=num_employees+1 WHERE company_id=1 EXEC SQL COMMIT Which ofthe following can be added to the database so that the company table willstill be updated without the need for the explic it UPDA TE SQL statement?A. An INSERT trigger on COMPANYB. An UPDA TE trigger on COMPANYC. An INSERT trigger on EMPLOYEED. An UPDA TE trigger on EMPLOYEE满分:4 分得分:412. Which of the following produces a sequentially increasing number,suitable for use as a primary key?A. ROWID data typeB. Generated IDENTITY columnC. GENERA TE_UNIQUE built-in functionD. CURRENT SEQUENCE special register满分:4 分得分:413. A cursor is declared with the WITH HOLD option. Which of thefollowing statements is always true?A. The cursor will remain open after a COMMIT.B. All rows retrieved are locked until a COMMIT.C. A COMMIT will not be allowed until the cursor is closed.D. Locks obtained by the cursor will be kept after a COMMIT.满分:4 分得分:414. Given the table called NAME with the following column and data: lname------ Smith SMITH SmiTh smith Which of the following SQL statements willreturn all four rows in upper case?A. SELECT CAPS(lname) FROM nameB. SELECT UCASE(lname) FROM nameC. SELECT STRUPR(lname) FROM nameD. SELECT TOUPPER(lname) FROM name满分:4 分得分:415. Given the tables T1 and T2, each with an INTEGER column: T1 COL1----------- 1- 1- 22 T2 COL1 ----------- 1- 2- 22 and the following querythat executes successfully: SELECT * FROM T1 LEFT OUTER JOIN T2 ONT1.COL1=T2.COL1 How many rows will the query return?A. 5B. 6C. 10D. 36满分:4 分得分:416. Which of the following will retrieve results that will only be inlower case?A. SELECT NAME FROM EMPLOYEE WHERE NAME='ali'B. SELECT NAME FROM EMPLOYEE WHERE LCASE(NAME)='ali'C. SELECT UCASE(NAME) FROM EMPLOYEE WHERE LCASE(NAME)='ali'D. SELECT NAME FROM EMPLOYEE WHERE NAME IN (SELECT NAME FROM EMPLOYEEWHERE LCASE(NAME)=LCASE('ALI'))满分:4 分得分:417. Given the tables: COUNTRY id name 1 Argentina 3 Cuba 4 - NA TION idname 2 Belgium 4 USA and the code: EXEC SQL DECLARE C1 CURSOR FOR SELECT *FROM country WHERE name IS NOT NULL UNION SELECT * FROM nation EXEC SQLOPEN C1 How many rows are in the result set?A. 1B. 2C. 3D. 4满分:4 分得分:418. Given the tables: EMPLOYEE DEPT emp_num emp_name dept dept_iddept_name 1 Adams 1 1 Planning 2 Jones 1 2 Support 3 Smith 2 4 Williams 1and the statement: ALTER TABLE employee ADD FOREIGN KEY (dept) REFERENCES dept (dept_id) ON DELETE CASCADE How many rows will be deleted when thefollowing statement is executed? DELETE FROM employee WHERE dept=1A. 0B. 1C. 3D. 4满分:4 分得分:419. Which of the following is a benefit of user-defined functions?A. Improves application concurrencyB. Improves blocking of result setsC. Simplifies application maintenanceD. Reduces memory requirements on the server满分:4 分得分:420. An application uses static SQL to connect to a remote DB2 server andinserts data into the CUST.ORDERS table on that remote DB2 server. Toenable access to the remote DB2 server, FOO needs to create a package withdefault options so that BAR is the only non-administrative user that canuse this package on the remote DB2 server. Which statement describes theprivileges that FOO requires to accomplish this?A. FOO requires EXECUTE privilege on the package.B. FOO requires the privilege to create the package on the remote DB2server.C. FOO requires EXECUTE privilege on the package and INSERT privilege onCUST.ORDERS.D. FOO requires the privilege to create the package on the remote DB2server and INSERT privilege on CUST.ORDERS.满分:4 分得分:421. If a stored procedure returns multiple rows, which of the followingmust the calling application use to access the result set?A. A cursorB. A select statementC. A declared temporary tableD. A table user-defined function满分:4 分得分:422. Which of the following CLI/ODBC functions should be used to deleterows from a DB2 table?A. SQLDelete()B. SQLExecDirect()C. SQLBulkDelete()D. SQLExecuteUpdate()满分:4 分得分:423. Which of the following is used to run an embedded dynamic SQL UPDA TEstatement?A. UPDA TEB. . PREPAREC. . DECLARED. . EXECUTE满分:4 分得分:424. An ODBC/CLI application performs an array insert into a tablecontaining a primary key. If one of the values inserted generates aduplicate row error, which of the following APIs can be called todetermine the failing row?A. SQLError()B. SQLNumRows()C. SQLRowCount()D. SQLGetDiagField()满分:4 分得分:425. Given the following code: BEGIN A TOMIC UPDA TE country SETcities=:count WHERE CURRENT OF C1; INSERT INTO countryV ALUES(:co11,:co12,:co13); INSERT INTO country V ALUES(:co14,:co15,:co16);INSERT INTO country V ALUES(:co17,:co18,:co19); INSERT INTO countryV ALUES(:co110,:co111,:co112); COMMIT; END Given that all statementssucceed except the following: INSERT INTO countryV ALUES(:co17,:co18,:co19); How many rows will be affected in table COUNTRY?A. 0B. 3C. 4D. 5满分:4 分得分:4。