吉大数据库应用技术在线作 业一 答案资料

上传人:w****i 文档编号:92495846 上传时间:2019-07-10 格式:DOC 页数:7 大小:51KB
返回 下载 相关 举报
吉大数据库应用技术在线作 业一 答案资料_第1页
第1页 / 共7页
吉大数据库应用技术在线作 业一 答案资料_第2页
第2页 / 共7页
吉大数据库应用技术在线作 业一 答案资料_第3页
第3页 / 共7页
吉大数据库应用技术在线作 业一 答案资料_第4页
第4页 / 共7页
吉大数据库应用技术在线作 业一 答案资料_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《吉大数据库应用技术在线作 业一 答案资料》由会员分享,可在线阅读,更多相关《吉大数据库应用技术在线作 业一 答案资料(7页珍藏版)》请在金锄头文库上搜索。

1、吉大数据库应用技术在线作业一答案 试卷总分:100 测试时间:- 试卷得分:100 单选题 一、单选题(共 25 道试题,共 100 分。) 得分:100V 1. Given the following table: TestTable C1 - 12345 And if the following CLI calls are made: SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv); SQLSetEnvAttr( henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3,0); S

2、QL AllocHandle(SQL_HANDLE_DBC,henv,&hdbc); SQLConnect( hdbc, (SQLCHAR *)db, SQL_NTS, (SQLCHAR *)userid, SQL_NTS, (SQLCHAR *)password, SQL_NTS ); SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0); SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt); SQLPrepare(hstmt,(unsigned char*)select

3、*from Test order by C1,SQL_NTS); SQLBindCol(hstmt,1,SQL_C_SHORT,&data,0,NULL); SQLExecute(hstmt); SQLFetch(hstmt); printf(Data:%in,data); SQLFetch(hstmt); printf(Data:%in,data); SQLFetch(hstmt); printf(Data:%in,data); SQLEndTran(SQL_HANDLE_ENV,henv,SQL_COMMIT); SQLFetch(hstmt); printf(Data:%in,data)

4、; Which of the following will be returned by the program? A. Data: 1 Data: 2 Data: 3 Data: 3 B. Data: 1 Data: 2 Data: 3 Data: 4 C. Data: 1 Data: 2 Data: 3 Data: 1 D. Data: 1 Data: 2 Data: 3 Data: 5 满分:4 分 得分:4 2. Given the code: EXEC SQL DECLARE cursor1 CURSOR FOR SELECT name,age,b_date FROM person;

5、 EXEC SQL OPEN cursor1; Under which of the following situations will the above cursor be implicitly closed? A. When a CLOSE statement is issued B. When a COMMIT statement is issued C. When there are no rows in the result set D. When all rows are FETCHed from the result set 满分:4 分 得分:4 3. Given the a

6、pplication code: EXEC SQL DECLARE cur CURSOR WITH HOLD FOR SELECT 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 CLOSE cur /* Statement 5 */ If the

7、 table T1 has no rows in it, which statement will cause the cursor cur to be closed first? A. Statement 1 B. Statement 2 C. Statement 3 D. Statement 4 满分:4 分 得分:4 4. How many rows can be retrieved using a single SELECT INTO statement? A. Only one row B. As many as are in the result C. As many as are

8、 host variables used in the call D. As many as host variable array structures can hold 满分:4 分 得分:4 5. Given the table T1 with the following data: COL1 IDX - - A single-threaded CLI application executes the following pseudocode in sequence: SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv ) SQLAllocHandle

9、( SQL_HANDLE_DBC, hEnv, &hDbc ) SQLConnect( hDbc, SAMPLE, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS ) SQLSetConnectAttr( hDbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_ON ) SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt ) SQLExecDirect( hStmt, UPDATE table1 SET col1=10 WHERE idx=1, SQL_NTS ) SQLExecDirect( hS

10、tmt, UPDATE table1 SET col1=20 WHERE idx=2, SQL_NTS ) SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_COMMIT ) SQLExecDirect( hStmt, UPDATE table1 SET col1=30 WHERE idx=1, SQL_NTS ) SQLExecDirect( hStmt, UPDATE table1 SET col1=40 WHERE idx=1, SQL_NTS ) SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_ROLLBACK ) SQLExecD

11、irect( hStmt, SELECT col1 FROM table1 WHERE idx=1, SQL_NTS ) Which of the following values for COL1 will be fetched when the sequence for the pseudocode listed above is successfully executed? A. 10 B. 20 C. 30 D. 40 满分:4 分 得分:4 6. Given the table T1 with the following data: C1 C2 - - 1 1 2 2 An appl

12、ication issues the following SQL statements with AUTOCOMMIT disabled: UPDATE t1 SET c1 = 10 WHERE c2 = 1 UPDATE t1 SET c1 = 20 WHERE c2 = 2 SAVEPOINT sp1 UPDATE t1 SET c1 = 30 WHERE c2 = 1 UPDATE t1 SET c1 = 40, c2 = 3 WHERE c2 = 2 SAVEPOINT sp1 UPDATE t1 SET c1 = 50 WHERE c2 = 1 UPDATE t1 SET c1 =

13、60 WHERE c2 = 2 ROLLBACK TO SAVEPOINT sp1 UPDATE t1 SET c1 = 50 WHERE c2 = 3 COMMIT What is the result of the following query? SELECT c1, c2 FROM t1 ORDER BY c2 A. 10 1 20 2 B. 30 1 50 3 C. 30 1 40 3 D. 10 1 50 3 满分:4 分 得分:4 7. Which of the following cursor definitions will define a cursor called c2

14、 that will fetch rows from table t2, and for every row fetched will update column c1 in table t2? A. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF t2 B. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF c2 C. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF c1 D. DECLARE c2 CURSOR WITH HOLD

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号