0

databases Online Quiz - 73

Description: databases Online Quiz - 73
Number of Questions: 20
Created by:
Tags: databases
Attempted 0/20 Correct 0 Score 0

Which of the following database objects is considered executable using SQL?

  1. View

  2. Table

  3. Routine

  4. Package


Correct Option: C

A user utilizing an alias to update a subset of columns in a table must have UPDATE privileges on which of the following DB2 objects?

  1. Table

  2. Columns

  3. Table and Alias

  4. Columns and Alias


Correct Option: A

In which of the following scenarios would a stored procedure be beneficial?

  1. An application running on a remote client needs to be able to convert degrees Celsius to degrees Fahrenheit and vice versa

  2. An application running on a remote client needs to collect three input values, perform a calculation using the values provided, and store the input data, along with the results of the calculation in two different base tables

  3. An application running on a remote client needs to track every modification made to a table that contains sensitive data

  4. An application running on a remote client needs to ensure that every new employee that joins the company is assigned a unique, sequential employee number


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) An application running on a remote client needs to be able to convert degrees Celsius to degrees Fahrenheit and vice versa - In this scenario, a stored procedure may not be necessary. Converting degrees Celsius to degrees Fahrenheit and vice versa can be easily achieved using a simple mathematical calculation and does not require the use of a stored procedure.

Option B) An application running on a remote client needs to collect three input values, perform a calculation using the values provided, and store the input data, along with the results of the calculation in two different base tables - In this scenario, a stored procedure can be beneficial. By creating a stored procedure, you can encapsulate the logic for collecting input values, performing the calculation, and storing the data in two different tables. This can simplify the code on the client-side and provide a centralized and consistent method for performing the calculation and storing the data.

Option C) An application running on a remote client needs to track every modification made to a table that contains sensitive data - In this scenario, a stored procedure can be beneficial. By creating a stored procedure, you can define triggers or audit mechanisms within the procedure to track every modification made to the sensitive table. This can help ensure that any modifications are properly logged and audited.

Option D) An application running on a remote client needs to ensure that every new employee that joins the company is assigned a unique, sequential employee number - In this scenario, a stored procedure may not be necessary. Assigning unique, sequential employee numbers can be achieved through the use of auto-incrementing columns or identity columns in the database table. These mechanisms can automatically generate a unique employee number for each new record without the need for a stored procedure.

The correct answer is B. This option is correct because a stored procedure can simplify the code on the client-side and provide a centralized and consistent method for performing the calculation and storing the data in two different tables.

A programmer wants to generate values for a numeric ID column in their EXPENSE table. The ID column values need to be incremented by 1000 for each new expense report added to the EXPENSE table. Which DB2 object can be referenced by an INSERT statement to meet thisrequirement?

  1. Sequence

  2. Table Function

  3. Identity Column

  4. INSTEAD OF Trigger


Correct Option: A

Given the following DDL for the PARTS table: CREATE TABLE parts (part_no INT(9) NOT NULL, part_name VARCHAR(24), part_remain INT(9)); All part numbers entered will be different and all rows should be displayed in order of increasing part numbers whenever the table is queried. Which of the following create index statements will meet this criteria and require the least amount of storage for the index object?

  1. CREATE UNIQUE INDEX idx_partno ON parts(part_no)

  2. CREATE UNIQUE INDEX idx_partno ON parts(part_name ASC)

  3. CREATE UNIQUE INDEX idx_partno ON parts(part_name, part_no ASC)

  4. CREATE UNIQUE INDEX idx_partno ON parts(part_no, part_name ASC)


Correct Option: A

What type of constraint can be used to ensure that, in any given row in a table, the value of one column never exceeds the value of another column?

  1. Check

  2. Range

  3. Referential

  4. Informational


Correct Option: A

Which of the following will DELETE all of the rows from table T03?

  1. DELETE * FROM TABLE T03

  2. DELETE ALL FROM T03

  3. DELETE * FROM T03

  4. DELETE FROM T03


Correct Option: D

Which of the following can NOT be done using the ALTER TABLE statement?

  1. Add a new column

  2. Drop a check constraint

  3. Change a column's name

  4. Change the length of a VARCHAR column


Correct Option: C

AI Explanation

To answer this question, you need to understand the capabilities of the ALTER TABLE statement in SQL. Let's go through each option to understand why it is correct or incorrect:

Option A) Add a new column - This option is correct because the ALTER TABLE statement can be used to add a new column to an existing table.

Option B) Drop a check constraint - This option is correct because the ALTER TABLE statement can be used to drop or remove a check constraint from a table.

Option C) Change a column's name - This option is incorrect because the ALTER TABLE statement can be used to change a column's name in SQL. Therefore, it can be done using the ALTER TABLE statement.

Option D) Change the length of a VARCHAR column - This option is correct because the ALTER TABLE statement can be used to modify the length of a VARCHAR column in SQL.

The correct answer is C. Changing a column's name can be done using the ALTER TABLE statement.

Which of the following will be a consequence of defining the column IDCOL2 in TABLE2 as a foreign key referencing the primary key (IDCOL1) of TABLE1?

  1. DB2 will no longer allow updating the value of IDCOL1 in TABLE1.

  2. When inserting a row in TABLE2, the only values that DB2 will allow for IDCOL2 are the existing values of IDCOL1.

  3. When inserting a row in TABLE2, DB2 will only allow foreign values for IDCOL2, that is values which do not exist in IDCOL1.

  4. When a SELECT statement joins TABLE1 with TABLE2, DB2 will automatically add the condition TABLE1.IDCOL1=TABLE2.IDCOL2 if not specified in the statement


