Saturday, February 1, 2014

Create Table Using Object Type In Oracle Database.

Note :- In Oracle database we can create table using object type.

SQL> CREATE TYPE TY_EMPLOYEES
  2  AS OBJECT
  3  ( EMP_ID NUMBER,
  4    EMP_NAME VARCHAR2(300),
  5    STREET VARCHAR2(10),
  6    CITY   VARCHAR2(200),
  7    SALARY NUMBER(6),
  8    JOINING_DATE DATE
  9  )
 10  /

Type created.

SQL> CREATE TABLE EMPLOYEES OF TY_EMPLOYEES;

Table created.

SQL> INSERT INTO EMPLOYEES(EMP_ID, EMP_NAME, STREET, CITY, SALARY, JOINING_DATE)
  2  VALUES(100,'RAJIB','DHAKA','DHAKA',5000,SYSDATE);

1 row created.

SQL> SELECT * FROM EMPLOYEES;

    EMP_ID
----------
EMP_NAME
--------------------------------------------------------------------------------
STREET
----------
CITY
--------------------------------------------------------------------------------
    SALARY JOINING_D
---------- ---------
       100
RAJIB
DHAKA

    EMP_ID
----------
EMP_NAME
--------------------------------------------------------------------------------
STREET
----------
CITY
--------------------------------------------------------------------------------
    SALARY JOINING_D
---------- ---------
DHAKA
      5000 02-FEB-14


SQL>

No comments:

Post a Comment