ORACLE匯出表結構指令碼

來源:互聯網
上載者:User

標籤:

select  case when r = 1 then (select s.COMMENTS from user_tab_comments s where Table_Name= aa.table_name) else ‘‘ end as table_comments,  case when r = 1 then aa.table_name else ‘‘ end as table_name,  aa.r as column_sequence,  aa.COLUMN_NAME,  aa.DATA_TYPE,  aa.data_length,  (select ‘Y‘from user_cons_columns cu, user_constraints auwhere cu.constraint_name = au.constraint_name and au.constraint_type = ‘P‘   and au.table_name = aa.table_name  and cu.COLUMN_NAME = aa.COLUMN_NAME) as IS_PK,  aa.NULLABLE,  aa.DATA_DEFAULT,  aa.column_commentsfrom(select  row_number() over(partition by t.OBJECT_NAME order by t.OBJECT_NAME) r,        t.OBJECT_NAME as table_name,        c.COLUMN_NAME,        c.DATA_TYPE,        case when c.NULLABLE = ‘N‘ then ‘NOT NULL‘ else ‘‘ end as NULLABLE,        case when c.DATA_TYPE in (‘NVARCHAR2‘,‘CHAR‘,‘VARCHAR2‘) then to_char(c.CHAR_LENGTH)             when c.DATA_TYPE in (‘LONG‘,‘FLOAT‘,‘CLOB‘,‘BLOB‘,‘DATE‘)then ‘ ‘             when c.DATA_TYPE = ‘NUMBER‘ then                case when c.DATA_PRECISION is null and c.DATA_SCALE = 0 then                 ‘INTEGER‘                 else                 rtrim(c.DATA_PRECISION ||‘,‘|| c.DATA_SCALE,‘,‘)                 end             else ‘ ‘ end as data_length,        cc.COMMENTS as column_comments,        c.DATA_DEFAULTfrom user_objects t,     user_tab_columns  c,     user_col_comments ccwhere t.OBJECT_TYPE = ‘TABLE‘   and c.TABLE_NAME = t.OBJECT_NAME  and cc.TABLE_NAME = c.TABLE_NAME  and cc.COLUMN_NAME = c.COLUMN_NAME) aa;

 

ORACLE匯出表結構指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.