Chinaunix首页 | 论坛 | 博客
  • 博客访问: 970380
  • 博文数量: 358
  • 博客积分: 8185
  • 博客等级: 中将
  • 技术积分: 3751
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:27
个人简介

The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.

文章分类

全部博文(358)

文章存档

2012年(8)

2011年(18)

2010年(50)

2009年(218)

2008年(64)

我的朋友

分类: Oracle

2009-02-10 00:00:31

DBMS_METADATA package can be conveniently used to get the DDL of all tables and indexes in a schema. The sample syntax is as follows:


set pagesize 0
set long 90000
set feedback off
set echo off
spool ddl.txt
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name, 'MY_SCHEMA') || '/'
FROM dba_tables u
where owner='MY_SCHEMA';


SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name, 'MY_SCHEMA') || '/'
FROM dba_INDEXES u
where owner='MY_SCHEMA';
spool off;

SQL> set pagesize 200
SQL> set long 1000
SQL> select dbms_metadata.get_ddl('TABLE','EMPLOYEES') FROM dual;

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

  CREATE TABLE "STORE"."EMPLOYEES"
   (    "EMPLOYEE_ID" NUMBER(*,0),
        "MANAGER_ID" NUMBER(*,0),
        "FIRST_NAME" VARCHAR2(10) NOT NULL ENABLE,
        "LAST_NAME" VARCHAR2(10) NOT NULL ENABLE,
        "TITLE" VARCHAR2(20),
        "SALARY" NUMBER(6,0),
         CONSTRAINT "EMPLOYEES_PK" PRIMARY KEY ("EMPLOYEE_ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "USERS"  ENABLE
   ) PCTFREE 10 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"

阅读(644) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~