rem 
rem $Header: oci08.sql 10-jan-97.13:42:34 echen Exp $ 
rem 
Rem  Copyright (c) 1995, 1997 by Oracle Corporation 
Rem    NAME
Rem      oci08.sql
Rem    DESCRIPTION
Rem	 Script for A22400 OCI Techniques White Paper
Rem      Demo script for oci08.c
Rem    MODIFIED   (MM/DD/YY)
Rem     cchau      08/18/97 -  enable dictionary protection
Rem     echen      01/10/97 -  change internal to sys/change_on_install
Rem     vraghuna   03/01/95 -  Creation
 
set echo on;
connect internal
REM
REM create a view to get the name, length and colid of all the columns in
REM a table
create or replace view ocicol
   (tobjid, townerid,  tname, cname, clength, colid) AS
   SELECT o$.obj#, o$.owner#,  o$.name, c$.name, c$.length,  c$.col#
   FROM   sys.col$ c$, sys.obj$ o$
   WHERE  o$.obj# = c$.obj#
/

CREATE OR REPLACE view ocicolu AS                /* user version for ocitest */
       SELECT * from ocicol WHERE townerid = uid
/
grant select on ocicolu to public;
drop public synonym ocicolu;
create public synonym ocicolu for sys.ocicolu;

REM
REM Create a new user - call it ocitest
REM
drop user ocitest cascade;
create user ocitest identified by ocitest;
grant connect, resource to ocitest;

REM
REM Created needed tables 
REM
connect ocitest/ocitest;
create table test1 (col1 number);
create table test2 (col1 number, col2 number);
create table test3 (col1 number, col2 number, col3 number);
create table test4 (one number, two long, three date, four char(10));
create table test5(
        col1 number, col2 char, col3 number, col4 char,
        col5 number, col6 char, col7 number, col8 char,
        col9 number, col10 char);
create table test6(
        col1 number, col2 char, col3 number, col4 char,
        col5 number, col6 char, col7 number, col8 char,
        col9 number, col10 char, col11 number, col12 char,
        col13 number, col14 char, col15 number, col16 char,
        col17 number, col18 char, col19 number);
create table test7 (one number, two long, three date, four char(10),
	       five number, six number, seven number, eight number,
		nine char(1), ten varchar(2000));
