Tag: databases

Questions Related to databases

Select the best answer PACKAGE foo_foo IS PROCEDURE foo ( p_foo_text IN VARCHAR2 ); PROCEDURE foo (p_foo_number IN NUMBER); END;

  1. Package specification is invalid. Too many procedures named foo.

  2. Package specification is invalid. First procedure should be called called foo_1, second procedure should be called foo_2.

  3. Package specification is valid. This is an example of overloading.

  4. Package specification is invalid. We can only have one procedure named foo in the package

  5. Package specification is valid. We can have an unlimited number of procedures name foo.

  6. None of the above


Correct Option: C
  1. INITIALIZE, GET, CLOSE

  2. OPEN, FETCH, CLOSE

  3. CURSOR, GET, FETCH, CLOSE

  4. CURSOR, FETCH, CLOSE

  5. GET, SEEK, HIDE

  6. None of the above.


Correct Option: B
Explanation:

To process a set of records using explicit cursors, the correct sequence of commands is:

B. OPEN, FETCH, CLOSE

Explanation:

  • The first step is to declare a cursor, which is typically done outside of the sequence of commands listed in the question. The cursor declaration specifies the SELECT statement that defines the result set to be processed.
  • The next step is to open the cursor using the OPEN command. This prepares the result set for processing.
  • The FETCH command is then used to retrieve each record in the result set one at a time. This command is usually used in a loop, where processing is performed on each record as it is retrieved.
  • Finally, the CLOSE command is used to release the resources associated with the cursor.

Therefore, the correct answer is:

The Answer is: B. OPEN, FETCH, CLOSE

  1. VARCHAR2

  2. VARCHAR1

  3. CHAR

  4. CHAR2

  5. INTEGER

  6. NUMBER


Correct Option: B,D

SELECT ROUND (-123.39953,-2) FROM DUAL;

  1. -123.40

  2. -100

  3. -120

  4. -123.30


Correct Option: B

SELECT ROUND(-123.39953,-3) FROM DUAL;

  1. 0

  2. 100

  3. 123

  4. -123


Correct Option: A

AI Explanation

To answer this question, we need to understand the ROUND function in SQL.

The ROUND function is used to round a number to a specified number of decimal places or to the nearest whole number. It takes two arguments: the number to be rounded and the number of decimal places to round to.

In this case, the number to be rounded is -123.39953 and the number of decimal places to round to is -3.

When rounding to -3 decimal places, we are rounding to the nearest thousands place.

The correct answer is A) 0.

This is because -123.39953, when rounded to the nearest thousands place, becomes 0.

How many columns are presented after executing this query: SELECT address1||','||address2||','||address2 "Adress" FROM employee;

  1. 1

  2. 2

  3. 3

  4. 0

  5. 4


Correct Option: C

AI Explanation

To determine the number of columns presented after executing the given query, let's break down the query and analyze it step by step:

The query is: SELECT address1||','||address2||','||address2 "Adress" FROM employee;

Here, we are selecting three columns: address1, address2, and address2 (renamed as "Address" using the alias "Adress"). Each column is concatenated with a comma (',').

So, the query will produce three columns: address1, address2, and Address.

Therefore, the correct answer is C) 3.

  1. Primary key access

  2. Access via unique index

  3. Table access by ROWID

  4. Full table scan


Correct Option: C
  1. ALTER TABLE students ADD PRIMARY KEY student_id;

  2. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);

  3. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;

  4. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

  5. ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);


Correct Option: D