Skip to content

Instantly share code, notes, and snippets.

@tmuth
Last active August 29, 2015 14:01
Show Gist options
  • Save tmuth/99bb96faa9a31a500244 to your computer and use it in GitHub Desktop.
Save tmuth/99bb96faa9a31a500244 to your computer and use it in GitHub Desktop.
orcl datapump import > grep for object counts
# Use impdp to write DDL of an export out to a file.
# In this case, the source was SQLT > SQL Test Case Builder
impdp system/password@//localhost:1521/noncdb directory=TCB_IMP_DIR dumpfile=sqlt_s83913_tcb_dpexp.dmp TRANSFORM=SEGMENT_ATTRIBUTES:n sqlfile=objects.sql
# Note there are lots of filters you could apply to impdp to target just schemas and/or object types, etc
# Lets get an idea of the schemas referenced in the export:
grep -ioE "\"[[:alnum:]]{1,30}\"\." objects.sql | sort |uniq -c
# Count of objects by schema:
grep -iEo "^create (type|package|table|function|force view|procedure|index|unique index|database link|synonym|materialized view) \"[[:alnum:]]{1,30}\"\." objects.sql | grep -ioE "\"[[:alnum:]]{1,30}\"\." | sort | uniq -c
# Count of objects by type:
grep -iEo "^create (type|package|table|function|force view|procedure|index|unique index|database link|synonym|materialized view)" objects.sql | sort | uniq -c
# Find hints in SQL
grep -oE --color "/\*\+.+?\*\/" objects.sql
# Find hints, then group by hint and count
grep -oE --color "/\*\+.+?\*\/" objects.sql | sort | uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment