3

Suppose I have a user defined type:

CREATE OR REPLACE TYPE TEST_TYPE AS OBJECT
( 
    f1 varchar2(10),
    f2 number(5)
);

Now, I want to create a table to hold these types. I can do the following:

create table test_type_table (
    test_type_field test_type
);

This gives me a table with one column, test_type_field.

Is there an easy and automated way to instead create a table such that it has 2 columns, f1 and f2?. So that it's the equivilent to writing:

create table test_type_table (
    f1 varchar2(10),
    f2 number(5)
);
Glen
  • 21,816
  • 3
  • 61
  • 76

1 Answers1

6

Have you tried:

create table test_type_table of test_type;
Thomas Padron-McCarthy
  • 27,232
  • 8
  • 51
  • 75
  • @Thomas, no, I hadn't, but I really should have. Guess I'm having a slow morning – Glen Mar 12 '10 at 11:31
  • For TSQL, see http://stackoverflow.com/questions/22390358/create-sql-server-table-based-on-a-user-defined-type – Stan Jul 02 '15 at 13:40