home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / ORACLE02.ZIP / SQL.ORA < prev   
Encoding:
Text File  |  1987-04-23  |  12.7 KB  |  453 lines

  1. create table tables
  2.   (
  3.   tab$pid       number,
  4.   tab$rba       number,
  5.   tab$tbl       number,
  6.  
  7.   tab$owner       number      not null,
  8.   tab$name       char("M_IDEN") not null,
  9.   tab$type       char("S_TTFL") not null,
  10.   tab$logblk       number,
  11.  
  12.   tab$cluster       number,
  13.   tab$reqblk       number,
  14.   tab$indcompr       char("S_ICFL"),
  15.  
  16.   tab$time       date,
  17.  
  18.   tab$sowner       number,
  19.   tab$sname       char("M_IDEN"),
  20.  
  21.   tab$audit       char("S_OPFL"),
  22.   tab$comment       char("M_CSIZ"),
  23.   tab$snode       char("M_IDEN"),
  24.   tab$sownername   char("M_IDEN")
  25.   )
  26. /
  27. create table columns
  28.   (
  29.   col$pid       number      not null,
  30.   col$rba       number      not null,
  31.   col$tbl       number      not null,
  32.  
  33.   col$name       char("M_IDEN") not null,
  34.   col$datatype       char("S_DTFL") not null,
  35.   col$length       number      not null,
  36.   col$scale       number,
  37.   col$null_type    char("S_NLFL") not null,
  38.   col$id       number      not null,
  39.   col$comment       char("M_CSIZ"),
  40.   col$default       char("M_CSIZ")
  41.   )
  42. //
  43. create table extents
  44.   (
  45.   ext$pid       number      not null,
  46.   ext$rba       number      not null,
  47.   ext$type       char("S_ETFL") not null,
  48.  
  49.   ext$startblock   number      not null,
  50.   ext$endblock       number      not null
  51.   )
  52. //
  53. insert into extents values (
  54.   "S_PID", "TBLRBA", 'DATA',
  55.   "TBLRBA", "TBLRBA"+"D_DINI"-1 )
  56. /
  57. insert into extents values (
  58.   "S_PID", "TBLRBA", 'INDEX',
  59.   "TBLRBA"+"D_DINI", "TBLRBA"+"D_DINI"+"D_IINI"-1 )
  60. /
  61. insert into extents values (
  62.   "S_PID", "TBLRBA"+"D_DINI"+"D_IINI", 'DATA',
  63.   "TBLRBA"+"D_DINI"+"D_IINI", "TBLRBA"+2*"D_DINI"+"D_IINI"-1 )
  64. /
  65. insert into extents values (
  66.   "S_PID", "TBLRBA"+"D_DINI"+"D_IINI", 'INDEX',
  67.   "TBLRBA"+2*"D_DINI"+"D_IINI", "TBLRBA"+2*("D_DINI"+"D_IINI")-1 )
  68. /
  69. create table tabauth
  70.   (
  71.   tau$grantor       char("M_IDEN") not null,
  72.   tau$grantee       char("M_IDEN") not null,
  73.   tau$creator       char("M_IDEN") not null,
  74.   tau$tname       char("M_IDEN") not null,
  75.   tau$time       date       not null,
  76.   tau$alter       char(1)      not null,
  77.   tau$delete       char(1)      not null,
  78.   tau$index       char(1)      not null,
  79.   tau$insert       char(1)      not null,
  80.   tau$select       char(1)      not null,
  81.   tau$update       char(1)      not null
  82.   )
  83. /
  84. create table colauth
  85.   (
  86.   cau$grantor       char("M_IDEN") not null,
  87.   cau$grantee       char("M_IDEN") not null,
  88.   cau$creator       char("M_IDEN") not null,
  89.   cau$tname       char("M_IDEN") not null,
  90.   cau$time       date       not null,
  91.   cau$colname       char("M_IDEN") not null,
  92.   cau$update       char(1)      not null
  93.   )
  94. /
  95. create table views
  96.    (
  97.    vew$pid      number      not null,
  98.    vew$rba      number      not null,
  99.    vew$tbl      number      not null,
  100.    vew$textlen      number      not null,
  101.    vew$text      long          not null
  102.    )
  103. /
  104. create table spaces
  105.   (
  106.   spc$name       char("M_IDEN") not null,
  107.   spc$dini       number      not null,
  108.   spc$dinc       number      not null,
  109.   spc$dmextnt       number      not null,
  110.   spc$iini       number      not null,
  111.   spc$iinc       number      not null,
  112.   spc$imextnt       number      not null,
  113.   spc$pctfree       number      not null,
  114.   spc$pid       number
  115.   )
  116. /
  117. create table indexes
  118.   (
  119.   idx$pid       number      not null,
  120.   idx$rba       number      not null,
  121.   idx$tbl       number      not null,
  122.  
  123.   idx$owner       number      not null,
  124.   idx$name       char("M_IDEN") not null,
  125.   idx$colseq       number      not null,
  126.   idx$column       char("M_IDEN") not null,
  127.   idx$unique       char("S_UNFL") not null,
  128.   idx$order       char("S_ORFL") not null,
  129.   idx$compress       char("S_ICFL") not null,
  130.   idx$concatid       number
  131.   )
  132. /
  133. create table userauth
  134.   (
  135.   usr$uid    number        not null,
  136.   usr$name    char("M_IDEN")          ,
  137.   usr$password    char("M_IDEN")          ,
  138.   usr$time    date        not null,
  139.   usr$connect    char(1),
  140.   usr$dba    char(1),
  141.   usr$resource    char(1)
  142.   )
  143. /
  144. insert into userauth values ( 2, NULL, NULL, SYSDATE, NULL, NULL, NULL )
  145. /
  146. insert into userauth values ( 0, 'SYS', 'IOR', SYSDATE, 'Y', 'Y', 'Y' )
  147. /
  148. insert into userauth values ( 1, 'PUBLIC', NULL, SYSDATE, NULL, NULL, NULL )
  149. /
  150. grant connect,dba,resource to sys,system identified by change_on_install,manager
  151. /
  152. create table progs
  153.   (
  154.   creator       number       not null,
  155.   program       char("M_IDEN")  not null,
  156.   am_id        number       not null,
  157.   revision       number       ,
  158.   stmnts       number       not null,
  159.   cdate        date        ,
  160.   rdate        date        ,
  161.   language       char("M_IDEN")  not null
  162.   )
  163. /
  164. create table prog_stmnts
  165.   (
  166.   am_id        number       not null,
  167.   stmnt_id       number       not null,
  168.   textl        number       not null,
  169.   text           long        not null
  170.   )
  171. /
  172. create table spacemap
  173.   (
  174.   spm$pid       number       not null,
  175.   spm$startblock   number       not null,
  176.   spm$endblock       number       not null
  177.   )
  178. /
  179. create table partitions
  180.   (
  181.   par$id       number       not null,
  182.   par$name       char("M_IDEN")  not null
  183.   )
  184. /
  185. create table files
  186.   (
  187.   fil$id       number       not null,
  188.   fil$name       char("M_FFNM")  not null,
  189.   fil$pid       number       not null,
  190.   fil$rba       number       not null,
  191.   fil$length       number       not null
  192.   )
  193. /
  194. create table segquotas
  195.   (
  196.   sgq$pid       number      not null,
  197.   sgq$rba       number      not null,
  198.   sgq$tbl       number      not null,
  199.  
  200.   sgq$dini       number      not null,
  201.   sgq$dinc       number      not null,
  202.   sgq$dmextnt       number      not null,
  203.   sgq$iini       number      not null,
  204.   sgq$iinc       number      not null,
  205.   sgq$imextnt       number      not null,
  206.   sgq$pctfree       number      not null,
  207.   sgq$date       date       not null
  208.   )
  209. /
  210. create table audit_trail
  211.   (
  212.   sessionid       number      not null,
  213.   entryid       number      not null,
  214.   statement       number      not null,
  215.   timestamp       date       not null,
  216.   userid       char("M_IDEN"),
  217.   userhost       char("M_HOST"),
  218.   terminal       char("M_TERM"),
  219.   action       number      not null,
  220.   returncode       number      not null,
  221.  
  222.   obj$creator       char("M_IDEN"),
  223.   obj$name       char("M_IDEN"),
  224.  
  225.   auth$privileges  char("S_PRFL"),
  226.   auth$grantee       char("M_IDEN"),
  227.  
  228.   new$name       char("M_IDEN"),
  229.  
  230.   ses$actions       char("S_ACFL"),
  231.   ses$tid       raw("TIDSIZE"),
  232.  
  233.   logoff$lread       number,
  234.   logoff$pread       number,
  235.   logoff$lwrite    number,
  236.   logoff$dead       number,
  237.   logoff$time       date,
  238.  
  239.   comment$text       char("M_CSIZ")
  240.   )
  241. /
  242. create table "_system_auditing_options_" (a char(1))
  243. /
  244. create table "_default_auditing_options_" (a char(1))
  245. /
  246. create space temptable
  247.       datapages (initial 20, increment 100, maxextents 240, pctfree  1)
  248.       indexpages(initial 20, increment 100, maxextents 240)
  249. /
  250. insert into tabauth values(
  251. 'SYS','SYS','SYS','AUDIT_TRAIL',SYSDATE,'G','G','G','G','G','G')
  252. /
  253. insert into tabauth values(
  254. 'SYS','SYS','SYS','COLAUTH',SYSDATE,'G','G','G','G','G','G')
  255. /
  256. insert into tabauth values(
  257. 'SYS','SYS','SYS','COLUMNS',SYSDATE,'G','G','G','G','G','G')
  258. /
  259. insert into tabauth values(
  260. 'SYS','SYS','SYS','EXTENTS',SYSDATE,'G','G','G','G','G','G')
  261. /
  262. insert into tabauth values(
  263. 'SYS','SYS','SYS','FILES',SYSDATE,'G','G','G','G','G','G')
  264. /
  265. insert into tabauth values(
  266. 'SYS','SYS','SYS','INDEXES',SYSDATE,'G','G','G','G','G','G')
  267. /
  268. insert into tabauth values(
  269. 'SYS','SYS','SYS','PARTITIONS',SYSDATE,'G','G','G','G','G','G')
  270. /
  271. insert into tabauth values(
  272. 'SYS','SYS','SYS','PROGS',SYSDATE,'G','G','G','G','G','G')
  273. /
  274. insert into tabauth values(
  275. 'SYS','SYS','SYS','PROG_STMNTS',SYSDATE,'G','G','G','G','G','G')
  276. /
  277. insert into tabauth values(
  278. 'SYS','SYS','SYS','SEGQUOTAS',SYSDATE,'G','G','G','G','G','G')
  279. /
  280. insert into tabauth values(
  281. 'SYS','SYS','SYS','SPACES',SYSDATE,'G','G','G','G','G','G')
  282. /
  283. insert into tabauth values(
  284. 'SYS','SYS','SYS','SPACEMAP',SYSDATE,'G','G','G','G','G','G')
  285. /
  286. insert into tabauth values(
  287. 'SYS','SYS','SYS','TABLES',SYSDATE,'G','G','G','G','G','G')
  288. /
  289. insert into tabauth values(
  290. 'SYS','SYS','SYS','TABAUTH',SYSDATE,'G','G','G','G','G','G')
  291. /
  292. insert into tabauth values(
  293. 'SYS','SYS','SYS','USERAUTH',SYSDATE,'G','G','G','G','G','G')
  294. /
  295. insert into tabauth values(
  296. 'SYS','SYS','SYS','VIEWS',SYSDATE,'G','G','G','G','G','G')
  297. /
  298. insert into tabauth values(
  299. 'SYS','SYS','SYS','_system_auditing_options_',SYSDATE,'G','G','G','G','G','G')
  300. /
  301. insert into tabauth values(
  302. 'SYS','SYS','SYS','VIEWS',SYSDATE,'G','G','G','G','G','G')
  303. /
  304. grant select on tables to system with grant option
  305. /
  306. grant select on columns to system with grant option
  307. /
  308. grant select on extents to system with grant option
  309. /
  310. grant select on spaces to system with grant option
  311. /
  312. grant select on indexes to system with grant option
  313. /
  314. grant select on userauth to system with grant option
  315. /
  316. grant select on progs to system with grant option
  317. /
  318. grant select on prog_stmnts to system with grant option
  319. /
  320. grant select on spacemap to system with grant option
  321. /
  322. grant select on partitions to system with grant option
  323. /
  324. grant select on files to system with grant option
  325. /
  326. grant select on segquotas to system with grant option
  327. /
  328. grant select on tabauth to system with grant option
  329. /
  330. grant select on colauth to system with grant option
  331. /
  332. grant select on views to system with grant option
  333. /
  334. grant select on audit_trail to system with grant option
  335. /
  336. create index tab$name on tables(tab$name)
  337. /
  338. create unique index tab$owner on tables(tab$owner,tab$name)
  339. /
  340. create unique index usr$uid on userauth(usr$uid) nocompress
  341. /
  342. create unique index usr$name on userauth(usr$name) nocompress
  343. /
  344. create unique index sgq$tid on segquotas(sgq$pid,sgq$rba,sgq$tbl)
  345. /
  346. create index tau$gtc on
  347.        tabauth(tau$grantee,tau$tname,tau$creator) nocompress
  348. /
  349. create index tau$ctg on
  350.        tabauth(tau$creator,tau$tname,tau$grantor) nocompress
  351. /
  352. create unique index vew$tid on views(vew$pid,vew$rba,vew$tbl)
  353. /
  354. create unique index aud$uid on audit_trail(sessionid,entryid)
  355. /
  356. create view v4expuser (myid, mypsswd, myprivs, myname) as
  357.   select uid, usr$password,
  358.   nvl(usr$connect, ' ')||nvl(usr$dba, ' ')||nvl(usr$resource, ' '), user
  359.   from sys.userauth
  360.   where usr$uid = uid
  361. /
  362. grant select on v4expuser to public
  363. /
  364. create view v4expspace
  365.   (dini, dinc, dmax, iini, iinc, imax, pctf, pname, pid, rba, tbl) as
  366.   select sgq$dini, sgq$dinc, sgq$dmextnt, sgq$iini, sgq$iinc, sgq$imextnt,
  367.   sgq$pctfree, par$name, sgq$pid, sgq$rba,sgq$tbl
  368.   from sys.segquotas, sys.partitions, sys.tables
  369.   where sgq$rba = tab$rba and sgq$tbl = tab$tbl and sgq$pid = tab$pid
  370.   and    tab$owner = uid and sgq$pid = par$id
  371. /
  372. grant select on v4expspace to public
  373. /
  374. create view v4expindex
  375.   (tname, usrname, usrid, iname, colname, iunique, icompr, cid, cseq) as
  376.   select tab$name, user, uid, idx$name, idx$column,
  377.   decode(idx$unique, 'UNIQUE', 1, 0),
  378.   decode(idx$compress, 'COMPRESS', 1, 0),
  379.   idx$concatid, idx$colseq
  380.   from sys.indexes, sys.tables
  381.   where idx$rba = tab$rba and idx$tbl = tab$tbl and idx$pid = tab$pid
  382.   and tab$type = 'TABLE'
  383.   and    tab$owner = idx$owner and idx$owner = uid
  384. /
  385. grant select on v4expindex to public
  386. /
  387. create view v4exptab (name, pid, rba, tbl, aud, cmnt) as
  388.   select tab$name, tab$pid, tab$rba, tab$tbl, tab$audit, tab$comment
  389.   from sys.tables
  390.   where tab$type = 'TABLE' and tab$owner = uid
  391. /
  392. grant select on v4exptab to public
  393. /
  394. create view v4expclus (name, pid, rba, tbl, compr, reqblk, owner) as
  395.   select tab$name, tab$pid, tab$rba, tab$tbl,
  396.   decode(tab$indcompr,'COMPRESS',1, 0), nvl(tab$reqblk,0), uid
  397.   from sys.tables
  398.   where tab$type = 'CLUSTER' and tab$owner = uid
  399. /
  400. grant select on v4expclus to public
  401. /
  402. create view v4exptabauth (object, grantor, grantee, privs, owner) as
  403.   select tau$tname, tau$grantor, tau$grantee,
  404.   nvl(tau$alter,' ')||nvl(tau$delete,' ')||nvl(tau$index,' ')||
  405.   nvl(tau$insert,' ')||nvl(tau$select,' ')||nvl(tau$update,' '), user
  406.   from sys.tabauth
  407.   where tau$creator = user
  408. /
  409. grant select on v4exptabauth to public
  410. /
  411. create view v4expextents (pid, rba, type, sblock, eblock) as
  412.   select distinct *
  413.   from sys.extents
  414.   where (ext$pid, ext$rba) in (
  415.     select tab$pid, tab$rba
  416.     from sys.tables
  417.     where tab$owner = uid)
  418. /
  419. grant select on v4expextents to public
  420. /
  421. create view v4expcol
  422.     (rba, tbl, pid, name, length, scale, type, mand, id, cmnt, dflt ) as
  423.   select col$rba, col$tbl, col$pid, col$name, col$length,
  424.   nvl(col$scale, 0),
  425.   col$datatype,
  426.   decode(col$null_type, 'NOT NULL', 1, 0), col$id, col$comment, col$default
  427.   from sys.columns,sys.tables
  428.   where col$rba = tab$rba and col$pid = tab$pid and col$tbl = tab$tbl
  429.   and    tab$type != 'SYNONYM'
  430.   and    tab$owner = uid
  431. /
  432. grant select on v4expcol to public
  433. /
  434. create view v4expsyn (name, sname, sowner, stime) as
  435.    select tab$name, tab$sname, usr$name, tab$time
  436.    from sys.tables, sys.userauth
  437.    where tab$sowner = usr$uid
  438.    and     tab$type   = 'SYNONYM'
  439.    and     tab$owner  = uid
  440. /
  441. grant select on v4expsyn to public
  442. /
  443. create view v4expview
  444.     (name, pid, rba, tbl, aud, cmnt, vtime, vlen, vtext) as
  445.   select tab$name, tab$pid, tab$rba, tab$tbl, tab$audit, tab$comment,
  446.     tab$time, vew$textlen, vew$text
  447.   from sys.tables, sys.views
  448.   where tab$type = 'VIEW' and tab$owner = uid
  449.   and    tab$rba = vew$rba and tab$pid = vew$pid and tab$tbl = vew$tbl
  450. /
  451. grant select on v4expview to public
  452. /
  453.