Correct Option: B

Table TABLE1 needs to hold specific numeric values up to 9999999.999 in column COL1. COL1 is also used to perform arithmetic operations. Which of the following would be the most appropriate DB2 data type to use for column COL1?

  1. INTEGER

  2. REAL

  3. NUMERIC(7, 3)

  4. DECIMAL(10, 3)


Correct Option: D

Which of the following DB2 objects are publicly referenced names that require no special authority or privilege to use them?

  1. View

  2. Alias

  3. Table

  4. Package


Correct Option: B

A sequence was created with the DDL statement shown below: CREATE SEQUENCE my_sequence CACHE 10 ORDER The following statements are successfully executed in sequence through separate database connections: CONNECTION1 - VALUES NEXT VALUE FOR my_sequence INTO :con1hvar CONNECTION2 VALUES NEXT VALUE FOR my_sequence INTO :con2hvar CONNECTION1 - VALUES NEXT VALUE FOR my_sequence INTO :con1hvar What is the current value of the :con1hvar host variable?

  1. 2

  2. 3

  3. 11

  4. 30


Correct Option: B

A sequence was created with the DDL statement shown below: CREATE SEQUENCE my_seq START WITH 5 INCREMENT BY 5 CACHE 5 User1 successfully executes the following statements in Connections VALUES NEXT VALUE FOR my_seq INTO :con1hvar VALUES NEXT VALUE FOR my_seq INTO :con1hvar User2 successfully executes the following statement in Connection2: VALUES NEXT VALUE FOR my_seq INTO :con2hvar After User1 & User2 are finished, User3 executes the following statement in Connection3: SELECT NEXT VALUE FOR my_seq FROM sysibm.sysdummy1 Which value will be returned by the query?

  1. 20

  2. 25

  3. 50

  4. 55


Correct Option: D

A DRDA host database resides on a z/OS or an i5/OS system and listens on port 446. The TCP/IP address for this system is 192.168.10.1 and the TCP/IP host name is myhost. Which of the following commands is required to update the local node directory so that a DB2 client can access this DRDA database?

  1. CATALOG TCPIP NODE myhost REMOTE db2srv SERVER 446

  2. CATALOG TCPIP NODE mydb2srv REMOTE myhost SERVER 446

  3. CATALOG TCPIP NODE myhost REMOTE db2srv SERVER 192.168.10.1

  4. CATALOG TCPIP NODE mydb2srv REMOTE myhost SERVER 192.168.10.1


Correct Option: B

A stored procedure object is created into which DB2 object?

  1. Alias

  2. Schema

  3. Package

  4. Routine Space


Correct Option: B

Given the following DDL and INSERT statements: CREATE VIEW v1 AS SELECT col1 FROM t1 WHERE col1 > 10; CREATE VIEW v2 AS SELECT col1 FROM v1 WITH CASCADED CHECK OPTION; CREATE VIEW v3 AS SELECT col1 FROM v2 WHERE col1 < 100; INSERT INTO v1 VALUES(5); INSERT INTO v2 VALUES(5); INSERT INTO v3 VALUES(20); INSERT INTO v3 VALUES(100); How many of these INSERT statements will be successful? What is the expected sequence of value returned from the below query? SELECT Product-ID, Quantity from Customer ORDER BY Product-ID;

  1. 0

  2. 1

  3. 2

  4. 3


Correct Option: C

Which of the following is not true about XML Columns ?

  1. Data can be retrieved by SQL

  2. Data can be retrieved by XQUERY

  3. XML Columns must be altered to accommodate additional parent and child relationships

  4. Access to any portion of an XML document can be direct ,without reading whole document


Correct Option: C

An application needs to store a 5MB JPEG image in a DB2 table. Which datatype should be used to specify a column that will be used for storing A image ?

  1. GRAPHIC

  2. BINARY

  3. IMAGE

  4. BLOB


Correct Option: D
Explanation:

To solve this question, the user needs to know the different datatypes that can be used to store binary data, such as images, in a DB2 table.

Now, let's go through each option and explain why it is right or wrong:

A. GRAPHIC: This datatype is used to store fixed-length character data in Unicode format. It is not appropriate for storing binary data such as images.

B. BINARY: This datatype is used to store binary data in a fixed-length format. It is a valid option for storing images, but it does not provide compression capabilities.

C. IMAGE: This datatype is used to store large objects in a compressed format. It is an option for storing images, but it is not recommended as it has been deprecated in recent versions of DB2.

D. BLOB: This datatype is used to store large binary objects in a compressed format. It is the recommended option for storing images in a DB2 table as it provides compression capabilities and can handle large objects.

Therefore, the correct answer is:

The Answer is: D. BLOB

Which of the following constraint types can be used to ensure the value Of an INTEGER column references only positive values.

  1. Unique

  2. Check

  3. Referential

  4. Informational


Correct Option: B

Given that tables T1 and T2 contain the following rows : Table T1 : C1 C2 (5 4) (5 2) (5 5) Table T2 : C1 C2 (5 1) (5 2) (5 3) Which of the following queries will return only those rows that exists in T1 and not in T2 ?

  1. Select * from T1 minus select * from T2

  2. Select * from T1 except select * from T2

  3. Select * from T1 union except select * from T2

  4. Select * from T1 not exists select * from T2


Correct Option: B
- Hide questions