In addition to the previous answer, there are significant differences in the scope of the declaration.
When you declare a type in PL / SQL, for example the record type in your example, it can only be used for PL / SQL. If it is declared locally to a procedure or function, then it can only be used in this routine; if it is declared in the package body, it can only be used in this package; if it is declared in the package header, it can be used by any PL / SQL code that has access to the package. In no case can you refer to SQL statements, even built-in PL / SQL code .
When creating an object type or other schema level type definitions, such as nested tables, it can be used in both SQL and PL / SQL. As a very simple example, you can define a table definition in an object definition:
SQL> CREATE OR REPLACE TYPE "TYPE_NAME1" AS OBJECT 2 ( 3 temp_trans_id number(10), 4 trans_id number(10), 5 resion_id number(10) 6 ) 7 / Type created. SQL> create table type_name1_tab of type_name1; Table created. SQL> desc type_name1_tab Name Null? Type ----------------------------------------- -------- ---------------------------- TEMP_TRANS_ID NUMBER(10) TRANS_ID NUMBER(10) RESION_ID NUMBER(10)
see here for documentation of the CREATE TYPE statement and links to additional documentation on the various uses of object types.
source share