Results 1 to 2 of 2

Thread: Table->Script

  1. #1
    Join Date
    Jul 2003
    Posts
    1

    Unanswered: Table->Script

    Hi All!
    Lets say I have a table with properties and info.
    Is it possible to create an sql script from it ?

    TIA
    Guy

  2. #2
    Join Date
    Jul 2002
    Location
    Beijing . China
    Posts
    9
    exp/imp

    or use GET_DDL

    SQL> select dbms_metadata.get_ddl('TABLE','EMP') FROM DUAL;

    DBMS_METADATA.GET_DDL('TABLE','EMP')
    ----------------------------------------------------------------------------


    CREATE TABLE "SCOTT"."EMP"
    ( "EMPNO" NUMBER(4,0),
    "ENAME" VARCHAR2(10),


    SQL> SET LONG 10000
    SQL> /

    DBMS_METADATA.GET_DDL('TABLE','EMP')
    ----------------------------------------------------------------------------


    CREATE TABLE "SCOTT"."EMP"
    ( "EMPNO" NUMBER(4,0),
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
    CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")

    DBMS_METADATA.GET_DDL('TABLE','EMP')
    ----------------------------------------------------------------------------

    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "SYSTEM" ENABLE,
    CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
    ) PCTFREE 40 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"


    DBMS_METADATA.GET_DDL('TABLE','EMP')
    ----------------------------------------------------------------------------



    SQL> SHOW USER
    USER is "SCOTT"
    SQL> SELECT * FROM V$VERSION;

    BANNER
    ----------------------------------------------------------------
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE 9.2.0.1.0 Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production

    SQL>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •