0

databases Online Quiz - 141

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

Which command lets you put data into more than one table using a single command?

  1. MERGE

  2. INSERT INTO MANY

  3. MULTIADD

  4. INSERT ALL INTO


Correct Option: D

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?

  1. SER_NO

  2. ORDER_ID

  3. STATUS

  4. PROD_ID

  5. ORD_TOTAL

  6. composite index on ORDER_ID and ORDER_DATE


Correct Option: A,F

AI Explanation

To determine which columns would have an index automatically created when executing the given SQL statement, we need to consider the following:

  1. The "UNIQUE" constraint on the "SER_NO" column would automatically create an index for that column (Option A).

  2. The "PRIMARY KEY" constraint on the combination of "ORDER_ID" and "ORDER_DATE" columns would automatically create a composite index on those columns (Option F).

Therefore, the correct answer is options A and F.

Which three are DATETIME data types that can be used when specifying column definitions? (Choose three.)

  1. TIMESTAMP

  2. INTERVAL MONTH TO DAY

  3. INTERVAL DAY TO SECOND

  4. INTERVAL YEAR TO MONTH

  5. TIMESTAMP WITH DATABASE TIMEZONE


Correct Option: A,C,D

Evaluate the SQL statement: TRUNCATE TABLE DEPT; Which three are true about the SQL statement? (Choose three.) A. It releases the storage space used by the table. B. It does not release the storage space used by the table. C. You can roll back the deletion of rows after the statement executes. D. You can NOT roll back the deletion of rows after the statement executes. E. An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement executes will display an error. F. You must be the owner of the table or have DELETE ANY TABLE system privileges to truncate the DEPT table.

  1. A

  2. B

  3. C

  4. D

  5. E

  6. F


Correct Option: A,D,F

AI Explanation

To evaluate the given SQL statement TRUNCATE TABLE DEPT;, let's go through each option to determine which are true:

Option A) It releases the storage space used by the table - This option is true. The TRUNCATE statement removes all rows from the table and releases the storage space used by the table.

Option B) It does not release the storage space used by the table - This option is false. As mentioned above, the TRUNCATE statement does release the storage space used by the table.

Option C) You can roll back the deletion of rows after the statement executes - This option is false. The TRUNCATE statement cannot be rolled back. Once the statement executes, the rows are permanently deleted.

Option D) You can NOT roll back the deletion of rows after the statement executes - This option is true. As mentioned above, the TRUNCATE statement cannot be rolled back.

Option E) An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement executes will display an error - This option is false. After the TRUNCATE statement executes, the table structure remains intact. You can still use DESCRIBE or any other metadata query on the table.

Option F) You must be the owner of the table or have DELETE ANY TABLE system privileges to truncate the DEPT table - This option is true. To truncate a table, you need to have the necessary privileges. Typically, you must either be the owner of the table or have the DELETE ANY TABLE system privilege.

Therefore, the correct options are A, D, and F.

Which two statements about sequences are true? (Choose two.) A. You use a NEXTVAL pseudo column to look at the next possible value that would be generated from a sequence, without actually retrieving the value. B. You use a CURRVAL pseudo column to look at the current value just generated from a sequence, without affecting the further values to be generated from the sequence. C. You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually retrieving the value from the sequence. D. You use a CURRVAL pseudo column to generate a value from a sequence that would be used for a specified database column. E. If a sequence starting from a value 100 and incremented by 1 is used by more than one application, then all of these applications could have a value of 105 assigned to their column whose value is being generated by the sequence. F. You use a REUSE clause when creating a sequence to restart the sequence once it generates the maximum value defined for the sequence.

  1. A

  2. B

  3. C

  4. D

  5. E

  6. F


Correct Option: B,C

AI Explanation

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

Option A) You use a NEXTVAL pseudo column to look at the next possible value that would be generated from a sequence, without actually retrieving the value. - This option is incorrect. The NEXTVAL pseudo column is used to retrieve the next value from a sequence, not just to look at it without retrieving it.

Option B) You use a CURRVAL pseudo column to look at the current value just generated from a sequence, without affecting the further values to be generated from the sequence. - This option is correct. The CURRVAL pseudo column is used to retrieve the current value generated from a sequence without affecting the sequence itself.

Option C) You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually retrieving the value from the sequence. - This option is correct. The NEXTVAL pseudo column is used to retrieve the next value from a sequence by actually retrieving it from the sequence.

Option D) You use a CURRVAL pseudo column to generate a value from a sequence that would be used for a specified database column. - This option is incorrect. The CURRVAL pseudo column is used to retrieve the current value generated from a sequence, not to generate a new value.

Option E) If a sequence starting from a value 100 and incremented by 1 is used by more than one application, then all of these applications could have a value of 105 assigned to their column whose value is being generated by the sequence. - This option is incorrect. Each application will retrieve the next value from the sequence independently, so they will receive different values. In this case, each application will receive a different value after 100.

Option F) You use a REUSE clause when creating a sequence to restart the sequence once it generates the maximum value defined for the sequence. - This option is incorrect. The REUSE clause is not used to restart the sequence once it reaches the maximum value. It is used when dropping and recreating a sequence to reuse the existing values.

The correct answers are B) You use a CURRVAL pseudo column to look at the current value just generated from a sequence, without affecting the further values to be generated from the sequence. and C) You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually retrieving the value from the sequence.

Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12? A. SELECT ename, salary*12 'Annual Salary' FROM employees; B. SELECT ename, salary*12 "Annual Salary" FROM employees; C. SELECT ename, salary*12 AS Annual Salary FROM employees; D. SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees

  1. A

  2. B

  3. C

  4. D


Correct Option: B

AI Explanation

To answer this question, we need to understand how to generate an alias for a calculated column in SQL.

Option A) SELECT ename, salary*12 'Annual Salary' FROM employees; - This option is incorrect because it uses single quotes (' ') to define the alias. In SQL, single quotes are used to define string literals, not column aliases.

Option B) SELECT ename, salary*12 "Annual Salary" FROM employees; - This option is correct because it uses double quotes (" ") to define the alias. In SQL, double quotes are used to define column aliases. Therefore, the alias "Annual Salary" is correctly generated for the calculated column salary*12.

Option C) SELECT ename, salary*12 AS Annual Salary FROM employees; - This option is incorrect because it uses the keyword AS without double quotes to define the alias. In SQL, the AS keyword is used to define aliases, but the alias itself should be enclosed in double quotes.

Option D) SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees - This option is incorrect because it uses the INITCAP function within the alias definition. The INITCAP function is used to capitalize the first letter of each word in a string. It is not necessary in this case, as the alias "Annual Salary" does not require any special formatting.

The correct answer is B) B. SELECT ename, salary*12 "Annual Salary" FROM employees. This option correctly generates the alias "Annual Salary" for the calculated column salary*12.

Which SQL statement accepts user input for the columns to be displayed, the table name, and the WHERE condition? A. SELECT &1, "&2" FROM &3 WHERE last_name = '&4'; B. SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4''; C. SELECT &1, &2 FROM &3 WHERE last_name = '&4'; D. SELECT &1, '&2' FROM EMP WHERE last_name = '&4';

  1. A

  2. B

  3. C

  4. D


Correct Option: C

AI Explanation

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

Option A) SELECT &1, "&2" FROM &3 WHERE last_name = '&4'; This option is incorrect because it does not properly handle the user input. The column names, table name, and WHERE condition should be replaced using placeholders (&1, &2, &3, &4), but the WHERE condition is using a string literal ('&4') instead of a placeholder.

Option B) SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4''; This option is incorrect because it also does not properly handle the user input. The WHERE condition is using a string literal ('&last_name = '&4'') instead of a placeholder. Additionally, there is a syntax error with an extra single quote before 'last_name'.

Option C) SELECT &1, &2 FROM &3 WHERE last_name = '&4'; This option is correct because it properly handles the user input. The column names, table name, and WHERE condition are replaced using placeholders (&1, &2, &3, &4). The WHERE condition also uses a placeholder for the user input.

Option D) SELECT &1, '&2' FROM EMP WHERE last_name = '&4'; This option is incorrect because it does not allow the user to input the table name. The table name is hardcoded as 'EMP'.

The correct answer is C. This option is correct because it accepts user input for the columns to be displayed, the table name, and the WHERE condition using placeholders.

