Which two are true about INDEX-BY tables? (Choose two.)
Which two are true about INDEX-BY tables? (Choose two.)
INDEX-BY tables in PL/SQL, also known as associative arrays, must use an integer index. They cannot be created with the CREATE TYPE statement; they can only be defined within PL/SQL blocks. The index must be an integer, and not a string, making the options that state so incorrect.
A $ C ARE CORRECT
A and C are TRUE!
A AND D , C IS NOT BEC (ONLYE)
A.C TESTED
My bad, didn't check. D is not true. Checked in Oracle DB 12.1.0.2.0 Compilation errors for TYPE APPS.PHONEBOOK Error: PLS-00355: use of pl/sql table not allowed in this context Line: 1 Text: CREATE OR REPLACE TYPE PhoneBook AS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER Error: PL/SQL: Compilation unit analysis terminated Line: 1 Text: CREATE OR REPLACE TYPE PhoneBook AS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER A and C is true.
A and D. You can create type INDEX BY, example from ChatGPT: CREATE TYPE PhoneBook AS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER; After creating this type, you can use it to declare variables or columns in tables. For instance, you might use it within PL/SQL code like this: DECLARE -- Declare a variable of type PhoneBook myContacts PhoneBook; BEGIN -- Assign values to the INDEX-BY table myContacts(1) := 'John Doe'; myContacts(2) := 'Jane Smith'; -- Accessing elements DBMS_OUTPUT.PUT_LINE('First contact: ' || myContacts(1)); DBMS_OUTPUT.PUT_LINE('Second contact: ' || myContacts(2)); END;
Livesql CREATE TYPE PhoneBook AS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER; Errors: TYPE PHONEBOOK Line/Col: 0/0 PL/SQL: Compilation unit analysis terminated Line/Col: 1/19 PLS-00355: use of pl/sql table not allowed in this context
D is not correct, we can't create index by table in the database, only varray and nested table can create in database.