rem 
rem $Header: sql.bsq 31-aug-99.18:44:45 kosinski Exp $ sql.bsq 
rem 
rem  MODIFIED
rem   vpesati    08/09/99 - change comment for col property
rem   kosinski   08/13/99 - Bug 822440: Add PLS_TYPE to *_ARGUMENT$
rem   vpesati    06/28/99 - modify comment for col property
rem   rshaikh    06/17/99 - sql version                                        
rem   nvishnub   04/19/99 - Add index on expdepobj$ for parent object.
rem   qyu        03/04/99 - add CACHE READS lob mode
rem   susingh    03/02/99 - Add indexes for improving performance. BUG 574099
rem   arrajara   03/01/99 - add index on sys.reg_snap$(snapshot_id)
rem   rshaikh    01/21/99 - add longdbcs to javasnm
rem   sbodagal   12/03/98 - change privileges of outln
rem   masubram   11/17/98 - code review comments                               
rem   weiwang    11/06/98 - add privilege ADMINISTER DATABASE TRIGGER
rem   masubram   10/13/98 - store filter, equijoin bitvectors in snap_reftime
rem   mziauddi   09/22/98 - change priv keyword REWRITE ==> QUERY REWRITE
rem   sbedarka   10/09/98 -  #(725220) set maxvalue cycle for ora_tq_base$ sequ
rem   avaradar   09/15/98 - modify comment for col$.property  
rem   sbasu      09/01/98 - make deftiniexts, defextsize, defminexts, defmaxexts and 
rem                         defextpct columns in PARTOBJ$ nullable so we can represent
rem			    absence of specified default values by storing NULL's 
rem   kmuthiah   09/21/98 -  added 0x00200000 to property flag in col$
rem   amozes     09/22/98 - reserve flag in hist_head                       
rem   akruglik   08/24/98 - modify comment for TAB$.FLAGS                      
rem   syeung     08/18/98 - make [tab|ind]compart$.dataobj# nullable and insert
rem                         NULL to them 
rem   nagarwal   08/17/98 - add 204 & 212 to SYSTEM_PRIVILEGE_MAP
rem   attran     08/11/98 - PIOT:change column dataobj# of tabpart$ to nullable
rem   amozes     07/24/98 - reserve flag for global index stats                
rem   bgoyal     08/07/98 - add disabled flag to ind$                          
rem   whuang     08/19/98 - fake index
rem   mkrishna   07/09/98 -
rem   rwessman   06/12/98  - Fixed i_audit so that multiple proxy users can exi
rem   nagarwal   07/24/98 - remove EXECUTE OPERATOR (204) system privilege
rem   atsukerm   06/03/98 -  add new property flags for trigger$.
rem   akalra     06/12/98 - inicongroup -> defschclass. add comments
rem   hasun      06/05/98  - Fix V8.1 snapshot tables                          
rem   gclaborn   06/04/98 -  Separate exp tables for actions & objects
rem   igreenbe   06/03/98  - fix code walkthrough problems                     
rem   asurpur    06/02/98 -  Add flag to SYSTEM_PRIVILEGE_MAP
rem   rguzman    05/27/98 -  Add REWRITE & GLOBAL REWRITE
rem   bgoyal     05/26/98  - make global keyword required while creating a temp
rem   akalra     05/26/98  - Change tables for resource manager                
rem   mkrishna   06/23/98 -  add attribute# to attrcol table
rem   mjungerm   05/19/98 -  modify javsnm$ to hold utf8
rem   gclaborn   05/19/98 -  Add tables exppkgs$ and expdep$
rem   sbalaram   05/14/98 -  add flavor_id column to snap$                    
rem   nagarwal   05/11/98 -  remove objtype from ustats$
rem   syeung     05/07/98 -  store unspecified [no]logging attributes in 
rem                          [tab|ind]compart$
rem   amozes     04/30/98  - add mon_mods$ for auto_gather_stats               
rem   akruglik   05/06/98 -  add tabfragobj# to lobfrag$ and 
rem                          tabpartobj# to lobcomppart$
rem   nagarwal   05/02/98 -  create indexes on operator catalogs
rem   akruglik   05/01/98 -  add defbufpool to PARTLOB$ and LOBCOMPPART$       
rem   syeung     04/27/98 -  remove type# from tabcompart$ and indcompart$ and
rem                          make deflists and defgroups nullable
rem   bgoyal     04/20/98 -  add property flags to indicate temp. table in ind$
rem   pejustus   04/17/98 -  plan stability changes
rem   rguzman    05/15/98 -  Add columns for expressions in sumkey$
rem   rshaikh    04/15/98 -  replace mlslabel columns
rem   jwlee      04/15/98 -  Transportable/Pluggable Tablespace
rem   esoyleme   04/15/98 -  normalize ruleset$
rem   qyu        04/14/98 -  add flags in coltype$
rem   rguzman    04/10/98 -  modify sum$ to match with sumdep$ changes.
rem   akruglik   04/10/98 -  make deflists and defgroups in PARTLOB$ and
rem                          LOBCOMPART$ nullable so we can represent absense
rem                          of specified default value by storing NULL there
rem   akruglik   04/09/98 -  make defts#, definiexts, defextsize, defminexts, 
rem                          defmaxexts, defextpct in PARTLOB$ and LOBCOMPART$
rem                          nullable so we can represent absense of specified
rem                          default value by storing NULL there + rename
rem                          lobcomppart$.indobj# to indpartobj#
rem   akruglik   04/08/98 -  decided not to set a bit indicating that
rem                          a table contains LOB columns in partobj$.flags
rem                          because in kkpolpd.kkpofpd the information can
rem                          be gleamed from hd
rem   clei       04/08/98 -  add table for row level security
rem   jfeenan    04/08/98 -  Add new dim$ columns and sumdep$
rem   jingliu    04/07/98 -  add temp_log column to mlog$
rem   mluong     04/03/98 -  fix missing ;
rem   bgoyal     04/02/98  - change index stats1 to index on ustat$           
rem   dmwong     04/02/98 -  add context$ and privileges for app ctx           
rem   ato        04/01/98 -  add enqueue/dequeue privileges
rem   esoyleme   04/01/98 -  add obj num to ruleset$
rem   igreenbe   03/31/98  - add scn to snap_reftime$ for null fast refresh   
rem   mkrishna   03/31/98  -                                                   
rem   mkrishna   03/28/98  - add PARENT cols to trigger$                       
rem   amozes     03/27/98 -  mark reserved flags for composite objects         
rem   weiwang    03/26/98 -  Add reg$ and loc$ 
rem   ayalaman   03/26/98 -  define a new flag for sec. index on IOT
rem   amozes     03/26/98 -  add column epvalue to histgrm$
rem   rjenkins   03/25/98 -  adding system-generated column name flag to tab$
rem   jfeenan    03/24/98 -  Create indices for summary and dimension metadata
rem   bgoyal     03/23/98  - flags in lob$
rem   esoyleme   03/23/98 -  add ruleset$
rem   mkrishna   03/19/98  - add nttrigcol to trigger                          
rem   thoang     03/18/98 -  Add tables for partitioning lobs
rem   tanguyen   03/11/98  - change EXTEND to EXTENDS                          
rem   jfeenan    03/10/98 -  add levelid# to dimjoinkey$
rem   amozes     03/09/98 -  add new columns to hist_head                      
rem   alsrivas   03/09/98 -  removing temporary columns from INDTYPES$
rem   smuralid   03/07/98 -  add more flags to coltype$                        
rem   wesmith    03/03/98 -  Modify snap_colmap$ for server-side RepAPI        
rem   hasun      03/01/98 -  Remove unecessary columns from snapshot tables
rem   najain     02/27/98 -  pub_sub support
rem   skaluska   02/27/98 -  Invoker's rights: new property in type_misc$
rem   rwessman   02/25/98 -  Added support for n-tier authentication
rem   kmuthiah   02/25/98 -  add expctoid to refcon$                           
rem   sbasu      02/21/98 -  support for Range Composite part. local indexes
rem                          add table indsubpart$ and indcompart$, rename
rem                          comppart$->tabcompart$
rem   nagarwal   02/19/98 -  Make optimizer catalog changes
rem   bhimatsi   02/19/98 -  bitmapped ts - add flags bits to ts$
rem   nagarwal   02/19/98 -  Modify oparg$
rem   amozes     02/16/98 -  add flags for user-specified stats
rem   jfeenan    02/13/98 -  Add new columns to dim$
rem   rguzman    02/12/98 -  Audit opts: SUMMARY & DIMENSION, 
rem                          remove ALTER SUMMARY
rem   bgoyal     02/10/98 -  add flags for temporary tables                    
rem   qiwang     02/10/98 -  Fix comment for dimjoinkey$
rem   vkarra     02/10/98 -  single table hash clusters
rem   kdias      02/05/98 -  add cols to snap$, snap_reftime$
rem   rguzman    02/05/98 -  Add new Summary Management system privileges.
rem   atsukerm   02/04/98 -  add corrupt flag to seg$.
rem   mramache   02/02/98 -  Add triggerjava$ tables
rem   rjenkins   01/28/98 -  mark functional index columns as NLS dependent
rem   jfeenan    01/28/98 -  Add dimension tables
rem   wesmith    01/21/98 -  Add/modify dict tables for server-side RepAPI     
rem   jfinnert   01/20/98 -  Reserve spare3 in tab$ for summary management
rem   rjenkins   01/20/98 -  remove 0x02 from icol.spare1
rem   whuang     01/16/98 -  online index build project
rem   tanguyen   01/15/98 -  change 'supertypes' to 'supertoid' column in type$
rem   nlewis     01/15/98 -  remove mlslabels
rem   hasun      01/15/98 -  Fix comments to mlog$
rem   akalra     01/13/98 -  Create tables for db scheduler
rem   hasun      01/07/98 -  Add sql_txt dize column to snap$                 
rem   syeung     12/31/97 -  code cleanups for partitioning project:
rem			     rename hybpart$ to comppart$, references to 
rem                          extensible hash -> hash
rem   nagarwal   12/30/97 -  Add statstype# in association$
rem   atsukerm   12/29/97 -  add object# to seg$.
rem   nagarwal   12/23/97 -  Add create operator to resource role
rem   jweisz     12/18/97 -  update comment for collection properties          
rem   akruglik   12/17/97 -  LOB$.PART# will not be used and can be reclaimed 
rem                          if needed
rem   jingliu    12/16/97 -  change comment on job$.field1
rem   rjenkins   12/12/97 -  descending indexes
rem   nagarwal   12/04/97 -  Adding dict tables for ext optimizer
rem   rjenkins   12/04/97 -  adding drop column and functional index flags
rem   khnguyen   11/27/97 -  use spares for lfprecision, fsprecision
rem   jsriniva   11/17/97 -  add key compression to ind$ flags
rem   jsriniva   11/15/97 -  iot: key compression
rem   mjungerm   11/07/97 -  Add Java
rem                          if needed
rem   mjungerm   11/07/97 -  Add Java
rem   jfeenan    11/07/97 -  Add update scn to tab$
rem   wesmith    11/06/97 -  sumdelta$ shape change                            
rem   syeung     11/01/97 -  modified comments in partobj.defts# since number 
rem                          of tablespaces has been moved to spare2 (bytes
rem                          4-5)
rem   thoang     10/29/97 -  Reserved spare2 and spare4 in tab$ for drop column
rem   rmurthy    10/23/97 -  merge from 8.0.4
rem   jfeenan    10/20/97 -  Add summary metadata
rem   nagarwal   10/15/97 -  Change column size in opbinding$
rem   hasun      10/09/97 -  Modify index on sumdelta
rem   nagarwal   10/07/97 -  Change signature size in opbinding$
rem   atsukerm   10/02/97 -  bitmapped tablespaces field definitions.
rem   spsundar   09/18/97 -  comment use of fields for domain idx
rem   hasun      09/16/97 -  Add new table to support snapshots and sumdelta
rem   nagarwal   08/26/97 -  Add return type to opbinding$
rem   alsrivas   08/14/97 -  changing type toid to object number
rem   hasun      08/11/97 -  Change name of sumdelta_dependency to snap_logdep
rem   mkrishna   08/05/97 -  add non-updatable flags to col$.property
rem   alsrivas   07/18/97 -  adding temporary fields for new parameters
rem   syeung     07/03/97 -  add comment for table/index subpartition types in
rem   hasun      07/01/97 -  Add sumdelta and sumdelta_dependency
rem   hasun      06/11/97 -  Add masobj#, masflag to snap_reptime
rem   akruglik   06/09/97 -  expand comment describing parttype/subparttype
rem   akruglik   06/09/97 -  describe usage of partobj$.spare2 in more detail
rem   nagarwal   06/06/97 -  Change OPBINDING.SIGNATURE format
rem   alsrivas   05/27/97 -  adding create indextype to resource role
rem   atsukerm   05/19/97 -  change storage parameters of larger tables
rem   alsrivas   05/19/97 -  makind dictionary changes for indextypes
rem   nagarwal   05/02/97 -  Adding operator to type# in obj$
rem   rjenkins   04/24/97 -  functional indexes
rem   nagarwal   04/24/97 -  Changing signature col in OPBINDING
rem   alsrivas   04/24/97 -  changing indop$
rem   alsrivas   04/21/97 -  modifying indtypes$ and adding privileges
rem   anori      04/18/97 -  fix OIDs for KOT tables
rem   nagarwal   04/16/97 -  Syntax correction
rem   nagarwal   04/15/97 -  Adding privileges for operators
rem   nagarwal   04/11/97 -  Adding tables for operators
rem   alsrivas   04/09/97 -  adding dictionary tables for extensible indexing
rem   mmonajje   04/06/97 -  Replace M_HOST with M_CNCT
rem   syeung     04/05/97 -  add tabsubpart$, tslist$
rem   mkrishna   03/31/97 -  add type component to argument$ (change made by sa
rem   nlewis     03/28/97 -  insert row into trusted_list$
rem   vkarra     03/17/97 -  reserve spare1 in partobj$
rem   hasun      03/05/97 -  Expand rgroup table for parallel propagation
rem   jbellemo   02/25/97 -  remove drops
rem   usundara   01/01/97 -  add PRP flag to properties column in type_misc$
rem   atsukerm   12/16/96 -  add index on tablespace name to ts$.
rem   smuralid   11/21/96 -  add flags to tab$.properties
rem   rshaikh    11/15/96 -  move branch_id and spare to end of pending_sub_ses
rem   abhide     11/08/96 -  change link$
rem   ato        11/04/96 -  add AQ flag to property in tab$
rem   abhide     10/30/96 -  change link$
rem   schandra   10/23/96 -  OTS: Add branch_id column to pending_sub_sessions
rem   hasun      10/24/96 -  Alter snapshot DD:
rem                            slog$ - user#
rem                            snap$ - mas_roll_seg
rem   rshaikh    10/20/96 -  swap columns added from b1->b2 to end
rem   skaluska   10/03/96 -  incomplete types and mutually-referring types
rem                          add property column to dependency$;
rem                          (usundara: add properties to type_misc$)
rem   cxcheng    09/24/96 -  rename KOTTD0$ to KOTTB$ for lint purposes
rem   hasun      09/18/96 -  Fix merge problems
rem   vkrishna   09/12/96 -  add comments
rem   adowning   09/06/96 -  fix merge problem
rem   jsriniva   08/30/96 -  use trunccnt and remove inclcol from ind
rem   smuralid   08/28/96 -  packed type tables not supported
rem   jsriniva   08/26/96 -  add inclcol to ind$ for iots
rem   hasun      08/22/96 -  Reorder column in index i_snap_colmap1
rem   asurpur    08/16/96 -  Changing FAILED_LOGINS to FAILED_LOGIN_ATTEMPTS
rem   cxcheng    08/13/96 -  add create table KOTTD0$
rem   tcheng     08/12/96 -  fix comment in view$.property
rem   hasun      08/12/96 -  Add mtime to snap$ and mlog$ for incremental exp
rem   skaluska   08/09/96 -  Fix comment in clu$
rem   rxgovind   08/02/96 -  add new directory object privs
rem   cxcheng    08/02/96 -  real changes
rem   cxcheng    08/01/96 -  remove INSERT of system type info to type$
rem   skaluska   07/31/96 -  Remove create library from resource
rem   rmurthy    07/28/96 -  add refcon$ table
rem   rshaikh    07/26/96 -  add sys_migrate$ for v7->v8 migration
rem   hasun      07/26/96 -  Add colrole column to snap_colmap$ table
rem   bhimatsi   07/25/96 -  add cols to ts$ for pitr
rem   jwijaya    07/24/96 -  comments for charsetform
rem   jpearson   07/24/96 -  simplify incremental export
rem   tcheng     06/30/96 -  fix comments in triggercol$
rem   cxcheng    06/26/96 -  fix comment for method properties for method$
rem   hasun      06/14/96 -  Normalize snap into snap_reftime
rem   tcheng     06/14/96 -  add comments for col$.property
rem   amganesh   06/13/96 -  adding a defgrp_seq to user
rem   skaluska   06/06/96 -  Add audit$ in library$
rem   amganesh   05/31/96 -  add sequence on ugroup
rem   asurpur    05/30/96 -  Adding grants to exp_full_database/imp_full_databa
rem   hasun      05/29/96 -  Add lobmaskvec column to snap
rem   jpearson   06/11/96 -  modify incexp table for objects
rem   tcheng     05/29/96 -  add flags in view$ - updatability via triggers
rem   cxcheng    05/29/96 -  add charform column to attribute$, collection$ etc
rem   asurpur    05/29/96 -  Increasing the cluster key size
rem   amganesh   05/28/96 -  make i_undo2 nonuniq
rem   jwijaya    05/23/96 -  remove bad comments
rem   asurpur    05/23/96 -  Moving user_history$ table from bootstrap to outsi
rem   hyoshiok   05/22/96 -  add charform in col$
rem   atsukerm   05/22/96 -  add future fields to space dictionary.
rem   amganesh   05/21/96 -  index for ugrp# on ugroup
rem   amganesh   05/21/96 -  creating index on undo.name and ugroup.name
rem   skaluska   05/20/96 -  Add spares, library$, and changes for system gener
rem   tanguyen   05/20/96 -  add EXECUTE ANY TYPE privilege
rem   mmonajje   05/20/96 -  Replace interval col name with interval#
rem   mmonajje   05/20/96 -  Replace timestamp col name with timestamps#
rem   bhimatsi   05/18/96 -  add/rename fields in lob$
rem   cxcheng    05/17/96 - move lob$ table before type$
rem   rjenkins   05/17/96 -  add valid flag to cdef.defer
rem   schandra   05/15/96 -  loosely-coupled branches
rem   schandra   05/15/96 -  loosely-coupled branches
rem   hasun      05/14/96 -  Add snap_colmap
rem   nlewis     05/10/96 -  remove spare1 and spare2 from user$
rem   nlewis     05/09/96 -  PrivDBLinks: add table for Trusted DB list
rem   cxcheng    05/09/96 -  add comments for nchar bit in attribute$
rem   cxcheng    05/08/96 -  remove columns in attribute$, result$, parameter$
rem   smuralid   05/07/96 -  create lob$ before kottd$, kotad$ and kotmd$
rem   amganesh   05/06/96 -  adding cols to undo$ and pending_trans$
rem   amganesh   05/06/96 -  adding cols to undo$ and pending_trans$
rem   jwijaya    05/06/96 -  add LOB namespace and type
rem   hasun      05/06/96 -  replmerge
rem   jwijaya    05/01/96 -  add built-in type bit
rem   jwijaya    04/30/96 -  populate type$ with built-in types
rem   jwijaya    04/26/96 -  fix a bad merge
rem   jwijaya    04/25/96 -  fix col# comment
rem   jwijaya    04/24/96 -  remove unsupported version#
rem   jwijaya    04/22/96 -  cluster type_misc$
rem   ksriniva   04/19/96 -  dictionary changes for database scheduling project
rem   rshaikh    04/18/96 -  add grant directory to stmt_audit_opts_map
rem   mriley     04/16/96 -  add indmethod# to ind$ for cooperative index metho
rem   tcheng     04/16/96 -  add index to typed_view$
rem   jsriniva   04/14/96 -  iot: dictionary clean-up
rem   cxcheng    04/12/96 -  change KOT data structures
rem   vkrishna   04/12/96 -  add flags to lob$, name to ntab$
rem   hasun      04/12/96 -  Normalize snap$ into snap_reftime$ for SQ snaps
rem   ixhu       04/11/96 -  AQ support: new expact$ columns, noexp$ table
rem   jwijaya    04/11/96 -  move oid$ up
rem   asurpur    04/09/96 -  Dictionary Protection Implementation
rem   rshaikh    04/08/96 -  add directory to stmt_audit_opts_map
rem   hasun      04/08/96 -  Add snapshot id sequence
rem   tcheng     04/03/96 -  add typed_view$
rem   hasun      04/01/96 -  Add masterversion columns to snap
rem   jwijaya    03/29/96 -  add intcol# to partcol$
rem   jwijaya    03/25/96 -  index for oid$ column of obj$
rem   hasun      03/25/96 -  Add filter column and equi-join mask vector
rem                          columns to snap_refop$
rem   hasun      03/21/96 -  Modify comments for snap_refop$
rem   hasun      03/20/96 -  Add TABNUM column to snap_refop$
rem   smuralid   03/20/96 -  add new property flag in col$ for columns stored
rem                       -  in lobs
rem   bhimatsi   03/19/96 -  lob$ - add tsno for segment info
rem   hasun      03/15/96 -  Add STATUS columns to snap
rem   rshaikh    03/12/96 -  add type to STMT_AUDIT_OPTION_MAP
rem   sthakur    03/10/96 -  add kopm$, remove koptds$
rem   jwijaya    03/07/96 -  global TOID support
rem   asurpur    03/05/96 -  Logon Re-organization and Password Management
rem   rxgovind   03/04/96 -  add dir$ table
rem   ssamu      02/27/96 -  move 7.3 migration flag to tab/tabpart
rem   bhimatsi   02/27/96 -  minimum feature - add minimum extent to ts$
rem   lwillis    02/07/96 -  Change histogram cluster
rem   jwijaya    02/23/96 -  continue global OID work
rem   hasun      02/20/96 -  Add snap_refop$ to store fast refresh operations
rem   hasun      02/13/96 -  Add sys.mlog_refcol$ for subquery snapshot
rem   smuralid   02/12/96 -  add field kernelcols to tab$
rem   hasun      02/09/96 -  Merge pk_snapshot -> sq_snapshot
rem   ashgupta   02/09/96 -  Merging  snapshot registration code (proj 2045)
rem   jwijaya    02/09/96 -  global OID support (obj$.oid$, oid$)
rem   cxcheng    02/08/96 -  change comment for property in tab$
rem   cxcheng    02/08/96 -  remove value_adt field in type$
rem   tcheng     02/08/96 -  rename adtcol$ to coltype$
rem   ltan       02/08/96 -  PDML: add logging attribute to ts$
rem   akruglik   02/06/96 -  update comment for partobj$.deflogging
rem   ssamu      01/25/96 -  write stats flag to disk
rem   chong      01/25/96 -  fix add type to audit option map
rem   chong      01/23/96 -  add type to audit option map
rem   hasun      01/17/96 -  Remove NOT NULL const from TRIG column of mlog$
rem   jklein     01/11/96 -  freelist space stats for pdml
rem   hyoshiok   01/10/96 -  change col$ table
rem   rjenkins   01/09/96 -  finishing deferred constraintsf
rem   atsukerm   01/03/96 -  allow NULLS for ts# in file$.
rem   cxcheng    12/26/95 -  change column type of toid in attribute$
rem   atsukerm   12/15/95 -  tablespace-relative DBAs.
rem   tcheng     12/10/95 -  change EXTENT TABLE syntax to row type table
rem   mramache   12/07/95 -  add trigflag to tab$
rem   hasun      12/01/95 -  Modify snap$ and mlog$ for primary key snapshots
rem   smuralid   11/30/95 -  add lob object number to LOB$ table
rem   vkrishna   11/20/95 -  Add flags column to ADTCOL$ table
rem   anori      11/08/95 -  fix comments for lob table
rem   anori      11/07/95 -  merge with the BIG branch
rem   tcheng     11/07/95 -  add property to trigger$
rem   aho        11/06/95 -  iot : ind$
rem                          move compressed from flags to property
rem                          add unusable (dls) to flags
rem                          add type, threshold
rem                          rename spare7 to trunccnt
rem   aho        10/30/95 -  iot : tab$
rem                          change clu# to bobj#
rem                          move iot bits from flag to property
rem   rjenkins   10/30/95 -  deferred constraints
rem   schandra   10/13/95 -  Migration - separate status & contents in ts
rem   achaudhr   10/06/95 -  Merge PQ->PTI
rem   skaluska   10/03/95 -  Move partition bit over to property
rem   achaudhr   10/02/95 -  PTI: Fixup degree and instances
rem   echen      09/29/95 -  mergetrans echen_fix_tkxb_diffs
rem   echen      09/29/95 -  Modify table priviliege.
rem   ssamu      09/28/95 -  dual object number phase 2
rem   jsriniva   09/28/95 -  dictionary changes for index only table
rem   jwijaya    09/21/95 -  add attrcol$
rem   ssamu      09/20/95 -  dual object number - cleanup
rem   ssamu      09/18/95 -  dual object numbers
rem   smuralid   09/14/95 -  LOB support - add tables lob$
rem   ssamu      09/12/95 -  dual object numbers
rem   jwijaya    08/28/95 -  add type_misc$
rem   jwijaya    08/25/95 -  remove USAGE from TABLE_PRIVILEGE_MAP
rem   skaluska   08/11/95 -  merge PTI with Objects
rem   varora     06/29/95 -  make intcols/intcol# null/not null
rem   jwijaya    06/16/95 -  add TYPE USAGE 
rem   tcheng     06/06/95 -  modify create extent table syntax 
rem   skotsovo   05/05/95 -  update according to release 1 
rem   jwijaya    04/28/95 -  fix comments 
rem   varora     04/28/95 -  rename col#,usercol#,cols,usercols 
rem   tcheng     03/21/95 -  add col# to adtcol$ and ntab$ 
rem   varora     01/27/95 -  add table for nested table support 
rem   skotsovo   01/25/95 -  bring normalized type tables up to date 
rem   skotsovo   01/23/95 -  move exceptions from method to method_body 
rem   jwijaya    01/04/95 -  add system privileges for type
rem   jwijaya    12/29/94 -  making type$ work (temporarily allow 'version'
rem                          'checks' columns nullable and mark 'checks'
rem                          and 'default$' not-supported (N/S))
rem   skrishna   12/06/94 -  create extent table of pre-defined types 
rem   varora     12/01/94 -  change toid in adtcol$ to type number 
rem   anori      11/17/94 -  ADT support tables and columns
rem
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rem Whenever new column is created to store internal, user or kernel column
rem number, be sure to update the structure adtDT in atb.c so that those 
rem columns will be updated properly during drop column.
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
rem
create tablespace SYSTEM datafile "D_DBFN" 
  "D_DSTG" online
/
create rollback segment SYSTEM tablespace SYSTEM
  storage (initial 50K next 50K)
/
create cluster c_obj# (obj# number)
  pctfree 5 size 800                           /* don't waste too much space */
  /* A table of 32 cols, 2 index, 2 col per index requires about 2K.
   * A table of 10 cols, 2 index, 2 col per index requires about 750.
   */
  storage (initial 130K next 200k maxextents unlimited pctincrease 0) 
  /* avoid space management during IOR I */
/
create index i_obj# on cluster c_obj#
/
create table tab$                                             /* table table */
( obj# 	        number not null,                            /* object number */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#      number,                          /* data layer object number */
  ts#		number not null,                        /* tablespace number */
  file#		number not null,               /* segment header file number */
  block#	number not null,              /* segment header block number */
  bobj#         number,                /* base object number (cluster / iot) */
  tab#		number,    /* table number in cluster, NULL if not clustered */
  cols          number not null,			/* number of columns */
  clucols       number,/* number of clustered columns, NULL if not clustered */
  pctfree$      number not null, /* minimum free space percentage in a block */
  pctused$      number not null, /* minimum used space percentage in a block */
  initrans      number not null,            /* initial number of transaction */
  maxtrans      number not null,            /* maximum number of transaction */
  flags         number not null, /* 0x00     = unmodified since last backup 
                                    0x01     = modified since then 
                                    0x02     = DML locks restricted to <= SX 
                                    0x04     = DML locks <= SX not acquired
	                            0x08     = CACHE  
				    0x10     = table has been analyzed
				    0x20     = table has no logging
				    0x40     = 7.3 -> 8.0 data object
					       migration required    
                                    0x0080   = current summary dependency
                                    0x0100   = user-specified stats
                                    0x0200   = global stats           
                                    0x0800   = table has security policy 
                                    0x020000 = Move Partitioned Rows */
  audit$	varchar2("S_OPFL") not null,             /* auditing options */
  rowcnt        number,                                    /* number of rows */
  blkcnt        number,                                  /* number of blocks */
  empcnt        number,                            /* number of empty blocks */
  avgspc        number,                      /* average available free space */
  chncnt        number,                            /* number of chained rows */
  avgrln        number,                                /* average row length */
  avgspc_flb    number,       /* avg avail free space of blocks on free list */
  flbcnt        number,                             /* free list block count */
  analyzetime   date,                        /* timestamp when last analyzed */
  samplesize    number,                 /* number of rows sampled by Analyze */
/* 
 * Legal values for degree, instances: 
 *     NULL (used to represent 1 on disk/dictionary and implies noparallel), or
 *     2 thru EB2MAXVAL-1 (user supplied values), or
 *     EB2MAXVAL (implies use default value) 
 */
  degree        number,      /* number of parallel query slaves per instance */
  instances     number,        /* number of OPS instances for parallel query */
/* <intcols> => the number of dictionary columns => the number of columns 
 * that have dictionary meta-data associated with them. This is a superset of 
 * <usercols> and <kernelcols>. 
 *    <intcols> = <kernelcols> + <number_of_virtual_columns>
 */
  intcols       number not null,               /* number of internal columns */
/* <kernelcols> => the number of REAL columns (ie) columns that actually
 * store data.
 */
  kernelcols    number not null,          /* number of REAL (kernel) columns */
  property      number not null,            /* table properties (bit flags): */
                              /* 0x01 = typed table, 0x02 = has ADT columns, */
                 /* 0x04 = has nested-TABLE columns, 0x08 = has REF columns, */
                      /* 0x10 = has array columns, 0x20 = partitioned table, */
               /* 0x40 = index-only table (IOT), 0x80 = IOT w/ row OVerflow, */
             /* 0x100 = IOT w/ row CLustering, 0x200 = IOT OVeRflow segment, */
               /* 0x400 = clustered table, 0x800 = has internal LOB columns, */
        /* 0x1000 = has primary key-based OID$ column, 0x2000 = nested table */
                    /* 0x4000 = View is Read Only, 0x8000 = has FILE columns */
       /* 0x10000 = obj view's OID is system-gen, 0x20000 = used as AQ table */
                                   /* 0x40000 = has user-defined lob columns */
                               /* 0x00080000 = table contains unused columns */
                            /* 0x100000 = has an on-commit materialized view */
                             /* 0x200000 = has system-generated column names */
                                      /* 0x00400000 = global temporary table */
                            /* 0x00800000 = session-specific temporary table */
  trigflag      number,                             /* inline trigger flags: */
                                                  /* 0x01 deferred RPC Queue */
                                                        /* 0x02 snapshot log */
                                              /* 0x04 updatable snapshot log */
                                                           /* 0x08 = context */
  spare1        number,                       /* used to store hakan_kqldtvc */
  spare2        number,         /* committed partition # used by drop column */
  spare3        number,                           /* summary sequence number */
  spare4        varchar2(1000),         /* committed RID used by drop column */
  spare5        varchar2(1000),
  spare6        date                                        /* dml timestamp */
)
cluster c_obj#(obj#)
/  
create table clu$					    /* cluster table */
( obj# 		number not null,                            /* object number */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#      number,                          /* data layer object number */
  ts#		number not null,                        /* tablespace number */
  file#		number not null,               /* segment header file number */
  block#	number not null,              /* segment header block number */
  cols          number not null,			/* number of columns */
  pctfree$      number not null, /* minimum free space percentage in a block */
  pctused$      number not null, /* minimum used space percentage in a block */
  initrans      number not null,            /* initial number of transaction */
  maxtrans      number not null,            /* maximum number of transaction */
  size$         number,
       /* if b-tree, estimated number of bytes for each cluster key and rows */
  hashfunc      varchar2("M_IDEN"),        /* if hashed, function identifier */

  /* Some of the spare columns may give the initial # bytes in the hash table
   * and the # hash keys per block.  These are user-specified parameters.
   * For extendible hash tables, two columns might include the # bits
   * currently be used in the hash function and the number of the next
   * bucket to split.
   * Some spare columns may be used for hash table statistics
   * such as # distinct keys, # distinct values of first key column, and
   * average # blocks per key.  Some spare columns  may give the number of
   * the cluster table for which the cluster key is unique or indicate
   * whether the cluster is normal or referential.
   * We can encode multiple pieces of info in a single column.
   */
  hashkeys      number,                                    /* hash key count */
  func          number, /* function: 0 (key is function), 1 (system default) */
  extind        number,             /* extent index value of fixed hash area */
  flags         number,                                      /* 0x08 = CACHE */
                                          /* 0x010000 = Single Table Cluster */
/* 
 * Legal values for degree, instances: 
 *     NULL (used to represent 1 on disk/dictionary and implies noparallel), or
 *     2 thru EB2MAXVAL-1 (user supplied values), or
 *     EB2MAXVAL (implies use default value) 
 */
  degree        number,      /* number of parallel query slaves per instance */
  instances     number,       /*  number of OPS instances for parallel query */
  avgchn        number,          /* average chain length - previously spare4 */
  spare1        number,
  spare2        number,
  spare3        number,
  spare4        number,
  spare5        varchar2(1000),
  spare6        varchar2(1000),
  spare7        date
)
cluster c_obj#(obj#)
/
create cluster c_ts#(ts# number)           /* use entire block for each ts# */
/
create index i_ts# on cluster c_ts#
/
create cluster c_file#_block#(ts# number, segfile# number, segblock# number) 
  size 225    /* cluster key ~ 25, sizeof(seg$) ~ 50, 5 * sizeof(uet$) ~ 150 */
  storage (initial 20K)               /* avoid space management during IOR I */
/
create index i_file#_block# on cluster c_file#_block#
/
create cluster c_user#(user# number) 
  size  372 /* cluster key ~ 20, sizeof(user$) ~ 227, 5 * sizeof(tsq$) ~ 125 */
/
create index i_user# on cluster c_user#
/
create table fet$                                       /* free extent table */
( ts#           number not null,        /* tablespace containing free extent */
  file#         number not null,              /* file containing free extent */
  block#        number not null,              /* starting dba of free extent */
  length        number not null           /* length in blocks of free extent */
)
cluster c_ts#(ts#)
/
create table uet$                                       /* used extent table */
( segfile#      number not null,               /* segment header file number */
  segblock#     number not null,              /* segment header block number */
  ext#          number not null,         /* extent number within the segment */
  ts#           number not null,        /* tablespace containing this extent */
  file#         number not null,              /* file containing this extent */
  block#        number not null,              /* starting dba of this extent */
  length        number not null           /* length in blocks of this extent */
)
cluster c_file#_block#(ts#, segfile#, segblock#)
/
create table seg$                                           /* segment table */
( file#         number not null,               /* segment header file number */
  block#        number not null,              /* segment header block number */
  type#         number not null,                /* segment type (see KTS.H): */
   /* 1 = UNDO, 2 = SAVE UNDO, 3 = TEMPORARY, 4 = CACHE, 5 = DATA, 6 = INDEX */
  ts#           number not null,       /* tablespace containing this segment */
  blocks        number not null,       /* blocks allocated to segment so far */
					   /* zero for bitmapped tablespaces */
  extents       number not null,      /* extents allocated to segment so far */
					   /* zero for bitmapped tablespaces */
  iniexts       number not null,                      /* initial extent size */
  minexts       number not null,                /* minimum number of extents */
  maxexts       number not null,                /* maximum number of extents */
  extsize       number not null,                 /* current next extent size */
					   /* zero for bitmapped tablespaces */
  extpct        number not null,                    /* percent size increase */
  user#         number not null,               /* user who owns this segment */
  lists	        number,                        /* freelists for this segment */
  groups        number,                  /* freelist groups for this segment */
  bitmapranges  number not null,                 /* ranges per bit map entry */
  cachehint     number not null,                        /* hints for caching */
  scanhint      number not null,                       /* hints for scanning */
  hwmincr       number not null,             /* Amount by which HWM is moved */
					  /* Reuse it as object number/class */
				     /* for objects in bitmapped tablespaces */
  spare1        number,                        /* Segment flags - NULL = 0x0 */
                                               /* 0x1 - bitmapped tablespace */
                                                       /* 0x2 - undo segment */
                                                   /* 0x4 - saveundo segment */
                                             /* 0x8 - segment marked corrupt */
  spare2        number
)
cluster c_file#_block#(ts#, file#, block#)
/
create table undo$                                     /* undo segment table */
( us#           number not null,                      /* undo segment number */
  name          varchar2("M_IDEN") not null,    /* name of this undo segment */
  user#         number not null,      /* owner: 0 = SYS(PRIVATE), 1 = PUBLIC */
  file#         number not null,               /* segment header file number */
  block#        number not null,              /* segment header block number */
  scnbas        number,           /* highest commit time in rollback segment */
  scnwrp        number,              /* scnbas - scn base, scnwrp - scn wrap */
  xactsqn       number,               /* highest transaction sequence number */
  undosqn       number,                /* highest undo block sequence number */
  inst#         number,    /* parallel server instance that owns the segment */
  status$       number not null,              /* segment status (see KTS.H): */
  /* 1 = INVALID, 2 = AVAILABLE, 3 = IN USE, 4 = OFFLINE, 5 = NEED RECOVERY, 
   * 6 = PARTLY AVAILABLE (contains in-doubt txs) 
   */
  ts#           number,                                 /* tablespace number */
  ugrp#		number,                      /* The undo group it belongs to */
  keep          number,
  optimal       number,
  flags         number,
  spare1        number,
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)

/
create table ts$                                         /* tablespace table */
( ts#           number not null,             /* tablespace identifier number */
  name          varchar2("M_IDEN") not null,           /* name of tablespace */
  owner#        number not null,                      /* owner of tablespace */
  online$       number not null,                      /* status (see KTT.H): */
                                     /* 1 = ONLINE, 2 = OFFLINE, 3 = INVALID */
  contents$     number not null,     /* TEMPORARY/PERMANENT                  */
  undofile#     number,  /* undo_off segment file number (status is OFFLINE) */
  undoblock#    number,               /* undo_off segment header file number */
  blocksize     number not null,                   /* size of block in bytes */
  inc#          number not null,             /* incarnation number of extent */
  scnwrp	number,     /* clean offline scn - zero if not offline clean */
  scnbas        number,              /* scnbas - scn base, scnwrp - scn wrap */
  dflminext     number not null,       /*  default minimum number of extents */
  dflmaxext     number not null,        /* default maximum number of extents */
  dflinit       number not null,              /* default initial extent size */
  dflincr       number not null,                 /* default next extent size */
  dflminlen     number not null,              /* default minimum extent size */
  dflextpct     number not null,     /* default percent extent size increase */
  dflogging     number not null,                /* default logging attribute */
                                               /* 0 = NOLOGGING, 1 = LOGGING */
  affstrength   number not null,                        /* Affinity strength */
  bitmapped     number not null,       /* If not bitmapped, 0 else unit size */
						                /* in blocks */
  plugged       number not null,                               /* If plugged */
  directallowed number not null,   /* Operation which invalidate standby are */
							          /* allowed */
  flags         number not null,			    /* various flags */
	                                 /* 0x01 = system managed allocation */
	                                        /* 0x02 = uniform allocation */
			        /* if above 2 bits not set then user managed */
  pitrscnwrp    number,			     /* scn wrap when ts was created */
  pitrscnbas    number,			     /* scn base when ts was created */
  ownerinstance varchar("M_IDEN"),                    /* Owner instance name */
  backupowner   varchar("M_IDEN"),             /* Backup owner instance name */
  groupname     varchar("M_IDEN"),                             /* Group name */
  spare1        number,                                  /* plug-in SCN wrap */
  spare2        number,                                  /* plug-in SCN base */
  spare3        varchar2(1000),
  spare4        date
)
cluster c_ts#(ts#)
/
create table file$                                             /* file table */
( file#         number not null,                   /* file identifier number */
  status$       number not null,                      /* status (see KTS.H): */
                                               /* 1 = INVALID, 2 = AVAILABLE */
  blocks        number not null,                   /* size of file in blocks */
                                           /* zero for bitmapped tablespaces */
  ts#           number,                         /* tablespace that owns file */
  relfile#      number,                              /* relative file number */
  maxextend     number,                                 /* maximum file size */
  inc           number,                                  /* increment amount */
  crscnwrp      number,                                 /* creation SCN wrap */
  crscnbas      number,                                 /* creation SCN base */
  ownerinstance varchar("M_IDEN"),                    /* Owner instance name */
  spare1        number,      /* tablespace-relative DBA of space file header */
				   /* NULL for dictionary-mapped tablespaces */
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create table obj$                                            /* object table */
( obj#          number not null,                            /* object number */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */ 
  dataobj#      number,                          /* data layer object number */
  owner#        number not null,                        /* owner user number */
  name		varchar2("M_IDEN") not null,		      /* object name */
  namespace     number not null,         /* namespace of object (see KQD.H): */
 /* 1 = TABLE/PROCEDURE/TYPE, 2 = BODY, 3 = TRIGGER, 4 = INDEX, 5 = CLUSTER, */
                                                  /* 8 = LOB, 9 = DIRECTORY, */
  /* 10 = QUEUE, 11 = REPLICATION OBJECT GROUP, 12 = REPLICATION PROPAGATOR, */
                                     /* 13 = JAVA SOURCE, 14 = JAVA RESOURCE */
  subname       varchar2("M_IDEN"),               /* subordinate to the name */
  type#         number not null,                 /* object type (see KQD.H): */
  /* 1 = INDEX, 2 = TABLE, 3 = CLUSTER, 4 = VIEW, 5 = SYNONYM, 6 = SEQUENCE, */
             /* 7 = PROCEDURE, 8 = FUNCTION, 9 = PACKAGE, 10 = NON-EXISTENT, */
              /* 11 = PACKAGE BODY, 12 = TRIGGER, 13 = TYPE, 14 = TYPE BODY, */
      /* 19 = TABLE PARTITION, 20 = INDEX PARTITION, 21 = LOB, 22 = LIBRARY, */
                                             /* 23 = DIRECTORY , 24 = QUEUE, */
    /* 25 = IOT, 26 = REPLICATION OBJECT GROUP, 27 = REPLICATION PROPAGATOR, */
    /* 28 = JAVA SOURCE, 29 = JAVA CLASS, 30 = JAVA RESOURCE, 31 = JAVA JAR, */
                 /* 32 = INDEXTYPE, 33 = OPERATOR , 34 = TABLE SUBPARTITION, */
                                                  /* 35 = INDEX SUBPARTITION */
  ctime         date not null,                       /* object creation time */
  mtime         date not null,                      /* DDL modification time */
  stime         date not null,          /* specification timestamp (version) */
  status        number not null,            /* status of object (see KQD.H): */
                                     /* 1 = VALID/AUTHORIZED WITHOUT ERRORS, */
                          /* 2 = VALID/AUTHORIZED WITH AUTHORIZATION ERRORS, */
                            /* 3 = VALID/AUTHORIZED WITH COMPILATION ERRORS, */
                         /* 4 = VALID/UNAUTHORIZED, 5 = INVALID/UNAUTHORIZED */
  remoteowner   varchar2("M_IDEN"),	/* remote owner name (remote object) */
  linkname      varchar2("M_XDBI"),	        /* link name (remote object) */
  flags         number,               /* 0x01 = extent map checking required */
                                      /* 0x02 = temporary object             */
                                      /* 0x04 = system generated object      */
                                      /* 0x08 = unbound (invoker's rights)   */
                                      /* 0x10 = secondary object             */
  oid$          raw(16),        /* OID for typed table, typed view, and type */
  spare1        number,                      /* sql version flag: see kpul.h */
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table ind$                                             /* index table */
( obj#          number not null,			    /* object number */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#      number,                          /* data layer object number */
  ts#		number not null,                        /* tablespace number */
  file#		number not null,               /* segment header file number */
  block#	number not null,              /* segment header block number */
  bo#		number not null,	      /* object number of base table */
  indmethod#    number not null,    /* object # for cooperative index method */
  cols          number not null,			/* number of columns */
  pctfree$      number not null, /* minimum free space percentage in a block */
  initrans      number not null,            /* initial number of transaction */
  maxtrans      number not null,            /* maximum number of transaction */
  pctthres$     number,           /* iot overflow threshold, null if not iot */
  type#         number not null,              /* what kind of index is this? */
                                                               /* normal : 1 */
                                                               /* bitmap : 2 */
                                                              /* cluster : 3 */
                                                            /* iot - top : 4 */
                                                         /* iot - nested : 5 */
                                                            /* secondary : 6 */
                                                                 /* ansi : 7 */
                                                                  /* lob : 8 */
                                             /* cooperative index method : 9 */
  flags         number not null,      
                /* mutable flags: anything permanent should go into property */
                                                    /* unusable (dls) : 0x01 */
                                                    /* analyzed       : 0x02 */
                                                    /* no logging     : 0x04 */
                                    /* index is currently being built : 0x08 */
                                     /* index creation was incomplete : 0x10 */
                                           /* key compression enabled : 0x20 */
                                              /* user-specified stats : 0x40 */
					    /* secondary index on IOT : 0x80 */
                                      /* index is being online built : 0x100 */
                                    /* index is being online rebuilt : 0x200 */
                                                /* index is disabled : 0x400 */
						     /* global stats : 0x800 */
                                            /* fake index(internal) : 0x1000 */
  property      number not null,    /* immutable flags for life of the index */
                                                            /* unique : 0x01 */
                                                       /* partitioned : 0x02 */
                                                           /* reverse : 0x04 */
                                                        /* compressed : 0x08 */
                                                        /* functional : 0x10 */
                                              /* temporary table index: 0x20 */
                             /* session-specific temporary table index: 0x40 */
  /* The following columns are used for index statistics such
   * as # btree levels, # btree leaf blocks, # distinct keys, 
   * # distinct values of first key column, average # leaf blocks per key,
   * clustering info, and # blocks in index segment.
   */
  blevel        number,                                       /* btree level */
  leafcnt       number,                                  /* # of leaf blocks */
  distkey       number,                                   /* # distinct keys */
  lblkkey       number,                          /* avg # of leaf blocks/key */
  dblkkey       number,                          /* avg # of data blocks/key */
  clufac        number,                                 /* clustering factor */
  analyzetime   date,                        /* timestamp when last analyzed */
  samplesize    number,                 /* number of rows sampled by Analyze */
  rowcnt        number,                       /* number of rows in the index */
  intcols       number not null,               /* number of internal columns */
         /* The following two columns are only valid for partitioned indexes */
/* 
 * Legal values for degree, instances: 
 *     NULL (used to represent 1 on disk/dictionary and implies noparallel), or
 *     2 thru EB2MAXVAL-1 (user supplied values), or
 *     EB2MAXVAL (implies use default value) 
 */
  degree        number,      /* number of parallel query slaves per instance */
  instances     number,       /*  number of OPS instances for parallel query */

  trunccnt      number,                        /* re-used for iots 'inclcol' */
  spare1        number,         /* number of columns depended on, >= intcols */
  spare2        number,        /* number of key columns in compressed prefix */
  spare3        number,
  spare4        varchar2(1000),     /* used for parameter str for domain idx */
  spare5        varchar2(1000),
  spare6        date
)
cluster c_obj#(bo#)
/
create table icol$                                     /* index column table */
( obj#          number not null,                      /* index object number */
  bo#           number not null,                       /* base object number */
  col#          number not null,                            /* column number */
  pos#          number not null,        /* column position number as created */
  segcol#       number not null,		 /* column number in segment */
  segcollength  number not null,             /* length of the segment column */
  offset        number not null,                         /* offset of column */
  intcol#       number not null,                   /* internal column number */
  spare1        number,                                              /* flag */
                                              /* 0x01: this is an expression */
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
cluster c_obj#(bo#)
/
create table col$                                            /* column table */
( obj#          number not null,             /* object number of base object */
  col#          number not null,                 /* column number as created */
  segcol#       number not null,                 /* column number in segment */
  segcollength  number not null,             /* length of the segment column */
  offset        number not null,                         /* offset of column */
  name          varchar2("M_IDEN") not null,               /* name of column */
  type#      	number  not null,		      /* data type of column */
                                           /* for ADT column, type# = DTYADT */
  length        number  not null,               /* length of column in bytes */
  fixedstorage  number  not null,   /* flags: 0x01 = fixed, 0x02 = read-only */
  precision#    number,                                         /* precision */
  scale         number,                                             /* scale */
  null$         number not null,                     /* 0 = NULLs permitted, */
                                                /* > 0 = no NULLs permitted  */
  deflength     number,              /* default value expression text length */
  default$      long,                       /* default value expression text */

  /*
   * If a table T(c1, addr, c2) contains an ADT column addr which is stored 
   * exploded, the table will be internally stored as 
   *              T(c1, addr, C0003$, C0004$, C0005$, c2)
   * Of these, only c1, addr and c2 are user visible columns. Thus, the 
   * user visible column numbers for (c1, addr, C0003$, C0004$, C0005$, c2) 
   * will be 1,2,0,0,0,3. And the corresponding internal column numbers will 
   * be 1,2,3,4,5,6. 
   *
   * Some dictionary tables like icol$, ccol$ need to contain intcol# so 
   * that we can have indexes and constraints on ADT attributes. Also, these
   * tables also need to contain col# to maintain backward compatibility.
   * Most of these tables will need to be accessed by col#, intcol# so 
   * indexes are created on them based on (obj#, col#) and (obj#, intcol#).
   * Indexes based on col# have to be non-unique if ADT attributes might
   * appear in the table. Indexes based on intcol# can be unique.
   */
  intcol#       number not null,                   /* internal column number */
  property      number not null,           /* column properties (bit flags): */
                /* 0x0001 =       1 = ADT attribute column                   */
                /* 0x0002 =       2 = OID column                             */
                /* 0x0004 =       4 = nested table column                    */
                /* 0x0008 =       8 = virtual column                         */
                /* 0x0010 =      16 = nested table's SETID$ column           */
                /* 0x0020 =      32 = hidden column                          */
                /* 0x0040 =      64 = primary-key based OID column           */
                /* 0x0080 =     128 = column is stored in a lob              */
                /* 0x0100 =     256 = system-generated column                */
                /* 0x0200 =     512 = rowinfo column of typed table/view     */
                /* 0x0400 =    1024 = nested table columns setid             */
                /* 0x0800 =    2048 = column not insertable                  */
                /* 0x1000 =    4096 = column not updatable                   */
                /* 0x2000 =    8192 = column not deletable                   */
                /* 0x4000 =   16384 = dropped column                         */
                /* 0x8000 =   32768 = unused column - data still in row      */
            /* 0x00010000 =   65536 = virtual column                         */
            /* 0x00020000 =  131072 = place DESCEND operator on top          */
            /* 0x00040000 =  262144 = virtual column is NLS dependent        */
            /* 0x00080000 =  524288 = ref column (present as oid col)        */
            /* 0x00100000 = 1048576 = hidden snapshot base table column      */
            /* 0x00200000 = 2097152 = attribute column of a user-defined ref */
            /* 0x00400000 = 4194304 = export hidden column,RLS on hidden col */

  /* The spares may be used as the column's NLS character set, 
   * the number of distinct column values, and the column's domain.
   */
  /* the universal character set id maintained by NLS group */
  charsetid     number,                              /* NLS character set id */
  /*
   * charsetform
   */
  charsetform	number,
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  spare1        number,                      /* fractional seconds precision */
  spare2        number,                  /* interval leading field precision */
  spare3        number,
  spare4        varchar2(1000),          /* NLS settings for this expression */
  spare5        varchar2(1000),
  spare6        date
)
cluster c_obj#(obj#)
/
create table user$                                             /* user table */
( user#		number not null,                   /* user identifier number */
  name        	varchar2("M_IDEN") not null,		     /* name of user */
  type#         number not null,                       /* 0 = role, 1 = user */
  password	varchar2("M_IDEN"),		       /* encrypted password */
  datats#     	number not null, /* default tablespace for permanent objects */
  tempts#     	number not null,  /* default tablespace for temporary tables */
  ctime         date not null,                 /* user account creation time */
  ptime         date,                                /* password change time */
  exptime       date,                     /* actual password expiration time */
  ltime         date,                         /* time when account is locked */
  resource$     number not null,                        /* resource profile# */
  audit$	varchar2("S_OPFL"),  	               /* user audit options */
  defrole       number not null,                  /* default role indicator: */
               /* 0 = no roles, 1 = all roles granted, 2 = roles in defrole$ */
  defgrp#	number,                                /* default undo group */
  defgrp_seq#   number,               /* global sequence number for  the grp *
  spare		varchar2("M_IDEN"),                   /* reserved for future */
  astatus	number default 0 not null,	    /* status of the account */
	        /* 1 = Locked, 2 = Expired, 3 = Locked and Expired, 0 - open */
  lcount	number default 0 not null, /* count of failed login attempts */
  defschclass   varchar2("M_IDEN"),                /* initial consumer group */
  ext_username  varchar2("M_VCSZ"),                     /* external username */
  spare1        number,
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
cluster c_user#(user#)
/
create table proxy$
( client#       NUMBER NOT NULL,                           /* client user ID */
  proxy#        NUMBER NOT NULL,                            /* proxy user ID */
  role#         NUMBER NOT NULL,                                  /* role ID */
  flags         NUMBER NOT NULL               /* Mask flags of associated with entry */
             /* Flags values:
              * 1 = proxy can activate all client roles
              * 2 = proxy can activate no client roles
              * 4 = role can be activated by proxy,
              * 8 = role cannot be activated by proxy
              */
)
/
create unique index i_proxy$ on proxy$(client#, proxy#, role#, flags)
/
create table con$                                        /* constraint table */
( owner#        number not null,                        /* owner user number */
  name          varchar2("M_IDEN") not null,              /* constraint name */
  con#          number not null,                        /* constraint number */
  spare1        number,
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
/
create cluster c_cobj# (obj# number)
  pctfree 0 pctused 50
  /* space for: update cdef$ set condition = 'col IS NOT NULL' at // */
  size 300
  storage (initial 50K)               /* avoid space management during IOR I */
/
create index i_cobj# on cluster c_cobj#
/
create table cdef$                            /* constraint definition table */
( con#          number not null,                        /* constraint number */
  obj#          number not null,         /* object number of base table/view */
  cols          number,                   /* number of columns in constraint */
  type#         number not null,                         /* constraint type: */
                            /* 1 = table check, 2 = primary key, 3 = unique, */
                             /* 4 = referential, 5 = view with CHECK OPTION, */
			                         /* 6 = view READ ONLY check */
               /* 7 - table check constraint associated with column NOT NULL */
                                   /* 8 - hash expressions for hash clusters */
  robj#         number,                 /* object number of referenced table */
  rcon#         number,           /* constraint number of referenced columns */
  rrules        varchar2(3),         /* future: use this columns for pendant */
  match#        number,                /* referential constraint match type: */
                                                 /* null = FULL, 1 = PARTIAL */
        /* this column can also store information for other constraint types */
  refact        number,                               /* referential action: */
              /* null = RESTRICT, 1 = CASCADE, 2 = SET NULL, 3 = SET DEFAULT */
  enabled        number,          /* is constraint enabled? NULL if disabled */
  condlength    number,                 /* table check condition text length */
  condition     long,                          /* table check condition text */
  intcols       number,          /* number of internal columns in constraint */
  mtime         date,      /* date this constraint was last enabled-disabled */
  defer         number,                     /* 0x01 constraint is deferrable */
                                              /* 0x02 constraint is deferred */
                                /* 0x04 constraint has been system validated */
                                 /* 0x08 constraint name is system generated */
                       /* 0x10 constraint is BAD, depends on current century */
                           /* 0x20, optimizer should RELY on this constraint */
  spare1        number,                      /* sql version flag: see kpul.h */
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
cluster c_cobj#(obj#)
/
create table ccol$                                /* constraint column table */
( con#          number not null,                        /* constraint number */
  obj#          number not null,                       /* base object number */
  col#          number not null,                            /* column number */
  pos#          number,                 /* column position number as created */
  intcol#       number not null,                   /* internal column number */
  spare1        number,
  spare2        number,
  spare3        number,
  spare4        varchar2(1000),
  spare5        varchar2(1000),
  spare6        date
)
cluster c_cobj#(obj#)
/
create index i_tab1 on tab$(bobj#)
/
create unique index i_undo1 on undo$(us#)
/
create index i_undo2 on undo$(name)
/
create unique index i_obj1 on obj$(obj#)
/
create unique index i_obj2 on obj$(owner#, name, namespace,
remoteowner, linkname, subname)
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create index i_obj3 on obj$(oid$)
/
create unique index i_ind1 on ind$(obj#)
/
create index i_icol1 on icol$(obj#)
/
create unique index i_file1 on file$(file#)
/
create unique index i_file2 on file$(ts#, relfile#)
/
create unique index i_ts1 on ts$(name)
/
create unique index i_user1 on user$(name)
/
create unique index i_col1 on col$(obj#, name)
  storage (initial 30k next 100k maxextents unlimited pctincrease 0)
/
create index i_col2 on col$(obj#, col#)
  storage (initial 30k next 100k maxextents unlimited pctincrease 0)
/
create unique index i_col3 on col$(obj#, intcol#)
  storage (initial 30k next 100k maxextents unlimited pctincrease 0)
/
create unique index i_con1 on con$(owner#, name)
/
create unique index i_con2 on con$(con#)
/
create unique index i_cdef1 on cdef$(con#)
/
create index i_cdef2 on cdef$(obj#)
/
create index i_cdef3 on cdef$(robj#)
/
create index i_cdef4 on cdef$(enabled)
/
create index i_ccol1 on ccol$(con#, col#)
/
create unique index i_ccol2 on ccol$(con#, intcol#)
/
create table bootstrap$
( line#         number not null,                       /* statement order id */
  obj#          number not null,                            /* object number */
  sql_text      varchar2("M_VCSZ") not null)                    /* statement */
  storage (initial 50K)            /* to avoid space management during IOR I */
//                                            /* "//" required for bootstrap */
create table ugroup$                         /* rollback segment group table */
( ugrp#		number not null,                        /* undo group number */
  name		varchar2("M_IDEN") not null,              /* undo group name */
  seq#          number,
  spare1        number,
  spare2        varchar2("M_IDEN"),
  spare3        number
)
/
create index i_ugroup1 on ugroup$(name)
/
create index i_ugroup2 on ugroup$(ugrp#)
/
create table tsq$                                  /* tablespace quota table */
( ts#           number not null,                        /* tablespace number */
  user#         number not null,                              /* user number */
  grantor#      number not null,                               /* grantor id */
  blocks        number not null,         /* number of blocks charged to user */
  maxblocks     number,     /* user's maximum number of blocks, NULL if none */
  priv1         number not null,            /* reserved for future privilege */
  priv2         number not null,            /* reserved for future privilege */
  priv3         number not null)            /* reserved for future privilege */
cluster c_user# (user#)
/
create table syn$                                           /* synonym table */
( obj#          number not null,			    /* object number */
  node		varchar2("M_XDBI"),			   /* node of object */
  owner 	varchar2("M_IDEN"),                          /* object owner */
  name		varchar2("M_IDEN") not null)		      /* object name */
/
create table view$                                             /* view table */
( obj#          number not null,			    /* object number */
  audit$	varchar2("S_OPFL") not null,		 /* auditing options */
  cols          number not null,			/* number of columns */
  intcols       number not null,               /* number of internal columns */
  property      number not null,             /* view properties (bit flags): */
                /* 0x0001 =       1 = this is typed view                     */
                /* 0x0002 =       2 = view has ADT column(s)                 */
                /* 0x0004 =       4 = view has nested table column(s)        */
                /* 0x0008 =       8 = view has REF column(s)                 */
                /* 0x0010 =      16 = view has array column(s)               */
                /* 0x1000 =    4096 = view has primary key-based oid         */
                /* 0x4000 =   16384 = view is read-only                      */
  flags         number not null,                  /* view flags (bit flags): */
		/* 0x0800 =    2048 = view/table has security policy         */
                /* 0x1000 =    4096 = view is insertable via trigger         */
                /* 0x2000 =    8192 = view is updatable via trigger          */
                /* 0x4000 =   16384 = view is deletable via trigger          */
  textlength	number,				      /* length of view text */
  text          long)						/* view text */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table typed_view$                   /* additional info for typed view */
( obj#	          number not null,                          /* object number */
  typeowner       varchar2("M_IDEN"),                   /* owner of row type */
  typename        varchar2("M_IDEN"),                    /* name of row type */
  typetextlength  number,                         /* length of row type text */
  typetext        varchar2("M_VCSZ"),                           /* type text */
  oidtextlength   number,                              /* length of oid text */
  oidtext         varchar2("M_VCSZ"),                            /* oid text */
  transtextlength number,                 /* length of transformed view text */
  transtext       long)                             /* transformed view text */
/
create table seq$
( obj#	        number not null,                            /* object number */
  increment$    number not null,            /* the sequence number increment */
  minvalue      number,                         /* minimum value of sequence */
  maxvalue      number,                         /* maximum value of sequence */
  cycle#        number not null,                      /* 0 = FALSE, 1 = TRUE */
  order$        number not null,                      /* 0 = FALSE, 1 = TRUE */
  cache         number not null,                 /* how many to cache in sga */
  highwater     number not null,                     /* disk high water mark */
  audit$	varchar2("S_OPFL") not null)             /* auditing options */
/
create table procedure$				          /* procedure table */
( obj#          number not null,			    /* object number */
  audit$	varchar2("S_OPFL") not null,		 /* auditing options */
  storagesize   number,				/* storage size of procedure */
  options       number)                     		  /* compile options */
/
create table argument$                     /* procedure argument description */
( obj#           number not null,                           /* object number */
  procedure$     varchar2("M_IDEN"), /* procedure name (if within a package) */
  overload#      number not null,
                /* 0 = not overloaded, n = unique id of overloaded procedure */
  position#      number not null,  /* argument position (0 for return value) */
  sequence#      number not null,
  level#         number not null,
  argument       varchar2("M_IDEN"),/* argument name (null for return value) */
  type#          number not null,                           /* argument type */
  charsetid      number,                                 /* character set id */
  charsetform    number,                               /* character set form */
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  default#       number,   /* null = no default value, 1 = has default value */
  in_out         number,                   /* null = IN, 1 = OUT, 2 = IN/OUT */
  length         number,                                      /* data length */
  precision#     number,                                /* numeric precision */
  scale          number,                                    /* numeric scale */
  radix          number,                                    /* numeric radix */
  deflength      number,             /* default value expression text length */
  default$       long,                      /* default value expression text */
  type_owner     varchar2("M_IDEN"),    /* owner name component of type name */
  type_name      varchar2("M_IDEN"),                            /* type name */
  type_subname   varchar2("M_IDEN"),       /* subname component of type name */
  type_linkname  varchar2("M_XDBI"),       /* db link component of type name */
  pls_type       varchar2("M_IDEN"))                     /* pl/sql type name */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table source$                                         /* source table */
( obj#          number not null,                            /* object number */
  line          number not null,                              /* line number */
  source        varchar2("M_VCSZ"))                           /* source line */
  storage (initial 10k next 200k maxextents unlimited pctincrease 0)
/
create table idl_ub1$                            /* idl table for ub1 pieces */
( obj#          number not null,                            /* object number */
  part          number not null,
         /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  version       number,                                    /* version number */
  piece#        number not null,                             /* piece number */
  length        number not null,                             /* piece length */
  piece         long raw not null)                              /* ub1 piece */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table idl_char$                          /* idl table for char pieces */
( obj#          number not null,                            /* object number */
  part          number not null,
         /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  version       number,                                    /* version number */
  piece#        number not null,                             /* piece number */
  length        number not null,                             /* piece length */
  piece         long not null)                                 /* char piece */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table idl_ub2$                            /* idl table for ub2 pieces */
( obj#          number not null,                            /* object number */
  part          number not null,
         /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  version       number,                                    /* version number */
  piece#        number not null,                             /* piece number */
  length        number not null,                             /* piece length */
  piece         long ub2 not null)                              /* ub2 piece */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table idl_sb4$                            /* idl table for sb4 pieces */
( obj#          number not null,                            /* object number */
  part          number not null,
         /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  version       number,                                    /* version number */
  piece#        number not null,                             /* piece number */
  length        number not null,                             /* piece length */
  piece         long sb4 not null)                              /* sb4 piece */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table dir$                                  /* directory object table */
( obj#          number not null,                            /* object number */
  audit$	varchar2("S_OPFL") not null,		 /* auditing options */
  os_path       varchar2("M_VCSZ"))                        /* OS path string */
/
create table error$                                           /* error table */
( obj#          number not null,                            /* object number */
  sequence#     number default 0 not null,
                                  /* sequence number (for ordering purposes) */
  line          number not null,                       /* source line number */
  position#     number not null,                  /* position in source line */
  textlength    number not null,                 /* length of the error text */
  text          varchar2("M_VCSZ") not null)                   /* error text */
/
create table resource_plan$
( obj#                number not null,                       /* obj# of plan */
  name                varchar2("M_IDEN"),                    /* name of plan */
  mandatory           number,                   /* whether plan is mandatory */
  cpu_method          varchar2("M_IDEN"),  /* cpu resource allocation method */
  mast_method         varchar2("M_IDEN"), /* max. active sess. target method */
  pdl_method          varchar2("M_IDEN"),    /* parallel degree limit method */
  num_plan_directives number,           /* number of directives for the plan */
  description         varchar2("M_CSIZ"),                         /* comment */
  status              varchar2("M_IDEN")        /* whether active or pending */
)
/
create table resource_consumer_group$
( obj#              number not null,                        /* obj# of group */
  name              varchar2("M_IDEN"),                     /* name of group */
  mandatory         number,                    /* whether group is mandatory */
  cpu_method        varchar2("M_IDEN"),    /* cpu resource allocation method */
  description       varchar2("M_CSIZ"),                           /* comment */
  status            varchar2("M_IDEN")          /* whether active or pending */
)
/
create table resource_plan_directive$
( obj#                      number not null,          /* obj# of parent plan */
  plan                      varchar2("M_IDEN"),       /* name of parent plan */
  group_or_subplan          varchar2("M_IDEN"),  /* name of group or subplan */
  is_subplan                number not null,  /* whether the above is a plan */
  description               varchar2("M_CSIZ"),                   /* comment */
  mandatory                 number,    /* whether the directive is mandatory */
  cpu_p1                    number, /* first parameter for cpu alloc. method */
  cpu_p2                    number,   /* second param. for cpu alloc. method */
  cpu_p3                    number, /* third parameter for cpu alloc. method */
  cpu_p4                    number,   /* fourth param. for cpu alloc. method */
  cpu_p5                    number, /* fifth parameter for cpu alloc. method */
  cpu_p6                    number, /* sixth parameter for cpu alloc. method */
  cpu_p7                    number, /* seventh  param. for cpu alloc. method */
  cpu_p8                    number,   /* eighth param. for cpu alloc. method */
  max_active_sess_target_p1 number,                        /* mast parameter */
  parallel_degree_limit_p1  number,                         /* pdl parameter */
  status                    varchar2("M_IDEN")  /* whether active or pending */
)
/
create table trigger$				            /* trigger table */
( obj#    	number not null,			    /* object number */
  type#         number not null,                            /* trigger type: */
        /*  0 = BEFORE TABLE, 1 = BEFORE ROW, 2 = AFTER TABLE, 3 = AFTER ROW */
                                                   /* 4 = INSTEAD OF TRIGGER */
  update$       number not null, 	   		   /* fire on update */
  insert$       number not null,			   /* fire on insert */
  delete$       number not null,			   /* fire on delete */
  baseobject 	number not null,                   	/* triggering object */
  refoldname    varchar2("M_IDEN"),		     /* old referencing name */
  refnewname    varchar2("M_IDEN"),		     /* new referencing name */
  definition    varchar2("M_VCSZ"),		       /* trigger definition */
  whenclause    varchar2("M_VCSZ"),                   /* text of when clause */
  action#       long,	 	   	           	   /* action to fire */
  actionsize    number,				      /* size of action text */
  enabled       number,                         /* 0 = DISABLED, 1 = ENABLED */
  property      number not null,          /* trigger properties (bit flags): */
                                                /* 0x01 = baseobject is view */
                                                /* 0x02 = Call style trigger */
                                                /* 0x04 = Java Trigger       */
                                            /* 0x08 = baseobject is database */
                                              /* 0x10 = baseobject is schema */
                                              /* 0x20 = Nested table trigger */
                                                 /* 0x40 = baseobject is IOT */
  sys_evts      number,                                     /* system events */
  nttrigcol     number,               /* intcol# on which trigger is defined */
  nttrigatt     number,                    /* attribute number within column */
  refprtname    varchar2("M_IDEN")                /* PARENT referencing name */ 
)
/
create table triggercol$
( obj#          number not null,                            /* object number */
  col#          number not null,                            /* column number */
  type#         number not null,                /* type of column reference: */
     /* 6 = OLD IN-ARG, 5 = NEW IN-ARG, 9 = NEW OUT-VAR, 13 = NEW IN/OUT-VAR */
                                                  /* 0x14 = 20 PARENT IN-ARG */
  position#     number,                               /* position in trigger */
  intcol#       number not null)                   /* internal column number */
/
create table reg$
( subscription_name varchar2(128) not null,
  location_name     varchar2(256) not null,
  user#             number not null,
  user_context      raw(128) not null,
  context_size      number not null,
  namespace         number)
/
create table loc$
( location_name     varchar2(256) not null,
  emon#             number,
  connection#       number)
/
REM  The following four tables for 8.1 SDK2 specific.
REM  They should be removed before 8.1 beta, assuming we use ILMS
REM services for JAVA trigger invocation. 
create table triggerjavaf$
( obj#          number not null,                            /* object number */
  flags         long raw,                                  /* ub1 flag array */
  flaglength    number)                          /* length of ub1 flag array */
/
create table triggerjavas$
( obj#          number not null,                            /* object number */
  signature     long not null,                           /* method signature */
  siglength     number not null)               /* length of method signature */
/
create table triggerjavac$
( obj#          number not null,                            /* object number */
  ownername     varchar2("M_IDEN") not null,             /* class owner name */
  ownerlength   number not null,               /* length of class owner name */
  classname     long not null,                          /* method class name */
  classlength   number not null)              /* length of method class name */
/
create table triggerjavam$
( obj#          number not null,                            /* object number */
  methodname    long not null,                                /* method name */
  methodlength  number not null,                 /* length of ub1 flag array */
  cookiesize    number not null)                              /* cookie size */
/
create table objauth$                           /* table authorization table */
( obj#          number not null,                            /* object number */
  grantor#      number not null,                      /* grantor user number */
  grantee#      number not null,                      /* grantee user number */
  privilege#    number not null,                   /* table privilege number */
  sequence#     number not null,                    /* unique grant sequence */
  parent        rowid,                                             /* parent */
  option$	number,                     /* null = none, 1 = grant option */
  col#          number)     /* null = table level, column id if column grant */
/
create table sysauth$                          /* system authorization table */
( grantee# 	number not null,          /* grantee number (user# or role#) */
  privilege# 	number not null,                      /* role or privilege # */
  sequence#	number not null, 		    /* unique grant sequence */
  option$	number)                     /* null = none, 1 = admin option */
/
create table objpriv$                       /* privileges granted to objects */
( obj#          number not null,                            /* object number */
  privilege# 	number not null)                         /* privilege number */
/
create table defrole$                                  /* default role table */
( user#		number not null, 				  /* user id */
  role#		number not null)  			  /* default role id */
/
create table profile$                                    /* resource profile */
( profile#	number not null,   /* user$.resource$ and profname$.profile# */
  resource#	number not null,                          /* resource number */
  type#		number not null,  /* 0 = kernel resource, else tool resource */
  limit#	number not null)                           /* resource limit */
/
create table profname$                /* mapping of profile# to profile name */
( profile#	number not null,
  name		varchar2("M_IDEN") not null)
/
create table dependency$                                 /* dependency table */
( d_obj#        number not null,                  /* dependent object number */
  d_timestamp   date not null,   /* dependent object specification timestamp */
  order#        number not null,                             /* order number */
  p_obj#        number not null,		     /* parent object number */
  p_timestamp   date not null,      /* parent object specification timestamp */
  d_owner#      number not null,                  /*  dependent owner number */
  property      number not null)                   /* 0x01 = HARD dependency */
                                                   /* 0x02 = REF  dependency */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table access$                                         /* access table */
( d_obj#        number not null,                  /* dependent object number */
  order#        number not null,                  /* dependency order number */
  columns       raw("M_BVCO"),                /* list of cols for this entry */
  types         number not null)                             /* access types */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table aud$					/* audit trail table */
( sessionid     number not null,
  entryid	number not null,
  statement	number not null,
  timestamp#	date not null,
  userid	varchar2("M_IDEN"),
  userhost	varchar2("M_HOST"),
  terminal	varchar2("M_TERM"),
  action#	number not null,
  returncode	number not null,
  obj$creator	varchar2("M_IDEN"),
  obj$name	varchar2("M_XDBI"),
  auth$privileges varchar2("S_PRFL"),
  auth$grantee	varchar2("M_IDEN"),
  new$owner     varchar2("M_IDEN"),
  new$name	varchar2("M_XDBI"),
  ses$actions	varchar2("S_ACFL"),
  ses$tid	number,
  logoff$lread	number,
  logoff$pread	number,
  logoff$lwrite number,
  logoff$dead	number,
  logoff$time	date,
  comment$text	varchar2("M_VCSZ"),
  spare1        varchar2(255),
  spare2        number,
  obj$label     raw(255),                         /* OBSOLETE: 8.0 and above */
  ses$label     raw(255),                         /* OBSOLETE: 8.0 and above */
  priv$used     number)
/
create table link$                             /* remote database link table */
( owner#        number not null,                        /* owner user number */
  name          varchar2("M_XDBI") not null,              	/* link name */
  ctime	        date not null,                              /* creation time */
  host	        varchar2("M_CNCT"),    /* optional driver string for connect */
  userid        varchar2("M_IDEN"),             /* optional user to logon as */
  password      varchar2("M_IDEN"),                    /* password for logon */
  flag          number,                        /* to identify type of dblink */
  authusr      varchar2("M_IDEN"),             /* optional user to logon as */
  authpwd      varchar2("M_IDEN"))                    /* password for logon */
/
create table trusted_list$            /* trusted list for privileged dblinks */
( dbname        varchar2("M_XDBI") not null,                /* database name */
  username      varchar2("M_VCSZ") not null)                    /* user name */
/
insert into trusted_list$ values ('+*','*')     /* default value - allow all */
/
create table props$
( name          varchar2("M_IDEN") not null,                /* property name */
  value$        varchar2("M_VCSZ"),                        /* property value */
  comment$      varchar2("M_VCSZ"))               /* description of property */
/
create table com$                                           /* comment table */
( obj#          number not null,                            /* object number */
  col#          number,		       /* column number (NULL if for object) */
  comment$	varchar2("M_VCSZ"))	       /* user-specified description */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create table resource_cost$
( resource#	number not null,                         /* 2, 4, 6, 7, 8, 9 */
  cost		number not null)                                     /* >= 0 */
/
insert into resource_cost$ values (0, 0)                         /* not used */
/
insert into resource_cost$ values (1, 0)                /* sessions_per_user */
/
insert into resource_cost$ values (2, 0)                  /* cpu_per_session */
/
insert into resource_cost$ values (3, 0)                         /* not used */
/
insert into resource_cost$ values (4, 0)        /* logical_reads_per_session */
/
insert into resource_cost$ values (5, 0)                         /* not used */
/
insert into resource_cost$ values (6, 0)                         /* not used */
/
insert into resource_cost$ values (7, 0)                     /* connect_time */
/
insert into resource_cost$ values (8, 0)                      /* private_sga */
/
insert into resource_cost$ values (9, 0)                         /* not used */
/
insert into props$ 
values('DICT.BASE', '2', 'dictionary base tables version #')
/
create unique index i_view1 on view$(obj#)
/
create unique index i_typed_view1 on typed_view$(obj#)
/
create unique index i_syn1 on syn$(obj#)
/
create unique index i_seq1 on seq$(obj#)
/
create unique index i_objauth1 on 
  objauth$(obj#, grantor#, grantee#, privilege#, col#)
/
create index i_objauth2 on objauth$(grantee#, obj#, col#)
/
create unique index i_sysauth1 on sysauth$(grantee#, privilege#)
/
create unique index i_defrole1 on defrole$(user#, role#)
/
create index i_aud1 on aud$(sessionid, ses$tid)
/
create index i_link1 on link$(owner#, name)
/
create unique index i_com1 on com$(obj#, col#)
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create unique index i_procedure1 on procedure$(obj#)
/
create unique index i_argument1 on 
  argument$(obj#, procedure$, overload#, sequence#)
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create unique index i_source1 on source$(obj#, line)
  storage (initial 10k next 200k maxextents unlimited pctincrease 0)
/
create unique index i_idl_ub11 on
  idl_ub1$(obj#, part, version, piece#)
/
create unique index i_idl_char1 on
  idl_char$(obj#, part, version, piece#)
/
create unique index i_idl_ub21 on
  idl_ub2$(obj#, part, version, piece#)
/
create unique index i_idl_sb41 on
  idl_sb4$(obj#, part, version, piece#)
/
create unique index i_dir1 on dir$(obj#)
/
create index i_error1 on error$(obj#, sequence#)
/
create unique index i_dependency1 on
  dependency$(d_obj#, d_timestamp, order#) 
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create index i_dependency2 on
  dependency$(p_obj#, p_timestamp)
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create index i_access1 on
  access$(d_obj#, order#) 
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create index i_trigger1 on trigger$(baseobject)
/                                             
create unique index i_trigger2 on trigger$(obj#)
/
create index i_triggercol1 on triggercol$(obj#, col#, type#, position#)
/
create index i_triggercol2 on triggercol$(obj#, intcol#, type#, position#)
/
create unique index i_triggerjavaf on triggerjavaf$(obj#)
/
create unique index i_triggerjavas on triggerjavas$(obj#)
/
create unique index i_triggerjavac on triggerjavac$(obj#)
/
create unique index i_triggerjavam on triggerjavam$(obj#)
/
create unique index i_profname on profname$(name)
/
create index i_profile on profile$(profile#)
/
create sequence ugroup_sequence   /* sequence for undo group    cache (lab$) */
  increment by 1
  start with 1
  minvalue 0
  nomaxvalue
  cache 10
  order
  nocycle
/
create sequence object_grant                 /* object grant sequence number */
  start with 1
  increment by 1
  minvalue 1
  nomaxvalue
  cache 20
  order
  nocycle
/
create sequence system_grant                 /* system grant sequence number */
  start with 1
  increment by 1
  minvalue 1
  nomaxvalue
  cache 20
  order
  nocycle
/
create sequence profnum$                   /* profile number sequence number */
  increment by 1
  start with 0                              /* profile# for DEFAULT always 0 */
  minvalue 0
  nocache                                           /* don't want to reuse 0 */
/
create profile "DEFAULT" limit            /* default value, always present */
  composite_limit		unlimited                   /* service units */
  sessions_per_user		unlimited              /* logins per user id */
  cpu_per_session		unlimited            /* cpu usage in minutes */
  cpu_per_call			unlimited        /* max cpu minutes per call */
  logical_reads_per_session	unlimited
  logical_reads_per_call	unlimited
  idle_time			unlimited
  connect_time 			unlimited
  private_sga			unlimited      /* valid only with TP-monitor */
  failed_login_attempts	        unlimited
  password_life_time	        unlimited
  password_reuse_time	        unlimited
  password_reuse_max            unlimited
  password_verify_function      null
  password_lock_time	        unlimited
  password_grace_time	        unlimited
/
create table incexp                      /* incremental export support table */
( owner#        number not null,                                 /* owner id */
  name          varchar2("M_IDEN") not null,                  /* object name */
  type#	        number not null,                              /* object type */
  ctime	        date,                      /* time of last cumulative export */
  itime	        date not null,            /* time of last incremental export */
  expid         number(3) not null)                             /* export id */
/
create unique index i_incexp on incexp(owner#, name, type#)
/
create user sys identified by change_on_install
/
create role public
/
create role connect
/
grant create session,alter session,create synonym,create view,
  create database link,create table,create cluster,create sequence to connect
/
create role resource
/
grant create table,create cluster,create sequence,create trigger,
 create procedure, create type, create indextype, create operator
 to resource
/
create role dba
/
grant all privileges to dba with admin option
/
create user system identified by manager
/
grant dba to system with admin option
/
grant all on incexp to system
/
create table incvid                    /* incremental valid identifier table */
( expid         number(3) not null)               /* id of last valid export */
/
insert into incvid(expid) values (0)
/
grant all on incvid to system
/
create table incfil                         /* incremental file export table */
( expid         number(3) not null,                             /* export id */
  exptype       varchar2(1) not null,                        /* export type: */
                            /* X - complete, I - incremental, C - cumulative */
  expfile       varchar2(100) not null,                  /* export file name */
  expdate       date not null,                                /* export date */
  expuser       varchar2("M_IDEN") not null)            /* user doing export */
/
grant all on incfil to system
/
create table "_default_auditing_options_"   /* default auditing option table */
( a             varchar2(1))                              /* auditing option */
/
create sequence audses$                               /* auditing session id */
  start with 1
  increment by 1
  minvalue 1
  maxvalue 2E9                                     /* maxvalue fits in a ub4 */
  cycle
  cache 20
  noorder
/
create table audit$                                 /* auditing option table */
( user#		number not null,                   /* user identifier number */
  proxy#        number, /* UID of the proxy user.
                        ** Special values:
                        ** NULL = no proxy authentication
                        ** 0 = all proxies may authenticate the user
                        */
  option#       number not null,                   /* auditing option number */
  success       number,                                 /* audit on success? */
  failure       number)                                 /* audit on failure? */
               /* null = no audit, 1 = audit by session, 2 = audit by access */
/
create unique index i_audit on audit$(user#, proxy#, option#)
                       /* this index is more for uniqueness than performance */
/
create table pending_trans$		/* pending or "indoubt" transactions */
( local_tran_id	  varchar2("M_LTID") not null, /* print form of kxid (local) */
  global_tran_fmt integer not null,               /* global tran format code */
  global_oracle_id  varchar2("M_GTID"),                      /* Oracle k2gti */
  global_foreign_id raw("M_GTID"),                       /* non-Oracle k2gti */
  tran_comment	  varchar2("M_XCMT"),             /* commit/rollback comment */
  state		  varchar2(16) not null,       /* see k2.h: k2sta (tx state) */
  status          varchar2(1) not null,                   /* Pending, Damage */
  heuristic_dflt  varchar2(1),                  /* advice: Commit/Rollback/? */
  session_vector  raw(4) not null,              /* bit map of pending sess's */
  reco_vector	  raw(4) not null,             /* map of sess's rdy for reco */
  type#		  number,  /* loosely-coupled or tightly-coupled transaction */
  fail_time	  date not null,                            /* time inserted */
  heuristic_time  date,                        /* time of heuristic decision */
  reco_time	  date not null,               /* last time tried (exp.b.o.) */
  top_db_user     varchar2("M_IDEN"),        /* top level DB session created */
  top_os_user     varchar2("M_UNML"),              /* top level OS user name */
  top_os_host	  varchar2("M_HOST"),         /* top level user OS host name */
  top_os_terminal varchar2("M_TERM"),            /* top level OS terminal id */
  global_commit#  varchar2(16),               /* global system commit number */
  spare1          number,
  spare2          varchar2("M_IDEN"),
  spare3          number,
  spare4          varchar2("M_IDEN")
)
/
create unique index i_pending_trans1 on pending_trans$(local_tran_id)
  /* this index is not for performance, but rather to ensure uniqueness */
/
create table pending_sessions$		          /* child of pending_trans$ */
( local_tran_id   varchar2("M_LTID") not null,	            /* 1:n w/ parent */
  session_id	  smallint not null,
  branch_id	  raw("M_GBID") not null,                        /* of local */
  interface	  varchar2(1) not null,	         /* C=commit/confirm, P=prep */
  type#		  number,  	/* loosely-coupled or tightly-coupled branch */
  parent_dbid	  varchar2("M_IDBI"),  		   /* null string->top level */
  parent_db	  varchar2("M_XDBI"),      /* global name of parent database */
  db_userid	  integer not null)                 /* creator of DB session */
/
create table pending_sub_sessions$	       /* child of pending_sessions$ */
( local_tran_id   varchar2("M_LTID") not null,	/* w/session_id,1:n w/parent */
  session_id	  smallint not null,                             /* of local */
  sub_session_id  smallint not null, /* session,sub_session is remote branch */
  interface	  varchar2(1) not null,		 /* C=hold commit, N=no hold */
  dbid		  varchar2("M_IDBI") not null,			/* of remote */
  link_owner	  integer not null,			  /* owner of dblink */
  dblink	  varchar2("M_XDBI") not null,
  branch_id	  raw("M_GBID"),	 	 /* branch id of sub session */
  spare	  	  raw("M_GBID"))     	       /* spare field for future use */
/
create table sumdelta$           /* sumdelta table */
( tableobj#     number not null, /* detail table obj# loaded */
  partitionobj# number not null, /* partition obj# that was loaded */
  dmloperation  char(1),         /* I=insert, D=delete */
  scn           number not null, /* SCN when the bulk DML occurred. */
  timestamp     date not null,   /* Time when the bulk DML occurred. */
  lowrowid      rowid not null,  /* low rowid modified in this partition. */
  highrowid     rowid not null,  /* high rowid modified in this partition. */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create unique index i_sumdelta$ on 
  sumdelta$(tableobj#, partitionobj#, timestamp, lowrowid, highrowid) 
/ 
CREATE TABLE snap_logdep$ (                           /* slog$ for sumdelta$ */
  tableobj#  number,                             /* obj# of the master table */
  snapid     integer,           /* internal id of the snapshot using the log */
  snaptime   date)                  /* time of last refresh for the snapshot */
/ 
create unique index i_snap_logdep1 on snap_logdep$(tableobj#, snapid)
/
CREATE TABLE snap_loadertime$ (                       /* mlog$ for sumdelta$ */
  tableobj#  number,                             /* obj# of the master table */
  oldest     date,                /* oldest information for the master table */
  youngest   date,                 /* most recent refresh timestamp assigned */
  flag       number)                            /* (reserved for future use) */
/
create unique index i_snap_loadertime1 on snap_loadertime$(tableobj#)
/
create cluster c_mlog# (master varchar2("M_IDEN"),
                        mowner varchar2("M_IDEN"))
/
create index i_mlog# on cluster c_mlog#
/
create table mlog$          /* list of local master tables used by snapshots */
( mowner          varchar2("M_IDEN") not null,            /* owner of master */
  master          varchar2("M_IDEN") not null,             /* name of master */
  oldest          date,       /* maximum age of rowid information in the log */
  oldest_pk       date,          /* maximum age of PK information in the log */
  oscn            number,                                   /* scn of oldest */
  youngest        date,                     /* most recent snaptime assigned */
  yscn            number,                   /* set-up scn;  identifies group */
                                          /* of rows set up at time youngest */
  log             varchar2("M_IDEN") not null,                /* name of log */
  trig            varchar2("M_IDEN"),           /* trigger on master for log */
  flag            number,       /* 0x0001, log contains rowid values         */
                                /* 0x0002, log contains primary key values   */
                                /* 0x0004, log contains filter column values */
                                /* 0x0008, log is imported                   */
                                /* 0x0010, log is created with temp table    */
  mtime           date not null,                    /* DDL modification time */
  temp_log        varchar2("M_IDEN"))/* temp table as updatable snapshot log */
cluster c_mlog# (master, mowner)
/
create table slog$                     /* list of snapshots on local masters */
( mowner          varchar2("M_IDEN") not null,            /* owner of master */
  master          varchar2("M_IDEN") not null,             /* name of master */
  snapshot        date,                 /* identifies V7 snapshots: obsolete */
  snapid          integer,                        /* identifies V8 snapshots */
  sscn            number,                                 /* scn of snapshot */
  snaptime        date               not null,        /* when last refreshed */
  tscn            number,                                 /* scn of snaptime */
  user#           number)                  /* userid for security validation */
cluster c_mlog# (master, mowner)
/
create index i_slog1 on slog$(snaptime)
/
create table snap$                                /* list of local snapshots */
( sowner          varchar2("M_IDEN") not null,          /* owner of snapshot */
  vname           varchar2("M_IDEN") not null,      /* name of snapshot view */
  tname           varchar2("M_IDEN") not null,     /* name of snapshot table */
  mview           varchar2("M_IDEN"),          /* view snapshot is made from */
  mowner          varchar2("M_IDEN"),                     /* owner of master */
  master          varchar2("M_IDEN"),                      /* name of master */
  mlink           varchar2("M_XDBI"),        /* database link to master site */
  can_use_log     varchar2(1),                                     /* unused */
  snapshot        date,       /* used by V7 masters to identify the snapshot */
  snapid          integer,    /* used by V8 masters to identify the snapshot */
  sscn            number,                                 /* scn of snapshot */
  snaptime        date,   /* when this snapshot was last refreshed: OBSOLETE */
  tscn            number,                                 /* scn of snaptime */
  error#          number,          /* last error caused by automatic refresh */
  auto_fast       varchar2(1),        /* date function for automatic refresh */
  auto_fun        varchar2("M_DATF"),             /* obsolete, 7.1 and above */
  auto_date       date,                           /* obsolete, 7.1 and above */
  refgroup        number,                                          /* unused */
  ustrg           varchar2("M_IDEN"),     /* trigger for updatable snapshots */
  uslog           varchar2("M_IDEN"),         /* log for updatable snapshots */
  status          integer,  /* 0x0000, Need to regenerate refresh operations */
                            /* 0x0001, fast refresh operations generated     */
                            /* 0x0002, complete refresh operations generated */
  master_version  integer,              /* Oracle version of the master site */
                                                              /* (1) -> V7.x */
                                                              /* (2) -> V8.0 */
  tables          integer,  /* number of tables in snapshot definition query */
  field1          number,                                  /* for future use */
  field2          varchar2("M_IDEN"),                      /* for future use */
  flag            number,                   /* 0x0001, can use master log    */
                                            /* 0x0002, snapshot is updatable */
                                            /* 0X0010, ROWID snapshot        */
                                            /* 0x0020, PRIMARY KEY snapshot  */
  query_txt       long,                /* query which this view instantiates */
  lobmaskvec      raw(255),                       /* lob columns mask vector */
  mtime           date not null,                    /* DDL modification time */
  mas_roll_seg    varchar2("M_IDEN"),        /* master-side rollback segment */
  rscn		  number,		 	  	 /* last refresh scn */
  refhnt	  number,                                    /* refresh hint */
  query_len       integer,            /* length of snapshot definition query */
  instsite        integer default 0,                   /* instantiating site */
  flavor_id       number                                       /* flavor id */
)
/
create unique index i_snap1 on snap$(vname, sowner, instsite)
/
create sequence snapshot_id$                         /* Snapshot ID sequence */
  increment by 1
  start with 1
  minvalue 1
  maxvalue 2147483647     /* max value that is guaranteed to fit into an SB4 */
  nocycle
/
create table snap_reftime$
( sowner          varchar2("M_IDEN") not null,          /* owner of snapshot */
  vname           varchar2("M_IDEN") not null,      /* name of snapshot view */
  tablenum        integer not null,   /* order of master table in snap query */
  snaptime        date,                    /* time of last refresh for table */
  mowner          varchar2("M_IDEN"),                     /* owner of master */
  master          varchar2("M_IDEN"),                      /* name of master */
  masflag         number,                  /* additional master information: */
                                    /* (0x0001) is a fact table              */
                                    /* (0x0002) can be foreign key optimized */
  masobj#         number,                        /* obj# of the master table */
  loadertime      date,       /* last refresh with respect to SQL*Loader log */
  refscn          number,   /* scn of latest info used to refresh this table */
  instsite        integer default 0,                   /* instantiating site */
  lastsuccess     date,             /* time of last known successful refresh */
  fcmaskvec       raw(255),                    /* filter columns mask vector */
  ejmaskvec       raw(255)                  /* equi-join columns mask vector */
)
/
create unique index i_snap_reftime1 on 
  snap_reftime$(vname, sowner, instsite, tablenum)
/
create table mlog_refcol$             /* list of snapshot log filter columns */
( mowner          varchar2("M_IDEN") not null,            /* owner of master */
  master          varchar2("M_IDEN") not null,             /* name of master */
  colname         varchar2("M_IDEN") not null,   /* master table column name */
  oldest          date,          /* maximum age of information in the column */
  flag            integer)                       /* column meta information: */
/
create unique index i_mlog_refcol1 on mlog_refcol$(mowner, master, colname)
/
create table snap_refop$            /* fast refresh operations for snapshots */
( sowner          varchar2("M_IDEN") not null,          /* owner of snapshot */
  vname           varchar2("M_IDEN") not null,      /* name of snapshot view */
  tabnum          integer not null,   /* order of table in subquery chain    */
                                      /* the master table is indicated by 1  */
  operation#      integer not null,   /* operation type (see kkzrff, kkzrei) */
                                      /* FAST REFRESH OPERATIONS (outer tab) */
                                      /* 0 -> SELECT for delete phase        */
                                      /* 1 -> DELETE statement               */
                                      /* 2 -> SELECT for upd/ins phase       */
                                      /* 3 -> UPDATE statement               */
                                      /* 4 -> INSERT statement               */
                                      /* 5 -> DELETE local inserts (if upd)  */
                                      /* FAST REFRESH OPERATIONS (inner tab) */
                                      /* 0 -> SELECT for delete phase        */
                                      /* 1 -> DELETE statement               */
                                      /* 2 -> SELECT for insert phase        */
                                      /* 3 -> INSERT statement               */
                                      /* COMPLETE REFRESH OPERATIONS         */
                                      /* 6 -> Insert as Select               */
  cols            number,     /* columns in the select list, 0 if not SELECT */
  fcmaskvec       raw(255),        /* obsolete -  filter columns mask vector */
  ejmaskvec       raw(255),       /* obsolete -equi-join columns mask vector */
  sql_txt         long,                /* query which this view instantiates */
  instsite        integer default 0)                   /* instantiating site */
/
create unique index i_snap_refop1 on 
  snap_refop$(sowner, vname, instsite, operation#, tabnum)
/
create table snap_colmap$            /* snapshot column aliasing information */
( sowner          varchar2("M_IDEN") not null,          /* owner of snapshot */
  vname           varchar2("M_IDEN") not null,      /* name of snapshot view */
  snacol          varchar2("M_IDEN") not null,    /* name of snapshot column */
  tabnum          integer not null,   /* order of master table in snap query */
  mascol          varchar2("M_IDEN"),                  /* master column name */
  maspos          integer,             /* position of master column (intcol) */
  colrole         number,                         /* how is this column used */
  instsite        integer default 0,                   /* instantiating site */
  snapos          integer default 0     /* position of col in snapshot table */
)
/
create unique index i_snap_colmap1 on 
  snap_colmap$(sowner, vname, instsite, tabnum, snacol)
/
create table reg_snap$            /* snapshots that use masters on this site */
( sowner          varchar2("M_IDEN") not null,          /* owner of snapshot */
  snapname        varchar2("M_IDEN") not null,           /* name of snapshot */
  snapsite        varchar2("M_XDBI") not null,       /* location of snapshot */
  snapshot_id     integer,                        /* identifies the snapshot */
  flag            number,                            /* updatable, PK, rowid */
  rep_type        number,                        /* type of replicating site */
  comment$        varchar2("M_VCSZ"),                 /* comment on snapshot */
  query_txt       long)                 /* query that this view instantiates */
/
create unique index i_reg_snap1 on reg_snap$(sowner, snapname, snapsite)
/
create index i_reg_snap2 on reg_snap$(snapshot_id)
/
create table snap_site$                      /* mapping of site names to IDs */
( site_name  varchar2("M_XDBI") not null,                       /* site name */
  site_id    integer                                              /* site ID */
)
/
create unique index i_snap_site1 on snap_site$(site_name)
/
create sequence snapsite_id$                    /* snapshot Site ID sequence */
  increment by 1
  start with 1
  minvalue 1
  maxvalue 4294967295                           /* max portable value of UB4 */
  nocycle
/
rem 
rem  Job Queue
rem
create sequence jobseq
  start with 1
  increment by 1
  minvalue 1
  maxvalue 999999999                        /* should be less than MAXSB4VAL */
  cache 20
  noorder
  cycle
/
create table job$
( job             number not null,                  /* identifier of the job */
  lowner          varchar2("M_IDEN") not null,             /* logged in user */
  powner          varchar2("M_IDEN") not null,                   /* security */
  cowner          varchar2("M_IDEN") not null,                    /* parsing */
  last_date       date,                      /* when this job last succeeded */
  this_date       date,    /* when the current execute started, usually null */
  next_date       date not null,             /* when to execute the job next */
  total           number default 0 not null, /* total time spent on this job */
  interval#       varchar2("M_DATF") not null,/* function for next next_date */
  failures        number,           /* number of failures since last success */
  flag            number default 0 not null,     /* 0x01, this job is broken */
  what            varchar2("M_VCSZ"),        /* PL/SQL text, what is the job */
  nlsenv          varchar2("M_VCSZ"),                      /* nls parameters */
  env             raw(32),                    /* other environment variables */
  cur_ses_label   mlslabel,                       /* OBSOLETE: 8.0 and above */
  clearance_hi    mlslabel,                       /* OBSOLETE: 8.0 and above */
  clearance_lo    mlslabel,                       /* OBSOLETE: 8.0 and above */
  charenv         varchar2("M_VCSZ"),         /* Reserved for Trusted Oracle */
  field1          number default 0) /* instance number restricted to run  job*/
/
create unique index i_job_job on job$ (job)
/
create index i_job_next on job$ (next_date)
/
rem
rem  Refresh Groups
rem
create sequence rgroupseq
  start with 1
  increment by 1
  minvalue 1
  maxvalue 999999999                        /* should be less than MAXSB4VAL */
  cache 20
  noorder
  cycle
/
create cluster c_rg#
( refgroup        number)                            /* refresh group number */
/
create index i_rg# on cluster c_rg#
/
create table rgroup$
( refgroup         number,                        /* number of refresh group */
  owner            varchar2("M_IDEN") not null,    /* owner of refresh group */
  name             varchar2("M_IDEN") not null,     /* name of refresh group */
  flag             number default 0,       /* 0x01, destroy group when empty */
                                                 /* 0x02, do not push queues */
                                               /* 0x04, refresh after errors */
                                               /* 0x08, RepAPI refresh group */
  rollback_seg     varchar2("M_IDEN"),            /* rollback segment to use */
  field1           number default 0,
  job              number not null,  /* job in job$ for refreshing this group */
  purge_opt#       integer,      /* purge_opt#, parallelism#, and heap_size# */
  parallelism#     integer,      /* are parameters for parallel propagation  */
  heap_size#       integer,      /* in V8                                    */
  instsite         integer default 0,                    /* snapshot site id */
  refresh_sequence number                     /* refresh sequence for RepAPI */
)
cluster c_rg# (refgroup)
/
create unique index i_rgroup on rgroup$ (owner, name, instsite)
/
create unique index i_rgref on rgroup$ (refgroup)
/
create index i_rgjob on rgroup$ (job)
/
create table rgchild$
( owner           varchar2("M_IDEN") not null,             /* owner of child */
  name            varchar2("M_IDEN") not null,              /* name of child */
  type#           varchar2("M_IDEN") default 'SNAPSHOT',   /* type of object */
  field1          number default 0,
  refgroup        number,                   /* refresh group the child is in */
  instsite        integer default 0                      /* snapshot site id */
)
cluster c_rg# (refgroup)
/
create unique index i_rgchild on rgchild$ (owner, name, instsite, type#)
/
rem
rem  Drop User Cascade
rem
create table duc$
( owner           varchar2("M_IDEN") not null,            /* procedure owner */
  pack            varchar2("M_IDEN") not null,          /* procedure package */
  proc            varchar2("M_IDEN") not null,             /* procedure name */
  field1          number default 0,
  operation#      number not null,                    /* 1=drop user cascade */
  seq             number not null,            /* for ordering the procedures */
  com             varchar2(80))       /* comment on what this routine is for */
/
create unique index i_duc on duc$ (owner,pack,proc,operation#)
/
rem
rem  Histograms
rem
create cluster c_obj#_intcol#
( obj#            number,                                   /* object number */
  intcol#         number)                          /* internal column number */
  pctfree 5
/
create index i_obj#_intcol# on cluster c_obj#_intcol#
/
create table histgrm$                                     /* histogram table */
( obj#            number not null,                          /* object number */
  col#            number not null,                          /* column number */
  row#            number,                       /* row number (in row cache) */
  bucket          number not null,                          /* bucket number */
  endpoint        number not null,                  /* endpoint hashed value */
  intcol#         number not null,                 /* internal column number */
  epvalue         varchar2(1000),              /* endpoint value information */
  spare1          number,
  spare2          number)
cluster c_obj#_intcol#(obj#, intcol#)
/
create index i_h_obj#_col# on histgrm$(obj#, col#)
/

create table hist_head$                            /* histogram header table */
 (obj#            number not null,                          /* object number */
  col#            number not null,                          /* column number */
  bucket_cnt      number not null,                      /* number of buckets */
  row_cnt         number not null,             /* number of rows in histgrm$ */
  cache_cnt       number,                     /* number of rows in row cache */
  null_cnt        number,                  /* number of nulls in this column */
  timestamp#      date,                   /* date of histogram's last update */
  sample_size     number,             /* for estimated stats, size of sample */
  minimum         number,           /* minimum value (if 1-bucket histogram) */
  maximum         number,           /* minimum value (if 1-bucket histogram) */
  distcnt         number,                            /* # of distinct values */
  lowval          raw(32),
                        /* lowest value of column (second lowest if default) */
  hival           raw(32),
                      /* highest value of column (second highest if default) */
  density         number,                                   /* density value */
  intcol#         number not null,                 /* internal column number */
  spare1          number,                /* sample number of distinct values */
  spare2          number,                                           /* flags */
                    /* 0x01 = user-specified stats                           */
                    /* 0x02 = global stats                                   */
                    /* 0x04 = endpoint actual values in histogram            */
  avgcln          number,                           /* average column length */
  spare3          number,                                           /* spare */
  spare4          number                                            /* spare */
  )

/
create index i_hh_obj#_col# on hist_head$(obj#, col#)
/
create index i_hh_obj#_intcol# on hist_head$(obj#, intcol#)
/

create table dual                   /* pl/sql's standard pckg requires dual. */
  (dummy varchar2(1))    /* note, the optimizer knows sys.dual is single row */
  storage (initial 1)
/
insert into dual values('X')
/
create public synonym dual for dual
/
grant select on dual to public with grant option
/
rem Dual and this sequence are required by the parallel query option.
create sequence ora_tq_base$
  start with 1
  increment by 1
  nominvalue
  maxvalue 4294967  /* Ceiling as anything higher causes overflow internally */
  nocache
  noorder
  cycle                        /* Needed to complement the ceiling specified */
/

rem
rem  Partitioned Objects
rem

rem partition name sequence
rem This sequence is used to generate names for new partitions 
rem and subpartitions
create sequence partition_name$
  start with 1
  increment by 1
  minvalue 1
  nomaxvalue
  nocycle
  noorder
  cache 20
/
rem
rem partobj$ table
rem This table has a row per partitioned object
rem obj# is the key
rem There is a unique index on obj#
rem
create table partobj$ (
  obj#        number not null,/* object number of partitioned table or index */
  parttype    number not null,                          /* partitioning type */
             /* 1 = range, 2 = hash, 3 = system; if range, */
	     /* subparttype may be non-zero to indicate type of */
	     /* Range Composite partitioning method */
             /* see subparttype for form of Range Composite partitioning 
	     /* used */
  partcnt     number not null,                       /* number of partitions */
  partkeycols number not null,      /* number of columns in partitioning key */
  flags       number,               /* 1 = local index, 2 = prefixed index   */
  defts#      number,                           /* default tablespace number */
  defpctfree  number not null,                            /* default PCTFREE */
  defpctused  number not null,          /* default PCTUSED (N/A for indexes) */
  defpctthres number,               /* default PCTTHRESHOLD (N/A for tables) */
  definitrans number not null,                           /* default INITRANS */
  defmaxtrans number not null,                           /* default MAXTRANS */
  deftiniexts number,                         /* default INITIAL extent size */
  defextsize  number,                            /* default NEXT extent size */
  defminexts  number,                                  /* default MINEXTENTS */
  defmaxexts  number,                                  /* default MAXEXTENTS */
  defextpct   number,                                 /* default PCTINCREASE */
  deflists    number not null,                    /* default FREELISTS value */
  defgroups   number not null,  /* default FREELIST GROUPS (N/A for indexes) */
  deflogging  number not null,   /* default logging attribute of the object: */
			      /* 0 - unspecified; 1 - LOGGING; 2 - NOLOGGING */
  spare1      number,                           /* default BUFFER_POOL value */

  /* 4 bytes of spare2 are currently spoken for */
  /* byte 0: subparttype - non-zero implies Composite partitioning */
  /* (2 - Hash, 3 - System); byte 1: subpartkeycols, bytes 2-3: defsubpartcnt*/
  spare2      number,                       

  spare3      number,                                       /* spare column  */
  definclcol  number)       /* default iot include column # (N/A for tables) */
/
create unique index i_partobj$ on partobj$(obj#)
/
rem
rem  partcol$ table
rem  This table has a row per partitioning key column
rem  obj#, intcol# is a key
rem  There is a non-unique index on obj#
create table partcol$ (
  obj#   number not null,     /* object number of partitioned table or index */
  intcol# number not null,                         /* internal column number */
  col#   number not null,                                   /* column number */
  pos#   number not null,    /* position of column in key (1 = first column) */
  spare1 number)           /* spare column for any unanticpated future needs */
/
create index i_partcol$ on partcol$(obj#)
/
rem
rem  tabpart$ table
rem  This table has one row per table partition
rem  obj# is a key; and so is (bo#, part#)
rem  There is a non-unique index on bo#, obj#
rem
create table tabpart$ (
  obj#        number not null,                 /* object number of partition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#    number,                            /* data layer object number */
  bo#         number not null,                /* object number of base table */
  part#       number not null,    /* partition number (see discussion below) */
  hiboundlen  number not null,      /* length of high bound value expression */
  hiboundval  long,                   /* text of high-bound value expression */
  ts#         number,           /* tablespace number where partition resides */
  file#       number,                          /* segment header file number */
  block#      number,                         /* segment header block number */
  pctfree$    number not null,   /* minimum free space percentage in a block */
  pctused$    number not null,   /* minimum used space percentage in a block */
  initrans    number not null,             /* initial number of transactions */
  maxtrans    number not null,             /* maximum number of transactions */
  flags       number not null,                              /* for any flags */
                                  /* 0x01 = 7.3 -> 8.0 data object migration */
                                  /* 0x02 = partition has been analyzed      */
                                  /* 0x04 = NO LOGGING for partition         */
                                  /* 0x08 = user-specified stats             */
                                  /* 0x10 = global stats                     */
  analyzetime date,                          /* timestamp when last analyzed */
  samplesize  number,                            /* samplesize for histogram */
  rowcnt      number,                                      /* number of rows */
  blkcnt      number,                                    /* number of blocks */
  empcnt      number,                              /* number of empty blocks */
  avgspc      number,                        /* average available free space */
  chncnt      number,                              /* number of chained rows */
  avgrln      number,                                  /* average row length */
  /* These spare columns are for future needs, e.g. values for the 
   * PARALLEL(degree, instances) parameters.
   */

  spare1      number,
  spare2      number,
  spare3      number)
/
create index i_tabpart$ on tabpart$(bo#, obj#)
/
create index i_tabpart$_bopart$ on tabpart$(bo#, part#)
/
rem  indpart$ table
rem  This table has one row per index partition
rem  obj# is a key, and so is (bo#, part#)
rem  There is a non-unique index on bo#, obj#
rem
create table indpart$ (
  obj#        number not null,                 /* object number of partition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#    number not null,                   /* data layer object number */
  bo#         number not null,                /* object number of base index */
  part#       number not null,
                         /* partition number (see discussion under TABPART$) */
  hiboundlen  number not null,      /* length of high bound value expression */
  hiboundval  long ,                  /* text of high bound value expression */
  flags   number not null,
                    /* 0x01 = Unusable (this field replaces the V7 DLS flag) */
                    /* 0x02 = partition has been analyzed                    */ 
                    /* 0x04 = NO LOGGING for partition                       */
                    /* 0x08 = user-specified stats                           */
                    /* 0x10 = global stats                                   */
                    /* 0x100 = index partition is being online built         */
                    /* 0x200= index partition is being online rebuilt        */
  ts#         number not null,  /* tablespace number where partition resides */
  file#       number not null,                 /* segment header file number */
  block#      number not null,                /* segment header block number */
  pctfree$    number not null,   /* minimum free space percentage in a block */
  pctthres$     number,           /* iot overflow threshold, null if not iot */
  initrans    number not null,             /* initial number of transactions */
  maxtrans    number not null,             /* maximum number of transactions */
  analyzetime date,                          /* timestamp when last analyzed */
  samplesize  number,                            /* samplesize for histogram */
  rowcnt      number,                                      /* number of rows */
  blevel      number,                                        /* B-tree level */
  leafcnt     number,                               /* number of leaf blocks */
  distkey     number,                             /* number of distinct keys */
  lblkkey     number,               /* average number of leaf blocks per key */
  dblkkey     number,               /* average number of data blocks per key */
  clufac      number,                                   /* clustering factor */
  spare1      number,
  /* These spare columns are for future needs, e.g. values for the
   * PARALLEL(degree, instances) parameters.
   */
  spare2   number,
  spare3   number,
  inclcol       number)        /* iot include column number, null if not iot */
/
create index i_indpart$ on indpart$(bo#, obj#)
/
create index i_indpart$_bopart$ on indpart$(bo#, part#)
/
rem
rem  subpartcol$ table
rem  This table has a row per subpartitioning key column for (R+H)
rem  obj#, intcol# is a key
rem  There is a non-unique index on obj#
create table subpartcol$ (
  obj#   number not null,     /* object number of partitioned table or index */
  intcol# number not null,                         /* internal column number */
  col#   number not null,                                   /* column number */
  pos#   number not null,    /* position of column in key (1 = first column) */
  spare1 number)          /* spare column for any unanticipated future needs */
/
create index i_subpartcol$ on subpartcol$(obj#)
/
rem
rem  tabsubpart$ table
rem  This table has one row per table subpartition
rem  obj# is a key; and so is (pobj#, subpart#)
rem  There is a non-unique index on pobj#, obj#
rem
create table tabsubpart$ (
  obj#        number not null,              /* object number of subpartition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#    number,                            /* data layer object number */
  pobj#       number not null,
                       /* object number of partition containing subpartition */
  subpart#    number not null,  
                     /* subpartition number within parent partition (base 1) */
  flags   number not null,
                                  /* 0x02 = partition has been analyzed      */
                                  /* 0x04 = NO LOGGING for partition         */
                                  /* 0x08 = user-specified stats             */
                                  /* 0x10 = global stats                     */
  ts#         number not null,
                             /* tablespace number where subpartition resides */
  file#       number not null,        /* segment header relative file number */
  block#      number not null,                /* segment header block number */
  pctfree$    number not null,   /* minimum free space percentage in a block */
  pctused$    number not null,   /* minimum used spare precentage in a block */
  initrans    number not null,             /* initial number of transactions */
  maxtrans    number not null,             /* maximum number of transactions */
  analyzetime date,                          /* timestamp when last analyzed */
  samplesize  number,                   /* number of rows sampled by analyze */
  rowcnt      number,                                      /* number of rows */
  blkcnt      number,                                    /* number of blocks */
  empcnt      number,                              /* number of empty blocks */
  avgspc      number,                        /* average available free space */
  chncnt      number,                              /* number of chained rows */
  avgrln      number,                                  /* average row length */
  /* These spare columns are for future needs, e.g. values for the 
   * PARALLEL(degree, instances) parameters.
   */
  spare1      number,
  spare2      number,
  spare3      number)
/
create index i_tabsubpart$ on tabsubpart$(pobj#, obj#)
/
create index i_tabsubpart$_pobjsubpart$ on tabsubpart$(pobj#, subpart#)
/
rem
rem  indsubpart$ table
rem  This table has one row per index subpartition
rem  obj# is a key; and so is (pobj#, subpart#)
rem  There is a non-unique index on pobj#, obj#
rem
create table indsubpart$ (
  obj#          number not null,	    /* object number of subpartition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE 		
   * TRANSACTION DURING TRUNCATE */
  dataobj#      number not null,                 /* data layer object number */
  pobj#	        number not null, 	       /* object number of partition */
  subpart#	number not null, /* subpartitn # w/in parent partitn(base 1) */
  flags         number not null,    /* 0x01 = Unusable                       */
                                    /* 0x02 = subpartition has been analyzed */
                                    /* 0x04 = NO LOGGING for subpartition    */
                                    /* 0x08 = user-specified stats           */
                                    /* 0x10 = global stats                   */
  ts#           number not null,  /* tablespace # where subpartition resides */
  file#         number not null,               /* segment header file number */
  block#        number not null,              /* segment header block number */
  pctfree$      number not null, /* minimum free space percentage in a block */
  initrans      number not null,           /* initial number of transactions */
  maxtrans      number not null,           /* maximum number of transactions */
  analyzetime   date,                        /* timestamp when last analyzed */
  samplesize    number,                          /* samplesize for histogram */
  rowcnt        number,                                    /* number of rows */
  blevel        number,                                      /* B-tree level */
  leafcnt       number,                             /* number of leaf blocks */
  distkey       number,                           /* number of distinct keys */
  lblkkey       number,             /* average number of leaf blocks per key */
  dblkkey       number,             /* average number of data blocks per key */
  clufac        number,                                 /* clustering factor */
  spare1        number,
         /* These spare columns are for future needs, e.g. values for the
   	  * PARALLEL(degree, instances) parameters.
   	  */
  spare2        number,
  spare3        number)
/
create index i_indsubpart$ on indsubpart$(pobj#, obj#)
/
create index i_indsubpart$_pobjsubpart$ on indsubpart$(pobj#, subpart#)
/
rem
rem tabcompart$ table
rem This table has a row per table composite partition
rem obj# is the key; and so is (bo#, part#)
rem There is a unique index on obj#
rem
create table tabcompart$ (
  obj#        number not null,                 /* object number of partition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#    number,                                          /* not in use */
  bo#         number not null,                /* object number of base table */
  part#       number not null,    /* partition number (see discussion below) */
  hiboundlen  number not null,      /* length of high bound value expression */
  hiboundval  long,                   /* text of high-bound value expression */
  subpartcnt  number not null,                    /* number of subpartitions */
  flags       number not null,                              /* for any flags */
                                  /* 0x01 = 7.3 -> 8.0 data object migration */
                                  /* 0x02 = partition has been analyzed      */
                                  /* 0x04 - not used                         */
                                  /* 0x08 = user-specified stats             */
                                  /* 0x10 = global stats                     */
  defts#      number,                                  /* default TABLESPACE */
  defpctfree  number not null,                            /* default PCTFREE */
  defpctused  number not null,                            /* default PCTUSED */
  definitrans number not null,                           /* default INITRANS */
  defmaxtrans number not null,                           /* default MAXTRANS */
  definiexts  number,    /* default INITIAL extent size; NULL if unspecified */
  defextsize  number,       /* default NEXT extent size; NULL if unspecified */
  defminexts  number,             /* default MINEXTENTS; NULL if unspecified */
  defmaxexts  number,             /* default MAXEXTENTS; NULL if unspecified */
  defextpct   number,            /* default PCTINCREASE; NULL if unspecified */
  deflists    number,        /* default FREELISTS value; NULL if unspecified */
  defgroups   number,        /* default FREELIST GROUPS; NULL if unspecified */
  deflogging  number,                          /* default LOGGING attribute: */
			      /* 0 - unspecified; 1 - LOGGING; 2 - NOLOGGING */
  defbufpool  number,                           /* default BUFFER_POOL value */
  analyzetime date,                          /* timestamp when last analyzed */
  samplesize  number,                            /* samplesize for histogram */
  rowcnt      number,                                      /* number of rows */
  blkcnt      number,                                    /* number of blocks */
  empcnt      number,                              /* number of empty blocks */
  avgspc      number,                        /* average available free space */
  chncnt      number,                              /* number of chained rows */
  avgrln      number,                                  /* average row length */
  /* These spare columns are for future needs, e.g. values for the 
   * PARALLEL(degree, instances) parameters.
   */
  spare1      number,                       
  spare2      number,                       
  spare3      number)
/
create unique index i_tabcompart$ on tabcompart$(obj#)
/
create index i_tabcompart$_bopart$ on tabcompart$(bo#, part#)
/
rem
rem indcompart$ table
rem This table has a row per index composite partition
rem obj# is the key; and so is (bo#, part#)
rem There is a unique index on obj#
rem
create table indcompart$ (
  obj#        number not null,                 /* object number of partition */
  /* DO NOT CREATE INDEX ON DATAOBJ#  AS IT WILL BE UPDATED IN A SPACE
   * TRANSACTION DURING TRUNCATE */
  dataobj#    number,                                          /* not in use */
  bo#         number not null,                /* object number of base index */
  part#       number not null,                           /* partition number */
  hiboundlen  number not null,      /* length of high bound value expression */
  hiboundval  long,                   /* text of high-bound value expression */
  subpartcnt  number not null,                    /* number of subpartitions */
  flags       number not null,                              /* for any flags */
                                  /* 0x01 - not used                         */
                                  /* 0x02 = partition has been analyzed      */
                                  /* 0x04 - not used                         */
                                  /* 0x08 = user-specified stats             */
                                  /* 0x10 = global stats                     */
  defts#      number,             /* default TABLESPACE; NULL if unspecified */
  defpctfree  number not null,                            /* default PCTFREE */
  definitrans number not null,                           /* default INITRANS */
  defmaxtrans number not null,                           /* default MAXTRANS */
  definiexts  number,    /* default INITIAL extent size; NULL if unspecified */
  defextsize  number,       /* default NEXT extent size; NULL if unspecified */
  defminexts  number,             /* default MINEXTENTS; NULL if unspecified */
  defmaxexts  number,             /* default MAXEXTENTS; NULL if unspecified */
  defextpct   number,            /* default PCTINCREASE; NULL if unspecified */
  deflists    number,        /* default FREELISTS value; NULL if unspecified */
  defgroups   number,           /* default FREELIST GROUPS (N/A for indexes) */
  deflogging  number,                          /* default LOGGING attribute: */
			      /* 0 - unspecified; 1 - LOGGING; 2 - NOLOGGING */
  defbufpool  number,                           /* default BUFFER_POOL value */
  analyzetime date,                          /* timestamp when last analyzed */
  samplesize  number,                            /* samplesize for histogram */
  rowcnt      number,                                      /* number of rows */
  blevel      number,                                        /* B-tree level */
  leafcnt     number,                               /* number of leaf blocks */
  distkey     number,                             /* number of distinct keys */
  lblkkey     number,               /* average number of leaf blocks per key */
  dblkkey     number,               /* average number of data blocks per key */
  clufac      number,                                   /* clustering factor */
  spare1      number,
  /* These spare columns are for future needs, e.g. values for the
   * PARALLEL(degree, instances) parameters.
   */
  spare2   number,
  spare3   number)
/
create unique index i_indcompart$ on indcompart$(obj#)
/
create index i_indcompart$_bopart$ on indcompart$(bo#, part#)
/
rem
rem partlob$ table
rem This table will be used to store table-level default attributes for LOB
rem columns in partitioned tables.
rem
create table partlob$ (
  lobj#       number not null,                 /* object number of partition */
  tabobj#     number not null,    /* obj# of the table containing lob column */
  intcol#     number not null,       /* internal column id of the lob column */
  defts#      number,             /* default TABLESPACE; NULL if unspecified */
  defchunk    number not null,     /* default oracle blocks in one lob chunk */
  defpctver$  number not null,                       /* default version pool */
  defflags    number not null,              /* default CACHE & LOGGING attrs */
                                                           /* 0x0000 = CACHE */
                                                 /* 0x0001 = NOCACHE LOGGING */
                                               /* 0x0002 = NOCACHE NOLOGGING */
                                             /* 0x0008 = CACHE READS LOGGING */
                                           /* 0x0010 = CACHE READS NOLOGGING */ 
  defpro      number not null,                 /* default partition property */
                                             /* 0x02 = enable storage in row */
  definiexts  number,    /* default INITIAL extent size; NULL if unspecified */
  defextsize  number,       /* default NEXT extent size; NULL if unspecified */
  defminexts  number,             /* default MINEXTENTS; NULL if unspecified */
  defmaxexts  number,             /* default MAXEXTENTS; NULL if unspecified */
  defextpct   number,            /* default PCTINCREASE; NULL if unspecified */
  deflists    number,        /* default FREELISTS value; NULL if unspecified */
  defgroups   number,        /* default FREELIST GROUPS; NULL if unspecified */
  defbufpool  number,            /* default BUFFER_POOL; NULL if unspecified */
  spare1      number,
  spare2      number,
  spare3      number       
)
/
rem
rem lobfrag$ table
rem This table will be used to store attributes of partitions (for tables
rem partitioned using Range, Hash, and System methods) and subpartitions 
rem (for tables partitioned using Composite methods) of LOB columns.
create table lobfrag$ (
  fragobj#     number not null,           /* object number of a LOB fragment */
  parentobj#   number not null,               /* object number of the parent */
                                        /* (LOB column for partitions or LOB */ 
                                             /* partition for subpartitions) */
  tabfragobj#  number not null,  /* object number of corresponding LOB table */
                                                                 /* fragment */
  indfragobj#  number not null,  /* object number of corresponding LOB index */
                                                                 /* fragment */
  frag#        number not null,       /* fragment # (partn w/in a LOB column */
                                  /* or subpartition w/in the LOB partition) */
  fragtype$    char(1),                                /* LOB fragment type: */
                                     /* 'P' - partition;  'S' - subpartition */
  ts#         number not null,          /* tablespace number of LOB fragment */
  file#       number not null,                 /* segment header file number */
  block#      number not null,                /* segment header block number */
  chunk       number not null,             /* oracle blocks in one lob chunk */
  pctversion$ number not null,                               /* version pool */
  fragflags   number not null,                 /* CACHE & LOGGING attributes */
                                                           /* 0x0000 = CACHE */
                                                 /* 0x0001 = NOCACHE LOGGING */
                                               /* 0x0002 = NOCACHE NOLOGGING */
                                             /* 0x0008 = CACHE READS LOGGING */
                                           /* 0x0010 = CACHE READS NOLOGGING */ 
  fragpro     number not null,                          /* fragment property */
                                             /* 0x02 = enable storage in row */
  spare1      number,
  spare2      number,
  spare3      number       
)
/
create index i_lobfrag$_parentobjfrag$ on lobfrag$(parentobj#, frag#)
/
rem
rem lobcomppart$ table
rem This table will contain partition-level default attributes for partitioned
rem of LOB columns of table partitioned using Composite methods.         
rem
create table lobcomppart$ (
  partobj#     number not null,          /* object number of a LOB partition */
  lobj#        number not null,  /* object number of the LOB column to which */
                                                    /* the partition belongs */
  tabpartobj#  number not null,      /* object number of the table partition */
                                      /* to which this partition corresponds */
  indpartobj#  number not null,      /* object number of the index partition */
                                      /* to which this partition corresponds */
  part#        number not null,        /* partition number w/in a LOB column */
  defts#       number,            /* default TABLESPACE; NULL if unspecified */
  defchunk     number not null,    /* default oracle blocks in one lob chunk */
  defpctver$   number not null,                      /* default version pool */
  defflags     number not null,             /* default CACHE & LOGGING attrs */
                                                           /* 0x0000 = CACHE */
                                                 /* 0x0001 = NOCACHE LOGGING */
                                               /* 0x0002 = NOCACHE NOLOGGING */
                                             /* 0x0008 = CACHE READS LOGGING */
                                           /* 0x0010 = CACHE READS NOLOGGING */  
  defpro       number not null,                /* default partition property */
                                             /* 0x02 = enable storage in row */
  definiexts   number,   /* default INITIAL extent size; NULL if unspecified */
  defextsize   number,      /* default NEXT extent size; NULL if unspecified */
  defminexts   number,            /* default MINEXTENTS; NULL if unspecified */
  defmaxexts   number,            /* default MAXEXTENTS; NULL if unspecified */
  defextpct    number,           /* default PCTINCREASE; NULL if unspecified */
  deflists     number,       /* default FREELISTS value; NULL if unspecified */
  defgroups    number,       /* default FREELIST GROUPS; NULL if unspecified */
  defbufpool   number,           /* default BUFFER_POOL; NULL if unspecified */
  spare1       number,
  spare2       number,
  spare3       number       
)
/
create index i_lobcomppart$_partlobj$ on lobcomppart$(lobj#, part#)
/
rem
rem  FAMILY "PRIVILEGE MAP"
rem  Tables for mapping privilege numbers to privilege names.
rem
rem  SYSTEM_PRIVILEGE_MAP maps a system privilege  number
rem  to the name.
rem
create table SYSTEM_PRIVILEGE_MAP (
        PRIVILEGE     number not null,
        NAME          varchar2(40) not null,
	PROPERTY      number not null /* 0x01 = do not export this privilege */
				      /* using sql statements */
	)
/
comment on table SYSTEM_PRIVILEGE_MAP is
'Description table for privilege type codes.  Maps privilege  type numbers to type names'
/
comment on column SYSTEM_PRIVILEGE_MAP.PRIVILEGE is
'Numeric privilege type code'
/
comment on column SYSTEM_PRIVILEGE_MAP.NAME is
'Name of the type of privilege'
/
comment on column SYSTEM_PRIVILEGE_MAP.PROPERTY is
'Property flag of privilege like not export this privilege, etc'
/
insert into SYSTEM_PRIVILEGE_MAP values (-3, 'ALTER SYSTEM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-4, 'AUDIT SYSTEM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-5, 'CREATE SESSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-6, 'ALTER SESSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-7, 'RESTRICTED SESSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-10, 'CREATE TABLESPACE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-11, 'ALTER TABLESPACE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-12, 'MANAGE TABLESPACE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-13, 'DROP TABLESPACE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-15, 'UNLIMITED TABLESPACE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-20, 'CREATE USER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-21, 'BECOME USER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-22, 'ALTER USER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-23, 'DROP USER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-30, 'CREATE ROLLBACK SEGMENT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-31, 'ALTER ROLLBACK SEGMENT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-32, 'DROP ROLLBACK SEGMENT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-40, 'CREATE TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-41, 'CREATE ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-42, 'ALTER ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-43, 'BACKUP ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-44, 'DROP ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-45, 'LOCK ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-46, 'COMMENT ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-47, 'SELECT ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-48, 'INSERT ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-49, 'UPDATE ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-50, 'DELETE ANY TABLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-60, 'CREATE CLUSTER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-61, 'CREATE ANY CLUSTER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-62, 'ALTER ANY CLUSTER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-63, 'DROP ANY CLUSTER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-71, 'CREATE ANY INDEX', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-72, 'ALTER ANY INDEX', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-73, 'DROP ANY INDEX', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-80, 'CREATE SYNONYM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-81, 'CREATE ANY SYNONYM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-82, 'DROP ANY SYNONYM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-83, 'SYSDBA', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-84, 'SYSOPER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-85, 'CREATE PUBLIC SYNONYM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-86, 'DROP PUBLIC SYNONYM', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-90, 'CREATE VIEW', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-91, 'CREATE ANY VIEW', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-92, 'DROP ANY VIEW', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-105, 'CREATE SEQUENCE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-106, 'CREATE ANY SEQUENCE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-107, 'ALTER ANY SEQUENCE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-108, 'DROP ANY SEQUENCE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-109, 'SELECT ANY SEQUENCE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-115, 'CREATE DATABASE LINK', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-120, 'CREATE PUBLIC DATABASE LINK', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-121, 'DROP PUBLIC DATABASE LINK', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-125, 'CREATE ROLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-126, 'DROP ANY ROLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-127, 'GRANT ANY ROLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-128, 'ALTER ANY ROLE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-130, 'AUDIT ANY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-135, 'ALTER DATABASE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-138, 'FORCE TRANSACTION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-139, 'FORCE ANY TRANSACTION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-140, 'CREATE PROCEDURE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-141, 'CREATE ANY PROCEDURE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-142, 'ALTER ANY PROCEDURE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-143, 'DROP ANY PROCEDURE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-144, 'EXECUTE ANY PROCEDURE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-151, 'CREATE TRIGGER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-152, 'CREATE ANY TRIGGER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-153, 'ALTER ANY TRIGGER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-154, 'DROP ANY TRIGGER', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-160, 'CREATE PROFILE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-161, 'ALTER PROFILE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-162, 'DROP PROFILE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-163, 'ALTER RESOURCE COST', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-165, 'ANALYZE ANY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-167, 'GRANT ANY PRIVILEGE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-172, 'CREATE SNAPSHOT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-173, 'CREATE ANY SNAPSHOT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-174, 'ALTER ANY SNAPSHOT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-175, 'DROP ANY SNAPSHOT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-177, 'CREATE ANY DIRECTORY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-178, 'DROP ANY DIRECTORY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-180, 'CREATE TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-181, 'CREATE ANY TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-182, 'ALTER ANY TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-183, 'DROP ANY TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-184, 'EXECUTE ANY TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-186, 'EXTENDS TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-188, 'CREATE LIBRARY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-189, 'CREATE ANY LIBRARY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-190, 'ALTER ANY LIBRARY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-191, 'DROP ANY LIBRARY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-192, 'EXECUTE ANY LIBRARY', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-194, 'WRITEDOWN DBLOW', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-195, 'READUP DBHIGH', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-196, 'WRITEUP DBHIGH', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-197, 'WRITEDOWN', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-198, 'READUP', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-199, 'WRITEUP', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-200, 'CREATE OPERATOR', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-201, 'CREATE ANY OPERATOR', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-202, 'ALTER OPERATOR', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-203, 'DROP ANY OPERATOR', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-204, 'EXECUTE ANY OPERATOR', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-205, 'CREATE INDEXTYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-206, 'CREATE ANY INDEXTYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-207, 'ALTER ANY INDEXTYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-208, 'DROP ANY INDEXTYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-209, 'EXTENDS ANY TYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-210, 'QUERY REWRITE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-211, 'GLOBAL QUERY REWRITE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-212, 'EXECUTE ANY INDEXTYPE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-214, 'CREATE DIMENSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-215, 'CREATE ANY DIMENSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-216, 'ALTER ANY DIMENSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-217, 'DROP ANY DIMENSION', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-218, 'MANAGE ANY QUEUE', 1);
insert into SYSTEM_PRIVILEGE_MAP values (-219, 'ENQUEUE ANY QUEUE', 1);
insert into SYSTEM_PRIVILEGE_MAP values (-220, 'DEQUEUE ANY QUEUE', 1);
insert into SYSTEM_PRIVILEGE_MAP values (-222, 'CREATE ANY CONTEXT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-223, 'DROP ANY CONTEXT', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-224, 'CREATE ANY OUTLINE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-225, 'ALTER ANY OUTLINE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-226, 'DROP ANY OUTLINE', 0);
insert into SYSTEM_PRIVILEGE_MAP values (-227, 'ADMINISTER RESOURCE MANAGER', 1);
insert into SYSTEM_PRIVILEGE_MAP values (-228, 'ADMINISTER DATABASE TRIGGER', 0);
/
create unique index I_SYSTEM_PRIVILEGE_MAP
        on SYSTEM_PRIVILEGE_MAP (PRIVILEGE, NAME)
/
create public synonym SYSTEM_PRIVILEGE_MAP for SYSTEM_PRIVILEGE_MAP
/
grant select on SYSTEM_PRIVILEGE_MAP to public with grant option
/
rem
rem  TABLE_PRIVILEGE_MAP maps a table privilege (auditing option) number
rem  to the name.
rem
create table TABLE_PRIVILEGE_MAP (
        PRIVILEGE       number not null,
        NAME            varchar2(40) not null)
/
comment on table TABLE_PRIVILEGE_MAP is
'Description table for privilege (auditing option) type codes.  Maps privilege (auditing option) type numbers to type names'
/
comment on column TABLE_PRIVILEGE_MAP.PRIVILEGE is
'Numeric privilege (auditing option) type code'
/
comment on column TABLE_PRIVILEGE_MAP.NAME is
'Name of the type of privilege (auditing option)'
/
insert into TABLE_PRIVILEGE_MAP values (0, 'ALTER');
insert into TABLE_PRIVILEGE_MAP values (1, 'AUDIT');
insert into TABLE_PRIVILEGE_MAP values (2, 'COMMENT');
insert into TABLE_PRIVILEGE_MAP values (3, 'DELETE');
insert into TABLE_PRIVILEGE_MAP values (4, 'GRANT');
insert into TABLE_PRIVILEGE_MAP values (5, 'INDEX');
insert into TABLE_PRIVILEGE_MAP values (6, 'INSERT');
insert into TABLE_PRIVILEGE_MAP values (7, 'LOCK');
insert into TABLE_PRIVILEGE_MAP values (8, 'RENAME');
insert into TABLE_PRIVILEGE_MAP values (9, 'SELECT');
insert into TABLE_PRIVILEGE_MAP values (10, 'UPDATE');
insert into TABLE_PRIVILEGE_MAP values (11, 'REFERENCES');
insert into TABLE_PRIVILEGE_MAP values (12, 'EXECUTE');
insert into TABLE_PRIVILEGE_MAP values (16, 'CREATE');
insert into TABLE_PRIVILEGE_MAP values (17, 'READ');
insert into TABLE_PRIVILEGE_MAP values (18, 'WRITE');
insert into TABLE_PRIVILEGE_MAP values (20, 'ENQUEUE');
insert into TABLE_PRIVILEGE_MAP values (21, 'DEQUEUE');
/
create unique index I_TABLE_PRIVILEGE_MAP
        on TABLE_PRIVILEGE_MAP (PRIVILEGE, NAME)
/
create public synonym TABLE_PRIVILEGE_MAP for TABLE_PRIVILEGE_MAP
/
grant select on TABLE_PRIVILEGE_MAP to public with grant option
/
rem
rem  FAMILY "OPTION MAP"
rem	Tables for mapping auditing option numbers to auditing 
rem  the name.
rem
rem  STMT_AUDIT_OPTION_MAP maps a auditing option number to the name.
rem
create table STMT_AUDIT_OPTION_MAP (
	OPTION#	        number not null,
	NAME            varchar2(40) not null,
	PROPERTY        number not null  /* 0x01 = do not export this audit */
					 /* option using sql statements */
)
/
comment on table STMT_AUDIT_OPTION_MAP is
'Description table for auditing option type codes.  Maps auditing option type numbers to type names'
/
comment on column STMT_AUDIT_OPTION_MAP.OPTION# is
'Numeric auditing option type code'
/
comment on column STMT_AUDIT_OPTION_MAP.NAME is
'Name of the type of auditing option'
/
comment on column STMT_AUDIT_OPTION_MAP.PROPERTY is
'Property flag of auditing option'
/
insert into STMT_AUDIT_OPTION_MAP values (  3, 'ALTER SYSTEM', 0);
insert into STMT_AUDIT_OPTION_MAP values (  4, 'SYSTEM AUDIT', 0);
insert into STMT_AUDIT_OPTION_MAP values (  5, 'CREATE SESSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (  6, 'ALTER SESSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (  7, 'RESTRICTED SESSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (  8, 'TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (  9, 'CLUSTER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 10, 'CREATE TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 11, 'ALTER TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 12, 'MANAGE TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 13, 'DROP TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 14, 'TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 15, 'UNLIMITED TABLESPACE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 16, 'USER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 17, 'ROLLBACK SEGMENT', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 18, 'TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 19, 'INDEX', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 20, 'CREATE USER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 21, 'BECOME USER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 22, 'ALTER USER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 23, 'DROP USER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 24, 'SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 25, 'PUBLIC SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 26, 'VIEW', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 27, 'SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 28, 'DATABASE LINK', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 29, 'PUBLIC DATABASE LINK', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 30, 'CREATE ROLLBACK SEGMENT', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 31, 'ALTER ROLLBACK SEGMENT', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 32, 'DROP ROLLBACK SEGMENT', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 33, 'ROLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 34, 'DIMENSION', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 35, 'PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 36, 'TRIGGER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 37, 'PROFILE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 38, 'DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 39, 'SUMMARY', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 40, 'CREATE TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 41, 'CREATE ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 42, 'ALTER ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 43, 'BACKUP ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 44, 'DROP ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 45, 'LOCK ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 46, 'COMMENT ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 47, 'SELECT ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 48, 'INSERT ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 49, 'UPDATE ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 50, 'DELETE ANY TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 60, 'CREATE CLUSTER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 61, 'CREATE ANY CLUSTER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 62, 'ALTER ANY CLUSTER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 63, 'DROP ANY CLUSTER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 71, 'CREATE ANY INDEX', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 72, 'ALTER ANY INDEX', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 73, 'DROP ANY INDEX', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 80, 'CREATE SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 81, 'CREATE ANY SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 82, 'DROP ANY SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 83, 'SYSDBA', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 84, 'SYSOPER', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 85, 'CREATE PUBLIC SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 86, 'DROP PUBLIC SYNONYM', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 90, 'CREATE VIEW', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 91, 'CREATE ANY VIEW', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 92, 'DROP ANY VIEW', 0);
insert into STMT_AUDIT_OPTION_MAP values (105, 'CREATE SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (106, 'CREATE ANY SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (107, 'ALTER ANY SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (108, 'DROP ANY SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (109, 'SELECT ANY SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (111, 'GRANT SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (115, 'CREATE DATABASE LINK', 0);
insert into STMT_AUDIT_OPTION_MAP values (120, 'CREATE PUBLIC DATABASE LINK', 0);
insert into STMT_AUDIT_OPTION_MAP values (121, 'DROP PUBLIC DATABASE LINK', 0);
insert into STMT_AUDIT_OPTION_MAP values (125, 'CREATE ROLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (126, 'DROP ANY ROLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (127, 'GRANT ANY ROLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (128, 'ALTER ANY ROLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (130, 'AUDIT ANY', 0);
insert into STMT_AUDIT_OPTION_MAP values (131, 'SYSTEM GRANT', 0);
insert into STMT_AUDIT_OPTION_MAP values (135, 'ALTER DATABASE', 0);
insert into STMT_AUDIT_OPTION_MAP values (138, 'FORCE TRANSACTION', 0);
insert into STMT_AUDIT_OPTION_MAP values (139, 'FORCE ANY TRANSACTION', 0);
insert into STMT_AUDIT_OPTION_MAP values (140, 'CREATE PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (141, 'CREATE ANY PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (142, 'ALTER ANY PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (143, 'DROP ANY PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (144, 'EXECUTE ANY PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (146, 'EXECUTE PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (147, 'GRANT PROCEDURE', 0);
insert into STMT_AUDIT_OPTION_MAP values (151, 'CREATE TRIGGER', 0);
insert into STMT_AUDIT_OPTION_MAP values (152, 'CREATE ANY TRIGGER', 0);
insert into STMT_AUDIT_OPTION_MAP values (153, 'ALTER ANY TRIGGER', 0);
insert into STMT_AUDIT_OPTION_MAP values (154, 'DROP ANY TRIGGER', 0);
insert into STMT_AUDIT_OPTION_MAP values (157, 'CREATE DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values (158, 'DROP DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values (160, 'CREATE PROFILE', 0);
insert into STMT_AUDIT_OPTION_MAP values (161, 'ALTER PROFILE', 0);
insert into STMT_AUDIT_OPTION_MAP values (162, 'DROP PROFILE', 0);
insert into STMT_AUDIT_OPTION_MAP values (163, 'ALTER RESOURCE COST', 0);
insert into STMT_AUDIT_OPTION_MAP values (165, 'ANALYZE ANY', 0);
insert into STMT_AUDIT_OPTION_MAP values (167, 'GRANT ANY PRIVILEGE', 0);
insert into STMT_AUDIT_OPTION_MAP values (172, 'CREATE SNAPSHOT', 0);
insert into STMT_AUDIT_OPTION_MAP values (173, 'CREATE ANY SNAPSHOT', 0);
insert into STMT_AUDIT_OPTION_MAP values (174, 'ALTER ANY SNAPSHOT', 0);
insert into STMT_AUDIT_OPTION_MAP values (175, 'DROP ANY SNAPSHOT', 0);
insert into STMT_AUDIT_OPTION_MAP values (176, 'NETWORK', 0);
insert into STMT_AUDIT_OPTION_MAP values (177, 'CREATE ANY DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values (178, 'DROP ANY DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values (179, 'GRANT DIRECTORY', 0);
insert into STMT_AUDIT_OPTION_MAP values (180, 'CREATE TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (181, 'CREATE ANY TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (182, 'ALTER ANY TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (183, 'DROP ANY TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (184, 'EXECUTE ANY TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (185, 'GRANT LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (187, 'GRANT TYPE', 0);
insert into STMT_AUDIT_OPTION_MAP values (188, 'CREATE LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (189, 'CREATE ANY LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (190, 'ALTER ANY LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (191, 'DROP ANY LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (192, 'EXECUTE ANY LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (193, 'EXECUTE LIBRARY', 0);
insert into STMT_AUDIT_OPTION_MAP values (194, 'WRITEDOWN DBLOW', 0);
insert into STMT_AUDIT_OPTION_MAP values (195, 'READUP DBHIGH', 0);
insert into STMT_AUDIT_OPTION_MAP values (196, 'WRITEUP DBHIGH', 0);
insert into STMT_AUDIT_OPTION_MAP values (197, 'WRITEDOWN', 0);
insert into STMT_AUDIT_OPTION_MAP values (198, 'READUP', 0);
insert into STMT_AUDIT_OPTION_MAP values (199, 'WRITEUP', 0);
insert into STMT_AUDIT_OPTION_MAP values (210, 'QUERY REWRITE', 0);
insert into STMT_AUDIT_OPTION_MAP values (211, 'GLOBAL QUERY REWRITE', 0);
insert into STMT_AUDIT_OPTION_MAP values (214, 'CREATE DIMENSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (215, 'CREATE ANY DIMENSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (216, 'ALTER ANY DIMENSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (217, 'DROP ANY DIMENSION', 0);
insert into STMT_AUDIT_OPTION_MAP values (218, 'MANAGE ANY QUEUE', 1);
insert into STMT_AUDIT_OPTION_MAP values (219, 'ENQUEUE ANY QUEUE', 1);
insert into STMT_AUDIT_OPTION_MAP values (220, 'DEQUEUE ANY QUEUE', 1);
insert into STMT_AUDIT_OPTION_MAP values (224, 'CREATE ANY OUTLINE', 0);
insert into STMT_AUDIT_OPTION_MAP values (225, 'ALTER ANY OUTLINE', 0);
insert into STMT_AUDIT_OPTION_MAP values (226, 'DROP ANY OUTLINE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 77, 'NOT EXISTS', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 87, 'EXISTS', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 54, 'ALTER TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 57, 'LOCK TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 58, 'COMMENT TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 65, 'SELECT TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 66, 'INSERT TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 67, 'UPDATE TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 68, 'DELETE TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values ( 69, 'GRANT TABLE', 0);
insert into STMT_AUDIT_OPTION_MAP values (103, 'ALTER SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (104, 'SELECT SEQUENCE', 0);
insert into STMT_AUDIT_OPTION_MAP values (221, 'CONTEXT', 0);

/
create unique index I_STMT_AUDIT_OPTION_MAP
        on STMT_AUDIT_OPTION_MAP (OPTION#, NAME)
/
create public synonym  STMT_AUDIT_OPTION_MAP for STMT_AUDIT_OPTION_MAP
/
grant select on STMT_AUDIT_OPTION_MAP to public
/
remark
remark FAMILY "RESOURCE PROFILES"
remark
create table RESOURCE_MAP (
	RESOURCE#	number not null,
        TYPE#           number not null,
	NAME		varchar2(32) not null)
/
comment on table RESOURCE_MAP is
'Description table for resources.  Maps resource name to number'
/
comment on column RESOURCE_MAP.RESOURCE# is
'Numeric resource code'
/
comment on column RESOURCE_MAP.NAME is
'Name of resource'
/
insert into resource_map values ( 0, 0, 'COMPOSITE_LIMIT' );
insert into resource_map values ( 1, 0, 'SESSIONS_PER_USER' );
insert into resource_map values ( 2, 0, 'CPU_PER_SESSION' );
insert into resource_map values ( 3, 0, 'CPU_PER_CALL' );
insert into resource_map values ( 4, 0, 'LOGICAL_READS_PER_SESSION' );
insert into resource_map values ( 5, 0, 'LOGICAL_READS_PER_CALL' );
insert into resource_map values ( 6, 0, 'IDLE_TIME' );
insert into resource_map values ( 7, 0, 'CONNECT_TIME' );
insert into resource_map values ( 8, 0, 'PRIVATE_SGA' );
insert into resource_map values ( 0, 1, 'FAILED_LOGIN_ATTEMPTS' );
insert into resource_map values ( 1, 1, 'PASSWORD_LIFE_TIME' );
insert into resource_map values ( 2, 1, 'PASSWORD_REUSE_TIME' );
insert into resource_map values ( 3, 1, 'PASSWORD_REUSE_MAX' );
insert into resource_map values ( 4, 1, 'PASSWORD_VERIFY_FUNCTION' );
insert into resource_map values ( 5, 1, 'PASSWORD_LOCK_TIME' );
insert into resource_map values ( 6, 1, 'PASSWORD_GRACE_TIME' )
/
create table user_astatus_map
( status#  number not null, 
  status  varchar2(32) not null)
/
insert into user_astatus_map values (0, 'OPEN');
insert into user_astatus_map values (1, 'EXPIRED');
insert into user_astatus_map values (2, 'EXPIRED(GRACE)');
insert into user_astatus_map values (4, 'LOCKED(TIMED)');
insert into user_astatus_map values (8, 'LOCKED');
insert into user_astatus_map values (5, 'EXPIRED & LOCKED(TIMED)');
insert into user_astatus_map values (6, 'EXPIRED(GRACE) & LOCKED(TIMED)');
insert into user_astatus_map values (9, 'EXPIRED & LOCKED');
insert into user_astatus_map values (10, 'EXPIRED(GRACE) & LOCKED')
/
create role select_catalog_role
/
create role execute_catalog_role
/
create role delete_catalog_role
/
grant select_catalog_role to dba with admin option
/
grant execute_catalog_role to dba with admin option
/
grant delete_catalog_role to dba with admin option
/
grant delete on aud$ to delete_catalog_role
/
create role exp_full_database
/
create role imp_full_database
/
grant select_catalog_role to exp_full_database
/
grant select_catalog_role to imp_full_database
/
grant execute_catalog_role to imp_full_database
/
grant execute_catalog_role to exp_full_database
/
create table expact$
( owner 	varchar2("M_IDEN") not null,              /* owner of object */
  name  	varchar2("M_IDEN") not null,               /* name of object */
  func_schema 	varchar2("M_IDEN") not null,     /* schema func is run under */
  func_package  varchar2("M_IDEN") not null,                 /* package name */
  func_proc  	varchar2("M_IDEN") not null,               /* procedure name */
  code  	number not null,                    /* PRETABLE OR POSTTABLE */
  callorder 	number,
  callarg 	varchar2(1),	    /* whether this function takes arguments */
			      /* or not.  Null - no arguments; Y - pass arg. */
  obj_type number not null,	            /* type of object to be exported */
  user_arg varchar2(2000)	       /* user arguments for pkg, proc, func */
)				
/
create table noexp$
( owner varchar2("M_IDEN") not null,                       /* owner of table */
  name  varchar2("M_IDEN") not null,                        /* name of table */
  obj_type number not null              /* type of object NOT to be exported */
)
/
create table coltype$                        /* additional column info table */
( obj#          number not null,             /* object number of base object */
  col#          number not null,                            /* column number */
  intcol#       number not null,                   /* internal column number */
  toid          raw(16) not null,                   /* column's ADT type OID */
  version#      number not null,             /* internal type version number */
  packed        number not null,                 /* 0 = unpacked, 1 = packed */
  intcols       number,                        /* number of internal columns */
                                          /* storing the exploded ADT column */
  intcol#s      raw("M_CSIZ"),        /* list of intcol#s of columns storing */
                          /* the unpacked ADT column; stored in packed form; */
                                          /* each intcol# is stored as a ub2 */
  flags         number)
                     /* flags to indicate whether column type is ADT, Array, */
                                                      /* REF or Nested table */
                           /* 0x20 - retrieve collection out-of-line         */
                           /* 0x20 - don't strip the null image              */
                           /* 0x40 - don't chop null image                   */
                           /* 0x40 - collection storage specified            */
                           /* 0x80 - column stores an old (8.0) format image */
cluster c_obj#(obj#)
/
create index i_coltype1 on coltype$(obj#, col#)
/
create unique index i_coltype2 on coltype$(obj#, intcol#)
/
create table attrcol$                          /* ADT attribute column table */
( obj#          number not null,             /* object number of base object */
  intcol#       number not null,                   /* internal column number */
  name          varchar2("M_VCSZ") not null)         /* fully-qualified name */
cluster c_obj#(obj#)
/
create unique index i_attrcol1 on attrcol$(obj#, intcol#)
/
create table viewtrcol$                      /* triggering view column table */
( obj#          number not null,             /* object number of base object */
  intcol#       number not null,                   /* internal column number */
  attribute#    number not null,          /* attribute# inside col for views */
  name          varchar2("M_VCSZ") not null)         /* fully-qualified name */
cluster c_obj#(obj#)
/
create unique index i_viewtrcol1 on viewtrcol$(obj#, intcol#,attribute#)
/
create table id_gens$                                 /* ID generators table */
( total         number not null)            /* total number of ID generators */
/
create table oid$                    /* OID mapping table for schema objects */
(
  user#         number not null,   /* user this mapping is for (user$.user#) */
  oid$          raw(16) not null,        /* OID for typed table/view or type */
  obj#          number not null)         /* target object number (obj$.obj#) */
                                                       /* key: (user#, oid$) */
/
create unique index i_oid1 on oid$(user#, oid$)
/
create table lob$                                   /* LOB information table */
( obj#          number not null,          /* object number of the base table */
  col#          number not null,                            /* column number */
  intcol#       number not null,                   /* internal column number */
  lobj#         number not null,                /* object number for the LOB */
  part#         number not null,                  /* this column is not used */
  ind#          number not null,                  /* LOB index object number */
  ts#           number not null,         /* segment header tablespace number */
  file#         number not null,               /* segment header file number */
  block#        number not null,              /* segment header block number */
  chunk         number not null,           /* oracle blocks in one lob chunk */
  pctversion$   number not null,                             /* version pool */
  flags         number not null,                           /* 0x0000 = CACHE */
                                                 /* 0x0001 = NOCACHE LOGGING */
                                               /* 0x0002 = NOCACHE NOLOGGING */
                                             /* 0x0008 = CACHE READS LOGGING */
                                           /* 0x0010 = CACHE READS NOLOGGING */ 
  property      number not null,           /* 0x00 = user defined lob column */
                                    /* 0x01 = kernel column(s) stored as lob */
                                     /* 0x02 = user lob column with row data */
					    /* 0x04 = partitioned LOB column */
                                   /* 0x0008 = LOB In Global Temporary Table */
                                          /* 0x0010 = Session-specific table */

  spare1        number,
  spare2        number,
  spare3        varchar2(255)
)
cluster c_obj#(obj#)
/
create index i_lob1 on lob$(obj#, intcol#)
/
create table type_misc$              /* type miscellaneous information table */
( obj#          number not null,                       /* type object number */
  audit$        varchar2("S_OPFL") not null,             /* auditing options */
  properties    number not null)                               /* properties */
                        /* 0x01 = (flag PRP) potential REF-dependency parent */
                        /* 0x02 = invoker's rights                           */
cluster c_obj#(obj#)
/
create cluster c_toid_version#
( toid          raw(16),                                             /* TOID */
  version#      number)                           /* internal version number */
  storage (initial 10k next 100k maxextents unlimited pctincrease 0)
/
create index i_toid_version# on cluster c_toid_version#
/
create table type$                                             /* type table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,                  /* internal version number */
  version       varchar2("M_IDEN") not null,   /* user-supplied version name */
  tvoid         raw(16) not null,                      /* type version's OID */
  typecode      number not null,                                 /* typecode */
  properties    number not null,                       /* type's properties: */
  /* 0x0001 =       1 = contains at least one (embedded) ADT attribute */
  /* 0x0002 =       2 = contains at least one REF attribute */
  /* 0x0004 =       4 = contains at least one "complex" attribute:
                        multiset, table, array, LOB, file, etc. */
  /* 0x0010 =      16 = is a predefined system/built-in type (unalterable) */
  /* 0x0080 =     128 = contains at least one multiset attribute */
  /* 0x0100 =     256 = is incomplete */
  /* 0x0200 =     512 = contains at least one LOB attribute */
  /* 0x0400 =    1024 = contains at least one file attribute */
  /* 0x0800 =    2048 = is a system-generated type */
  attributes    number,                              /* number of attributes */
  methods       number,                                 /* number of methods */
  supertypes    number,                                          /* reserved */
  subtypes      number,                                          /* reserved */
  spare1        number,                                          /* reserved */
  spare2        number,                                          /* reserved */
  spare3        number,                                          /* reserved */
  supertoid     raw(16))                                   /* supertype OID */
cluster c_toid_version#(toid, version#)
                           /* keys: (toid, version# or version) or (tdo_oid) */
/
create unique index i_type1 on type$(toid, version)
/
create unique index i_type2 on type$(tvoid)
/
create table collection$                            /* collection type table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,             /* internal type version number */
  coll_toid     raw(16) not null,   /* collection TOID (TABLE, VARRAY, etc.) */
  coll_version# number not null,/* collection type's internal version number */
  elem_toid     raw(16) not null,                          /* element's TOID */
  elem_version# number not null, /* element's type's internal version number */
  properties    number not null,                    /* element's properties: */
  /* 0x4000 =   16384 = is a PONTER element */
  /* 0x8000 =   32768 = is a REF element */
  /* 0x10000 =  65536  = no NULL is stored with each element */
  /* 0x20000 =  131072 = number/float elements stored in min. fixed size */
  /* 0x40000 =  262144 = number/float elements stored in varying size    */
  charsetid     number,                                  /* character set id */
  charsetform   number,                                /* character set form */
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  length        number,                  /* fixed character string length or */
                                  /* maximum varying character string length */
  precision     number,        /* fixed- or floating-point numeric precision */
  scale         number,                         /* fixed-point numeric scale */
  upper_bound   number,     /* fixed array size or varying array upper bound */
  spare1        number,                      /* fractional seconds precision */
  spare2        number,                  /* interval leading field precision */
  spare3        number)
cluster c_toid_version#(toid, version#)
/
create table attribute$                                   /* attribute table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,             /* internal type version number */
  name          varchar2("M_IDEN") not null,               /* attribute name */
  attribute#    number not null,              /* attribute identifier number */
  attr_toid     raw(16) not null,                        /* attribute's TOID */
  attr_version# number not null,
                               /* attribute's type's internal version number */
  properties    number not null,                  /* attribute's properties: */
  /* 0x4000 =   16384 = is a PONTER attribute */
  /* 0x8000 =   32768 = is a REF attribute */
  charsetid     number,                                  /* character set id */
  charsetform   number,                                /* character set form */
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  length        number,                  /* fixed character string length or */
                                  /* maximum varying character string length */
  precision#    number,        /* fixed- or floating-point numeric precision */
  scale         number,                         /* fixed-point numeric scale */
  spare1        number,                      /* fractional seconds precision */
  spare2        number,                  /* interval leading field precision */
  spare3        number)
cluster c_toid_version#(toid, version#)
                               /* keys: (toid, version#, name or attribute#) */
/
create unique index i_attribute1 on attribute$(toid, version#, name)
/
create unique index i_attribute2 on attribute$(toid, version#, attribute#)
/
create table method$                               /* method signature table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,             /* internal type version number */
  method#       number not null,                /* method number or position */
  name          varchar2("M_IDEN") not null,                  /* method name */
  properties    number not null,                     /* method's properties: */
  /* 0x00001 =      1 = PRIVATE method */
  /* 0x00002 =      2 = PUBLIC method (default) */
  /* 0x00004 =      4 = INLINE method */
  /* 0x00008 =      8 = VIRTUAL method */
  /* 0x00010 =     16 = CONSTANT method */
  /* 0x00020 =     32 = contructor method */
  /* 0x00040 =     64 = destructor method */
  /* 0x00080 =    128 = operator method */
  /* 0x00100 =    256 = selfish method */
  /* 0x00200 =    512 = MAP method */
  /* 0x00800 =   2048 = ORDER method */
  /* 0x01000 =   4096 = Read No Data State method (default) */
  /* 0x02000 =   8192 = Write No Data State method */
  /* 0x04000 =  16384 = Read No Process State method */
  /* 0x08000 =  32768 = Write No Process State method */
  parameters#   number not null,                     /* number of parameters */
  results       number not null,                        /* number of results */
  spare1        number,
  spare2        number,
  spare3        number)
cluster c_toid_version#(toid, version#)
                                          /* keys: (toid, version#, method#) */
/
create unique index i_method1 on method$(toid, version#, method#)
/
create table parameter$                            /* method parameter table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,             /* internal type version number */
  method#       number not null,                /* method number or position */
  name          varchar2("M_IDEN") not null,               /* parameter name */
  parameter#    number not null,             /* parameter number or position */
  param_toid    raw(16) not null,                 /* parameter's type's TOID */
  param_version# number not null,
                               /* parameter's type's internal version number */
  properties    number not null,                  /* parameter's properties: */
  /* 0x0100 =     256 = IN parameter (pass by value, default) */
  /* 0x0200 =     512 = OUT parameter */
  /* 0x0400 =    1024 = pass by reference parameter */
  /* 0x0800 =    2048 = required parameter (default) */
  /* 0x4000 =   16384 = is a PONTER parameter */
  /* 0x8000 =   32768 = is a REF parameter */
  charsetid     number,                                  /* character set id */
  charsetform   number,                                /* character set form */
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  default$      varchar2("M_VCSZ"),                         /* default value */
  spare1        number,
  spare2        number,
  spare3        number)
cluster c_toid_version#(toid, version#)
                      /* keys: (toid, version#, method#, name or parameter#) */
/
create unique index i_parameter1 on
  parameter$(toid, version#, method#, name)
/
create unique index i_parameter2 on
  parameter$(toid, version#, method#, parameter#)
/
create table result$                                  /* method result table */
( toid          raw(16) not null,                                    /* TOID */
  version#      number not null,             /* internal type version number */
  method#       number not null,                /* method number or position */
  result#       number not null,                /* result number or position */
  result_toid   raw(16) not null,                           /* result's TOID */
  result_version# number not null,
                                  /* result's type's internal version number */
  properties    number not null,                     /* result's properties: */
  /* 0x4000 =   16384 = is a PONTER result */ 
  /* 0x8000 =   32768 = is a REF result */
  /* Following length, precision, scale, upper_bound, char_set_id are NOT USED
     in V8.0, but maybe supported in the future. */
  charsetid     number,                                  /* character set id */
  charsetform   number,                                /* character set form */
  /* 1 = implicit: for CHAR, VARCHAR2, CLOB w/o a specified set */
  /* 2 = nchar: for NCHAR, NCHAR VARYING, NCLOB */
  /* 3 = explicit: for CHAR, etc. with "CHARACTER SET ..." clause */
  /* 4 = flexible: for PL/SQL "flexible" parameters */
  spare1        number,
  spare2        number,
  spare3        number)
cluster c_toid_version#(toid, version#)
                                 /* keys: (toid, version#, method#, result#) */
/
create unique index i_result1 on
  result$(toid, version#, method#, result#)
/
create table kottd$ of kottd                           /* primary type table */
  oid '00000000000000000000000000010001'
/
create table kottb$ of kottb                         /* secondary type table */
  oid '00000000000000000000000000010002'
/
create table kotad$ of kotad                    /* attribute/parameter table */
  oid '00000000000000000000000000010003'
/
create table kotmd$ of kotmd                       /* method signature table */
  oid '00000000000000000000000000010004'
/
create table kopm$                                         /* metadata table */
( 
  name          varchar2("M_IDEN") not null,                /* metadata name */
  length        number not null,                          /* metadata length */
  metadata      raw(255))                                        /* metadata */
/
create unique index i_kopm1 on kopm$ (name)
/
create table ntab$                         /* nested table information table */
( obj#          number not null,             /* object number of base object */
  col#          number not null,                            /* column number */
  intcol#       number not null,                   /* internal column number */
  ntab#         number not null,     /* object number of nested table object */
  name          varchar2("M_VCSZ") default 'NT$' not null 
                                    /* qualified name of the nested table col*/
)
cluster c_obj#(obj#)
/
create index i_ntab1 on ntab$(obj#, col#)
/
create unique index i_ntab2 on ntab$(obj#, intcol#)
/
create global temporary table atemptab$                     /* see atempind$ */
(
  id    number
)
/
comment on table ATEMPTAB$ is
'Temporary table whose definition is used internally.  Never contains data'
/
create index atempind$ on atemptab$(id) 
/             /* indexes backing up workspaces on disk claim to be atempind$ */

create table library$
( obj#          number not null,             /* object number of the library */
  filespec      varchar2(2000),
                        /* the actual file spec - NULL if property is STATIC */
  property      number,                     /* 0x01 = STATIC, 0x02 = TRUSTED */
  audit$        varchar2("S_OPFL") not null              /* auditing options */
)
cluster c_obj#(obj#)
/
create table user_history$ 
( user# number not null,   /* user number; this mapping is for (user$.user#) */
  password  varchar2("M_IDEN"),                      /* password of the user */
  password_date date                        /* date the password was entered */
);
/
create table migrate$
( version#   varchar2("M_IDEN"),                    /* version migrated from */
  migdate    date,              /* date the migration from v7->v8 took place */
  migrated   number not null     /* 0=not migrated, 1=migrated from v7 to v8 */
)
/
insert into migrate$ values (NULL, NULL, 0)
/
create table refcon$			            /* REF CONstraints table */
( obj#		number not null,	     /* object number of base object */
  col#		number not null,	                    /* column number */
  intcol#	number not null,	           /* internal column number */
  reftyp	number not null,                            /* REF type flag */
                                                     /* 0x01 = REF is scoped */
                                             /* 0x02 = REF stored with rowid */
                                             /* 0x04 = Primary key based ref */
  stabid	raw(16),		   /* OID of scope table (if scoped) */
  expctoid      raw(16) /* TOID of exploded columns when ref is user-defined */
)
cluster c_obj#(obj#)
/
create index i_refcon1 on refcon$(obj#, col#)
/
create unique index i_refcon2 on refcon$(obj#, intcol#)
/
/* if icoldep$ is empty for an index, the index depends on the cols in icol$ */
create table icoldep$                   /* which columns an index depends on */
( obj#          number not null,                                 /* index id */
  bo#           number not null,                                 /* table id */
  intcol#       number not null    /* intcol# in table that index depends on */
)
cluster c_obj#(bo#)
/
create index i_icoldep$_obj on icoldep$ (obj#)
/
create table operator$
( obj#          number not null,                            /* object number */
  numbind       number not null,                       /* number of bindings */
  property      number not null                             /* property flag */
)
/
create unique index oper1 on operator$(obj#)
/
create table opbinding$
( obj#          number not null,                     /* obj# of the operator */
  bind#         number not null,                                 /* binding# */
  functionname  varchar2(92),                 /* function name in form A.B.C */
  returnschema  varchar2("M_IDEN"),      /* schema of return type (for ADTs) */
  returntype    varchar2("M_IDEN"),              /* return type of binding   */
  impschema     varchar2("M_IDEN"),       /* indextype implementation schema */
  imptype       varchar2("M_IDEN"),         /* indextype implementation type */
  property      number not null,                            /* property flag */
                                                /* 0x01 = WITH INDEX CONTEXT */
                                             /* 0x02 = RETURN ANCILLARY DATA */
                                                      /* 0x04 = ANCILLARY TO */
  spare1        varchar2("M_IDEN"),
  spare2        varchar2("M_IDEN"),
  spare3        number
)
/
create unique index opbind1 on opbinding$(obj#,bind#)
/
create table opancillary$
( obj#      number not null,          /* object number of ancillary operator */
  bind#     number not null,            /* bind number of ancillary operator */
  primop#   number not null,            /* object number of primary operator */
  primbind# number not null               /* bind number of primary operator */
)
/
create index opanc1 on opancillary$(obj#,bind#)
/
create table oparg$
( obj#          number not null,                     /* obj# of the operator */
  bind#         number not null,                                 /* binding# */
  position      number not null,                    /* position of arguments */
  type          varchar2(61)                     /* datatype of the argument */
)
/
create index oparg1 on oparg$(obj#)
/
create table indtypes$
( obj#          number not null,                           /* indextype obj# */
  implobj#      number not null,        /* implementation type object number */
  property      number not null                            /* property flags */
)
/
create table indop$
( obj#          number not null,                         /* indextype object */
  oper#         number not null,          /* obj# for operator schema object */
  bind#         number not null,                         /* operator binding */
  property      number not null,                           /* property flags */
                                 /* 0x01 = INEXACT match ... look for filter */
  filt_nam      varchar2("M_IDEN"),           /* name of the filter function */
  filt_sch      varchar2("M_IDEN"),         /* schema of the filter function */
  filt_typ      varchar2("M_IDEN") /* type or package of the filter function */ 
)
/
create table association$
(
  obj#            number not null,    /* obj# of table, type, pkg or func */
  property        number not null,     /* 1-column, 2-type, 3-pkg, 4-func */
                                                      /* 5-idx, 6-idxtype */
  intcol#         number,            /* intcol# if association for column */
  statstype#      number,        /* object number for the statistics type */
  default_selectivity  number,                     /* default selectivity */
  default_cpu_cost     number,                       /* defaault CPU cost */
  default_io_cost      number,                        /* default i/o cost */
  default_net_cost     number,                    /* default network cost */
  spare1               number,
  spare2               number
)
/
create unique index assoc1 on association$(obj#, intcol#)
/
create index assoc2 on association$(statstype#)
/
create table ustats$
(
  obj#            number  not null,    /* obj# for table(column) or index */
  intcol#         number,                  /* intcol# if stats for column */
  statstype#      number,                  /* obj# of the statistics type */
  property        number,      /* 1-index, 2-column, 3-implicit, 4-direct */
  statistics      raw("M_CSIZ"),              /* uninterpreted statistics */
  spare1          number,                                /* spare column  */
  spare2          number                                /* spare ccolumn  */
)
/
create unique index ustats1 on ustats$(obj#, intcol#)
/
create table javasnm$
( short         varchar2("M_IDEN") not null,       /* shortened form of name */
  longname      long raw not null,                      /* long form of name */
  longdbcs      varchar2(4000)
)
/
create unique index i_javasnm1 on javasnm$ (short)
/
create table sum$                     /* summary table */
( obj#             number not null,   /* object number */
  containerobj#    number not null,   /* object number of the container tab */
  containertype    number not null,   /* type of container - snap, table */
  containernam     varchar2("M_IDEN"),/* name of container */
  fullrefreshtim   number,            /* number in seconds for full refresh */
  Increfreshtim    number,            /* number in seconds for full refresh */
  lastrefreshscn   number,            /* scn of last transaction to refresh */
  lastrefreshdate  date,              /* date of last transaction to refresh */
  refreshmode      number,            /* 0=none, 1=any, 2=inc, 3=full */
  pflags           number,            /* summary properties (bit flags): */
                                      /* refer to  QSMKSANA* flags */
  mflags           number,            /* summary mutable flags */
                                        /* 0x01 summary is known stale */
                                        /* 0x02 summary is unusable */
                                        /* 0x04 summary is disabled */
  numdetailtab     integer,           /* number of detail tables */
  numaggregates    integer,           /* number of measures */
  numkeycolumns    integer,           /* keys are group by fields */
  numjoins         integer,           /* number of joins in summary */
  sumtextlen       number not null,   /* length of text body */
  sumtext          long not null,     /* text from 'select' onward */
  fromoffset       number not null,   /* offset in bytes to FROM clause */
  fromlen          number not null,   /* length from the F to the last table */
  metaversion      number not null,   /* version of this the canonical forms */
  objcount	   number not null,   /* number of dependant objects */
  spare1           number,
  spare2           number,
  spare3           varchar2(1000),
  spare4           date
)
/
create unique index i_sum$_1 on sum$(obj#)
/
create table sumdetail$            /* summary detail table */
( sumobj#       number not null,   /* object number */
  detailobj#    number not null,   /* obj number of detail table */
  detailobjtype number,            /* 1=table,2=view,3=snap,4=cont. table */
  detailalias   varchar2("M_IDEN"),/* alias if used */
  refreshscn    number,            /* scn of last refresh */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create index i_sumdetail$_1 on sumdetail$(sumobj#)
/
create index i_sumdetail$_2 on sumdetail$(detailobj#)
/
create table sumkey$             /* summary key table */
( sumobj#       number not null, /* parent summary obj */
  sumcolpos#    number not null, /* position of column in select list */
  containercol# number not null, /* pos. in container where stored */
  detailobj#    number not null, /* detail table object from FROM */
  detailobjtype number,          /* detail table type - see sumdetail$ */
  detailcol#    number,          /* col number within detail table */
  groupingpos#  number,          /* pos. in GB clause */
  exprlen       number,
  expression    varchar2(4000),
  textlen       number,
  text          long,
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create unique index i_sumkey$_1 on sumkey$(sumobj#,sumcolpos#,groupingpos#)
/
create table sumagg$             /* summary aggregate table */
( sumobj#       number not null, /* parent summary obj */
  sumcolpos#    number not null, /* position of column in select list */
  containercol# number not null, /* pos. in container where stored */
  aggfunction   integer,         /* type of aggregate function */
  flags         number,          /* sumagg properties (bit flags): */
                                 /* 0x01=distinct aggregate */
  exprlen       number,          /* len of the canonical form */
  expression    varchar2(2000),  /* expr in canonical form */
  textlen       number,          /* len of aggregate text */
  aggtext       long,            /* text of agg. expression */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create unique index i_sumagg$_1 on sumagg$(sumobj#,sumcolpos#)
/
create table sumjoin$             /* summary join table */
( sumobj#       number not null,  /* Object number of the summary */
  tab1obj#      number not null,  /* Object number of the first table */
  tab1col#      number not null,  /* Column number in the first table */
  tab2obj#      number not null,  /* Object number of the second table */
  tab2col#      number not null,  /* Column number of second table */
  joinop        integer,          /* Op code as defined in opndef.h (OPTTEQ) */
  flags         number,           /* currently unused */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
);
/
create index i_sumjoin$_1 on sumjoin$(sumobj#,tab1obj#)
/
create table sumdep$                             /* summary dependency table */
( sumobj#       number not null,                  /* dependent object number */
  order#        number not null,                             /* order number */
  p_obj#        number not null,		     /* parent object number */
  p_type        number not null,                       /* parent object type */
  p_ref_time    date,                            /* parent refresh timestamp */
  p_ref_scn     number,                                /* parent refresh scn */
  flags         number)
/
create index i_sumdep$_1 on sumdep$(sumobj#,order#)
/
create index i_sumdep$_2 on sumdep$(p_obj#,p_type)
/
create table dim$                     /* dimension table */
( obj#             number not null,   /* object number */
  dimtextlen       number,            /* length of the dimension text */
  dimtext          long,
  flags            number,            /* currently only maintains force */
  numlevels        number,            /* number or levels */
  numlevkeys       number,            /* number of level keys */
  numjoinkeys      number,            /* number of join keys */
  numhier          number,            /* number or hierarchies */
  numhierlv        number,            /* number of hierarchy levels */
  numattr          number,            /* number of attributes */
  spare1           number,
  spare2           number,
  spare3           varchar2(1000),
  spare4           date
)
/
create unique index i_dim$_1 on dim$(obj#)
/
create table dimlevel$              /* a dimension level */
( dimobj#       number not null,    /* object number */
  levelid#      number not null,    /* unique number within dimension */
  levelname     varchar2("M_IDEN"), /* text name associated with the level */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create unique index i_dimlevel$_1 on dimlevel$(dimobj#,levelid#)
/
create table dimlevelkey$          /* the columns of a level */
( dimobj#       number not null,   /* object number */
  levelid#      number not null,   /* unique number within dimension */
  keypos#       number not null,   /* postition of column in the key */
  detailobj#    number,            /* detail table object */
  col#          number,            /* col number within detail table */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create index i_dimlevelkey$_1 on dimlevelkey$(dimobj#,levelid#)
/
create index i_dimlevelkey$_2 on dimlevelkey$(detailobj#,col#)
/
create table dimjoinkey$           /* describes a join in a dimension */
( dimobj#       number not null,   /* object number */
  joinkeyid#    number not null,   /* unique number within dimension */
  keypos#       number not null,   /* postition of column in the key */
  hierid#       number,            /* number of hier which this key links */
  levelid#      number,           /* number of hier which this key links */
  detailobj#    number,            /* detail table object */
  col#          number,            /* col number within detail table */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create index i_dimjoinkey$_1 on dimjoinkey$(dimobj#,joinkeyid#)
/
create index i_dimjoinkey$_2 on dimjoinkey$(detailobj#,col#)
/ 
create table dimattr$             /* describes attributes of a dimension */
( dimobj#       number not null,  /* object number */
  levelid#      number not null,  /* id of the level */
  detailobj#    number not null,  /* detail table object */
  col#          number,           /* col number within detail table */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create index i_dimattr$_1 on dimattr$(dimobj#,levelid#)
/
create index i_dimattr$_2 on dimattr$(detailobj#,col#)
/
create table hier$                  /* a hierarchy */
( dimobj#       number not null,    /* object number */
  hierid#       number not null,    /* unique number within dimension */
  hiername      varchar2("M_IDEN"), /* text name or hierarchy */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create unique index i_hier$_1 on hier$(dimobj#,hierid#)
/
create table hierlevel$            /* identifies a level in a hierarchy */
( dimobj#       number not null,   /* object number */
  hierid#       number not null,   /* unique number of the hierarchy */
  pos#          number not null,   /* postition of level in hierarchy */
  levelid#      number not null,   /* id of the level */
  joinkeyid#    number,            /* join key - if levels are from 2 tables */
  spare1        number,
  spare2        number,
  spare3        varchar2(1000),
  spare4        date
)
/
create index i_hierlevel$_1 on hierlevel$(dimobj#,hierid#)
/
create table rls$                                      /* Row Level Security */
(
  obj#            NUMBER NOT NULL,                   /* parent object number */
  pname           VARCHAR2("M_IDEN") NOT NULL,             /* name of policy */
  stmt_type       NUMBER NOT NULL,             /* applicable statement type: */
                           /* 1 = select, 2 = insert, 4 = update, 8 = delete */
  check_opt       NUMBER NOT NULL,                      /* with check option */
                                            /* 0 = no checking, 1 = checking */
  enable_flag     NUMBER NOT NULL,              /* 0 = disabled, 1 = enabled */
  pfschma         VARCHAR2("M_IDEN") NOT NULL,  /* schema of policy function */
  ppname          VARCHAR2("M_IDEN"),                 /* policy package name */
  pfname          VARCHAR2("M_IDEN") NOT NULL        /* policy function name */
)
/
create unique index i_rls on rls$(obj#, pname)
/
create table context$
(
  obj#          number  not null,                       /* object number */
  schema        varchar2("M_IDEN") not null,            /* schema name */
  package       varchar2("M_IDEN") not null             /* package name */
)
/
create unique index i_context on context$(obj#)
/
create table ruleset$ (
	obj#    	number not null,		    /* object number */
	baseobj    	number not null,	       /* base object number */
	rules_table     number not null		/* table in which rules live */
)
/
create user outln identified by outln
/
grant connect to outln
/
grant resource to outln
/
grant execute any procedure to outln
/
create table outln.ol$
(
  ol_name	    varchar2(30),   	  /* named is potentially generated */
  sql_text          long,		     /* the SQL stmt being outlined */
  textlen           number,			      /* length of SQL stmt */
  signature	    raw(16),			   /* signature of sql_text */
  hash_value	    number,		     /* KGL's calculated hash value */
  category          varchar2(30),			   /* category name */
  version           varchar2(64),	   /* db version @ outline creation */
  creator           varchar2(30),	  /* user from whom outline created */
  timestamp         date,			        /* time of creation */
  flags             number,		 /* e.g. everUsed, bindVars, dynSql */
  hintcount	    number		  /* number of hints on the outline */
)
/
create table outln.ol$hints
(
  ol_name	    varchar2(30),			    /* outline name */
  hint#             number,		  /* which hint for a given outline */
  category	    varchar2(30),	        /* collection/grouping name */
  hint_type         number,				    /* type of hint */
  hint_text         varchar2(512),	      /* hint specific information  */
  stage#	    number,	       /* stage of hint generation/applic'n */
  node#		    number,				     /* QBC node id */
  table_name        varchar2(30),			/* for ORDERED hint */
  table_tin	    number,			   /* table instance number */
  table_pos         number			       /* for ORDERED hint  */
)
/
create unique index outln.ol$name on outln.ol$(ol_name)
/
create unique index outln.ol$signature on outln.ol$(signature,category)
/
create unique index outln.ol$hnt_num on outln.ol$hints(ol_name, hint#)
/
create table exppkgobj$    /* Register procedural object sup pkgs for export */
(
  package     varchar2("M_IDEN") not null,                   /* package name */
  schema      varchar2("M_IDEN") not null,                 /* package schema */
  class       number not null,      /* 1=system, 2=schema, 3=object instance */
  type#       number not null,      /* type of objects this package supports */
  prepost     number,     /* 0=export prior to parent schema, 1=after parent */
  level#      number default 1000 not null
        /* Determines ordering in dump file of objects exported at same time */
)
/
create unique index i_objtype on exppkgobj$(type#)
/
create table exppkgact$    /* Register procedural action sup pkgs for export */
(
  package     varchar2("M_IDEN") not null,                   /* package name */
  schema      varchar2("M_IDEN") not null,                 /* package schema */
  class       number not null,      /* 1=system, 2=schema, 3=object instance */
  level#      number default 1000 not null
        /* Determines ordering in dump file of actions exported at same time */
)
/
create unique index i_actpackage on exppkgact$(package, schema, class)
/
create table expdepobj$  /* Register procedural object dependents for export */
(
  d_obj#      number not null,              /* dependent procedural object # */
  p_obj#      number not null                             /* parent object # */
)
/
create unique index i_dependobj on expdepobj$(d_obj#)
/
create index i_parentobj on expdepobj$(p_obj#)
/
create table expdepact$     /* Register objects that have associated actions */
(
  obj#        number not null,                                   /* object # */
  package     varchar2("M_IDEN"),    /* package containing instance_info_exp */
  schema      varchar2("M_IDEN")                           /* package schema */
)
/
create unique index i_actobj on expdepact$(obj#, package, schema)
/
create table mon_mods$
(
  obj#              number,                                 /* object number */
  inserts           number,  /* approx. number of inserts since last analyze */
  updates           number,  /* approx. number of updates since last analyze */
  deletes           number,  /* approx. number of deletes since last analyze */
  timestamp         date,     /* timestamp of last time this row was changed */
  flags             number                                          /* flags */
                                           /* 0x01 object has been truncated */
)
/
create unique index i_mon_mods$_obj on mon_mods$(obj#)
/

create table sql_version$
(
  version#          number not null,                           /* see kpul.h */
  sql_version       varchar2("M_IDEN")     /* sql version string identifier */
)
/
create unique index i_sql_version$_version# on sql_version$(version#)
/

insert into sql_version$ values (0, '8.1.5');    
insert into sql_version$ values (2, '8.1.5');    
insert into sql_version$ values (5, '8.1.5');
insert into sql_version$ values (6, '8.1.6')
/

