oracle导出表指定字段的ddl,Oracle 导出 某用户 DDL脚本

set arraysize 1

set echo off

set heading off

set feedback off

set verify off

set pagesize 0

set linesize 79

define 1 = &&SCHEMA_NAME

spool tbl_&&SCHEMA_NAME

set termout off

col x noprint

col y noprint

select  'rem   ****    Create Table DDL for '||chr(10)||

'rem   ****    '||username||''''||'s tables'||chr(10)||chr(10)

from    dba_users

where     username      = upper ('&&1')

/

select  table_name y,

0 x,

'create table ' ||

rtrim(table_name) ||

'('

from    dba_tables

where     owner = upper('&&1')

union

select  tc.table_name y,

column_id x,

rtrim(decode(column_id,1,null,','))||

rtrim(column_name)|| ' ' ||

rtrim(data_type) ||

rtrim(decode(data_type,'DATE',null,'LONG',null,

'NUMBER',decode(to_char(data_precision),null,null,'('),

'(')) ||

rtrim(decode(data_type,

'DATE',null,

'CHAR',data_length,

'VARCHAR2',data_length,

'NUMBER',decode(to_char(data_precision),null,null,

to_char(data_precision) || ',' || to_char(data_scale)),

'LONG',null,

'******ERROR')) ||

rtrim(decode(data_type,'DATE',null,'LONG',null,

'NUMBER',decode(to_char(data_precision),null,null,')'),

')')) || ' ' ||

rtrim(decode(nullable,'N','NOT NULL',null))

from    dba_tab_columns tc,

dba_objects o

where   o.owner = tc.owner

and     o.object_name = tc.table_name

and     o.object_type = 'TABLE'

and     o.owner = upper('&&1')

union

select  table_name y,

999999 x,

')'  || chr(10)

||' STORAGE('                           || chr(10)

||' INITIAL '    || initial_extent      || chr(10)

||' NEXT '       || next_extent         || chr(10)

||' MINEXTENTS ' || min_extents         || chr(10)

||' MAXEXTENTS ' || max_extents         || chr(10)

||' PCTINCREASE '|| pct_increase        || ')' ||chr(10)

||' INITRANS '   || ini_trans         || chr(10)

||' MAXTRANS '   || max_trans         || chr(10)

||' PCTFREE '    || pct_free          || chr(10)

||' PCTUSED '    || pct_used          || chr(10)

||' PARALLEL (DEGREE ' || DEGREE || ') ' || chr(10)

||' TABLESPACE ' || rtrim(tablespace_name) ||chr(10)

||'/'||chr(10)||chr(10)

from    dba_tables

where   owner = upper('&&1')

order by 1,2

/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值