Sunday, June 9, 2013

Script to get table Description

DECLARE
   l_table_script   CLOB;

   CURSOR c1
   IS
      SELECT object_name
        FROM dba_objects
       WHERE object_name LIKE 'XXX% AND object_type = 'TABLE';
BEGIN
   FOR i IN c1
   LOOP
      l_table_script := NULL;

      SELECT DBMS_METADATA.GET_DDL ('TABLE', i.object_name)
        INTO l_table_script
        FROM DUAL;

      DBMS_OUTPUT.put_line (l_table_script);
   END LOOP;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      NULL;
   WHEN OTHERS
   THEN
      NULL;
END;

No comments:

Post a Comment