In which scenario would an index be most useful? A. The indexed column is declared as NOT NULL. B. The indexed columns are used in the FROM clause. C. The indexed columns are part of an expression. D. The indexed column contains a wide range of values.

  1. A

  2. B

  3. C

  4. D


Correct Option: D

AI Explanation

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

Option A) The indexed column is declared as NOT NULL - This option is incorrect because declaring a column as NOT NULL does not necessarily make an index more useful. A NOT NULL constraint ensures that the column cannot have null values, but it does not directly affect the usefulness of an index.

Option B) The indexed columns are used in the FROM clause - This option is incorrect because using indexed columns in the FROM clause does not necessarily make an index more useful. The FROM clause is used to specify the tables from which to retrieve data, and while indexes can be used to optimize the retrieval of data, using indexed columns in the FROM clause alone does not guarantee the usefulness of an index.

Option C) The indexed columns are part of an expression - This option is incorrect because having indexed columns as part of an expression does not necessarily make an index more useful. While indexes can be used to optimize the evaluation of expressions, having indexed columns as part of an expression alone does not guarantee the usefulness of an index.

Option D) The indexed column contains a wide range of values - This option is correct because when the indexed column contains a wide range of values, an index can be more useful. Indexes are particularly effective when the indexed column has a large number of distinct values. A wide range of values in the indexed column allows for better selectivity, meaning that the index can filter out a larger portion of the data, resulting in improved query performance.

The correct answer is D. The indexed column contains a wide range of values. This option is correct because having a wide range of values in the indexed column makes an index more useful.

Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"? A. SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual; B. SELECT TO_DATE(SYSDATE,'yyyy') FROM dual; C. SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY') FROM dual; D. SELECT DECODE(SUBSTR(SYSDATE, 8), 'year') FROM dual; E. SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy') FROM dual;

  1. A

  2. B

  3. C

  4. D

  5. E


Correct Option: A

Which are iSQL*Plus commands? A. INSERT B. UPDATE C. SELECT D. DESCRIBE E. DELETE F. RENAME

  1. A

  2. B

  3. C

  4. D

  5. E

  6. F


Correct Option: D

Which standalone utility is used to Preformat the Active Log

  1. DSNJU003

  2. DSNJLOGF

  3. DSN1LOGP

  4. DSN1SDMP


Correct Option: B

Which standalone utility is used to modify the BSDS(BootStrap DataSet)?

  1. DSNJLOGF

  2. DSN1CHKR

  3. DSNJU003

  4. DSNJ004


Correct Option: C

Which standalone utility can be used to list System and Utility timestamps, Contents of Quiesce history record, active Log datasets available etc.

  1. DSN1LOGP

  2. DSNJU003

  3. DSNJU004

  4. DSNJLOGF


Correct Option: C

Which standalone Utility verifies the Integrity of DB2 directory and Catalog

  1. DSN1SDMP

  2. DSN1LOGP

  3. DSN1COMP

  4. DSN1CHKR


Correct Option: D

Which Utility is used to estimate space savings to be achieved by DB2 Data compression in tablespaces?

  1. DSN1COMP

  2. DSN1CHKR

  3. DSN1COPY

  4. DSN1SDMP


Correct Option: A

Which standalone utility can be used to move data between subsystems by translating OBID, PSID and DBID?

  1. DSN1COMP

  2. DSN1PRNT

  3. DSN1SDMP

  4. DSN1COPY


Correct Option: D

Which standalone utility can be used to move data between subsystems by translating OBID, PSID and DBID?

  1. DSN1COMP

  2. DSN1PRNT

  3. DSN1SDMP

  4. DSN1COPY


Correct Option: D

Which standalone utility used to format the contents of the recovery log for display?

  1. DSNJLOGF

  2. DSN1LOGP

  3. DSN1PRNT

  4. DSN1SDMP


Correct Option: B

Which standalone utility can be used to identify the contents of a tablespace, index or Image copy datasets?

  1. DSN1PRNT

  2. DSN1SDMP

  3. DSN1LOGP

  4. DSN1COMP


Correct Option: A

Which standalone utility trace the events to occur and force a dump to a user defined dataset?

  1. DSN1PRNT

  2. DSN1COPY

  3. DSN1CHKR

  4. DSN1SDMP


Correct Option: D
- Hide questions