Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Exporting a report on tables' structure in Oracle

Exporting a report on tables' structure in Oracle

Scheduled Pinned Locked Moved Database
databaseoraclecomtestingtools
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muammar
    wrote on last edited by
    #1

    Hey everyone, I'm using Oracle 10.2g with PL/SQL Developer 7.1 from Allround Automation and I want to list my tables one by one showing each detailing its fields.. Any simple way to do this?? Many thanks!


    We will either find a way, or make one!   (\ /)   (- .-) C(''')(''')

    D J 2 Replies Last reply
    0
    • M Muammar

      Hey everyone, I'm using Oracle 10.2g with PL/SQL Developer 7.1 from Allround Automation and I want to list my tables one by one showing each detailing its fields.. Any simple way to do this?? Many thanks!


      We will either find a way, or make one!   (\ /)   (- .-) C(''')(''')

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      The only way I've done it in the past was write some PL/SQL code that would loop through tabels like: SELECT * FROM ALL_TABLES WHERE OWNER='myOwner ORDER BY TABLE_NAME;

      M 1 Reply Last reply
      0
      • D David Mujica

        The only way I've done it in the past was write some PL/SQL code that would loop through tabels like: SELECT * FROM ALL_TABLES WHERE OWNER='myOwner ORDER BY TABLE_NAME;

        M Offline
        M Offline
        Muammar
        wrote on last edited by
        #3

        Exactly what I've done

        CREATE OR REPLACE VIEW schema_tables AS
        SELECT o.object_type AS object_type
        , c.table_name AS table_name
        , c.column_id AS column_id
        , c.column_name AS column_name
        , DECODE(c.nullable,'N','NOT NULL','') AS nullable
        , DECODE(c.data_type
        , 'BFILE' ,'BINARY FILE LOB'
        , 'BINARY_FLOAT' ,c.data_type
        , 'BINARY_DOUBLE',c.data_type
        , 'BLOB' ,c.data_type
        , 'CLOB' ,c.data_type
        , 'CHAR' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'DATE' ,c.data_type
        , 'FLOAT' ,c.data_type
        , 'LONG RAW' ,c.data_type
        , 'NCHAR' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'NVARCHAR2' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'NUMBER' ,DECODE(NVL(c.data_precision||c.data_scale,0)
        , 0,c.data_type
        , DECODE(NVL(c.data_scale,0),0
        , c.data_type||'('||c.data_precision||')'
        , c.data_type||'('||c.data_precision||','|| c.data_scale||')'))
        , 'RAW' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'VARCHAR' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'VARCHAR2' ,DECODE(NVL(c.data_length,0),0,c.data_type
        , c.data_type||'('||c.data_length||')')
        , 'TIMESTAMP' , c.data_type,c.data_type) AS data_type
        , CASE WHEN c.data_default IS NULL THEN 'N' ELSE 'Y' END AS data_default
        FROM user_tab_columns c,user_objects o
        WHERE o.object_name = c.table_name
        ORDER BY c.table_name, c.column_id
        /
        set feed off markup html on spool on
        /
        spool 'c:\filename.htm'
        /
        select * from schema_tables
        /
        spool off
        /
        set markup html off spool off
        /


        We will either find a way, or make one!   (\ /)   (- .-) C(''')(''')

        1 Reply Last reply
        0
        • M Muammar

          Hey everyone, I'm using Oracle 10.2g with PL/SQL Developer 7.1 from Allround Automation and I want to list my tables one by one showing each detailing its fields.. Any simple way to do this?? Many thanks!


          We will either find a way, or make one!   (\ /)   (- .-) C(''')(''')

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #4

          Use:

          dbms_metadata.get_ddl(
          object_type IN VARCHAR2,
          name IN VARCHAR2,
          schema IN VARCHAR2 DEFAULT NULL,
          version IN VARCHAR2 DEFAULT 'COMPATIBLE',
          model IN VARCHAR2 DEFAULT 'ORACLE',
          transform IN VARCHAR2 DEFAULT 'DDL')
          RETURN CLOB;

          Example:

          SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
          FROM USER_TABLES u;

          SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name)
          FROM USER_INDEXES u;

          Gives you all the tables and indexes for the logged in user.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups