Create a table based on user-defined object only : Object Table « Object Oriented Database « Oracle PL / SQL






Create a table based on user-defined object only

   
SQL>
SQL> create or replace
  2  type person as object (
  3   first_name varchar2(100),
  4   last_name varchar2(100),
  5   dob date,
  6   phone varchar2(100),
  7   member function get_last_name return varchar2,
  8   member function get_phone_number return varchar2 )
  9  not final
 10  /

Type created.

SQL>
SQL>
SQL> create or replace
  2  type body person as
  3    member function get_last_name return varchar2 is
  4    begin
  5      return self.last_name;
  6    end;
  7    member function get_phone_number return varchar2 is
  8    begin
  9      return self.phone;
 10    end;
 11  end;
 12  /

Type body created.

SQL>
SQL> create table person_table( p person );

Table created.

SQL>
SQL>
SQL> drop table person_table;

Table dropped.

   
    
  








Related examples in the same category

1.Crate table with object column
2.Use a table alias and the name of the object
3.Create table with user defined type as column
4.Create a table with user define varray as column type
5.Create a table with nested user defined type as column
6.Object table: a table of type
7.Use user-defined varray type as column type
8.Nested table
9.Implementation of many to many using object references
10.Implementation of multiple inheritance relationship
11.Implementation of one to many using object references
12.Create table based on single data type
13.Create table with nested types
14.Create type and use it as table column
15.One to one using object references
16.Use user-defined type to combine query logic
17.Create a new type and add it to a table
18.Multilevel aggregation relationships using nested tables