Describe table with user-defined type as column type : Describe Type « Object Oriented « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Object Oriented » Describe Type 
32. 21. 2. Describe table with user-defined type as column type
SQL>
SQL> create table course_schedule
  2  course     VARCHAR2(6)
  3  , begindate  DATE
  4  , trainer    NUMBER(4)
  5  , location   VARCHAR2(20)) ;

Table created.

SQL>
SQL>
SQL> insert into course_schedule values ('SQL',date '1999-04-12',1,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('OAU',date '1999-08-10',2,'CHICAGO');

row created.

SQL> insert into course_schedule values ('SQL',date '1999-10-04',3,'SEATTLE');

row created.

SQL> insert into course_schedule values ('SQL',date '1999-12-13',4,'DALLAS' );

row created.

SQL> insert into course_schedule values ('JAV',date '1999-12-13',5,'SEATTLE');

row created.

SQL> insert into course_schedule values ('XML',date '2000-02-03',6,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('JAV',date '2000-02-01',7,'DALLAS' );

row created.

SQL> insert into course_schedule values ('PLS',date '2000-09-11',8,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('XML',date '2000-09-18',NULL,'SEATTLE');

row created.

SQL> insert into course_schedule values ('OAU',date '2000-09-27',9,'DALLAS' );

row created.

SQL> insert into course_schedule values ('ERM',date '2001-01-15',10, NULL    );

row created.

SQL> insert into course_schedule values ('PRO',date '2001-02-19',NULL,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('RSD',date '2001-02-24',8,'CHICAGO');

row created.

SQL>
SQL>
SQL>
SQL> create type addressType as object
  2  street varchar2(20)
  3  , nr     varchar2(5)
  4  , pcode  varchar2(6)
  5  , city   varchar2(20)
  6  ;
  7  /

Type created.

SQL>
SQL> describe addressType
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 STREET                                             VARCHAR2(20)
 NR                                                 VARCHAR2(5)
 PCODE                                              VARCHAR2(6)
 CITY                                               VARCHAR2(20)

SQL>
SQL> select type_name, typecode from user_types;

TYPE_NAME                      TYPECODE
------------------------------ ------------------------------
DEBUG_O                        OBJECT
NUMBERLIST_T                   COLLECTION
ADDRESS2                       OBJECT
ZIP_CODE                       OBJECT
NUM_VARRAY                     COLLECTION
NUM_TABLE                      COLLECTION
ADD_LIST                       COLLECTION
HOME_ADD_LIST                  COLLECTION
SYS_PLSQL_14797_54_1           COLLECTION
SYS_PLSQL_14797_DUMMY_1        COLLECTION
SYS_PLSQL_14797_9_1            OBJECT
VCARRAY                        COLLECTION
STRINGS_NT                     COLLECTION
RIVER                          OBJECT
WATERFALL                      OBJECT
SQLMONTH_TABLETYPE             COLLECTION
ORD_TYPE                       OBJECT
ORD_TABLE                      COLLECTION
DTARRAY                        COLLECTION

TYPE_NAME                      TYPECODE
------------------------------ ------------------------------
NMARRAY                        COLLECTION
EMP_T                          OBJECT
ASCII_TABLE_TYPE               OBJECT
PHONE_NUM_REC_TYPE             OBJECT
NUMBERVARRAY                   COLLECTION
ADDRESSTYPE                    OBJECT

25 rows selected.

SQL>
SQL> create table o
  2  as
  3  select course, begindate, trainer
  4  from   course_schedule;

Table created.

SQL>
SQL> alter table o add (address addressType);

Table altered.

SQL>
SQL> set describe depth 1
SQL> describe o
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 COURSE                                             VARCHAR2(6)
 BEGINDATE                                          DATE
 TRAINER                                            NUMBER(4)
 ADDRESS                                            ADDRESSTYPE

SQL> set describe depth 2
SQL> describe o
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 COURSE                                             VARCHAR2(6)
 BEGINDATE                                          DATE
 TRAINER                                            NUMBER(4)
 ADDRESS                                            ADDRESSTYPE
   STREET                                           VARCHAR2(20)
   NR                                               VARCHAR2(5)
   PCODE                                            VARCHAR2(6)
   CITY                                             VARCHAR2(20)

SQL>
SQL> drop view o;
drop view o
*
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> drop table o;

Table dropped.

SQL> drop type addressType force;

Type dropped.

SQL> drop table course_schedule;

Table dropped.

SQL>
SQL>

SQL>
32. 21. Describe Type
32. 21. 1. Describe a type
32. 21. 2. Describe table with user-defined type as column type
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.