Which two statements are true about nested tables and varrays? (Choose two.)
A.
Only varrays must have consecutive numbers as subscripts.
B.
Only nested tables can be used as column types in database tables.
C.
Both nested tables and varrays must have consecutive numbers as subscripts.
D.
Both nested tables and varrays can be used as column types in database tables.
When someone writes an paragraph he/she retains the image of a user in his/her mind that
how a user can be aware of it. So that’s why
this paragraph is outstdanding. Thanks!
A, D.
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/collections.htm
A:
Nested tables might not have consecutive subscripts, while arrays are always dense (have consecutive subscripts). Initially, nested tables are dense, but they can become sparse (have nonconsecutive subscripts). You can delete elements from a nested table using the built-in procedure DELETE. The built-in function NEXT lets you iterate over all the subscripts of a nested table, even if the sequence has gaps.
D:
Understanding PL/SQL Collections
PL/SQL offers these collection types:
Associative arrays, also known as index-by tables, let you look up elements using arbitrary numbers and strings for subscript values. These are similar to hash tables in other programming languages.
Nested tables hold an arbitrary number of elements. They use sequential numbers as subscripts. You can define equivalent SQL types, allowing nested tables to be stored in database tables and manipulated through SQL.
Varrays (short for variable-size arrays) hold a fixed number of elements (although you can change the number of elements at runtime). They use sequential numbers as subscripts. You can define equivalent SQL types, allowing varrays to be stored in database tables. They can be stored and retrieved through SQL, but with less flexibility than nested tables.
C , D
HI GUYS ??
WHAT DOES IT MEANS
BOTH VARRAY AND NESTED TABLES MUST HAVE CONSECUTIVE NUMBER AS SUBSCRPTS…
YES, FOR NESTED TABLE, INTERNAL SUBSCRIT COULD BE DELETED SO BE EMPTY,
BUT ARE ALWAYS CONSECUTIVE …..
WHAT DOES IT MEANS CONSECUTIVE PLEASE ?
declare
type t_tn is table of number;
tn t_tn := t_tn(7,7,7);
begin
tn.delete(2);
if tn.exists(3) then
dbms_output.put_line(‘3 exists’);
end if;
if tn.exists(2) then
dbms_output.put_line(‘2 exists’);
end if;
end;