sysutils of informix

{ ********************************************************************* } 
{                                   } 
{           INFORMIX SOFTWARE, INC.             } 
{                                   } 
{   Sccsid: %W% %E% %U%                     } 
{   Created:    June 1995                       } 
{   Description:create system utilities database tables         } 
{                                   } 
{ ********************************************************************* } 


set lock mode to wait; 
 
create database sysutils with log; 
database sysutils exclusive; 
 
{ onbar } 
{ active OnLine servers } 
{ The size of srv_name should = IDENTSIZE from rsparam.h      } 
create table bar_server 
( 
    srv_name    char(128) not null,     { server name } 
    srv_node    char(64) not null,  { server node } 
 
    primary key (srv_name) 
) lock mode row; 
revoke all on bar_server from public; 
grant select on bar_server to public; 
grant all on bar_server to root; 
 
{ backup objects } 
{ object names are unique within an OnLine server } 
{ The size of obj_srv_name and obj_name should = IDENTSIZE from rsparam.h.} 
{ The size of obj_type should = BAR_MAX_TYPE_LEN in bar.h                 } 
create table bar_object 
( 
    obj_srv_name    char(128) not null references bar_server(srv_name), 
                                              { which server object is from } 
    obj_oid     serial,             { object identifier } 
    obj_name    char(128) not null,     { name of object    } 
    obj_type    char(2) not null,       { type of object:   } 
                                { B, CD, L, ND, or R } 
    primary key (obj_oid) 
) lock mode row; 
create unique index bar_obj_idx on bar_object(obj_srv_name, obj_name); 
revoke all on bar_object from public; 
grant select on bar_object to public; 
grant all on bar_object to root; 
 
{ backup or restore actions attempted against an object } 
create table bar_action 
( 
    act_aid     integer not null,   { action identifier } 
                        { this is not a serial to support whole system } 
 
    act_oid     integer not null references bar_object(obj_oid), 
                                    { object identifier } 
    act_type    smallint not null,  { type of action }  
    act_status  integer default -1, { status of action } 
    act_start   datetime year to second default CURRENT year to second, 
                                    { time action began } 
    act_end     datetime year to second default CURRENT year to second, 
                                    { time action ended } 
     
    primary key (act_aid, act_oid) 
) lock mode row; 
revoke all on bar_action from public; 
grant select on bar_action to public; 
grant all on bar_action to root; 
 
{ successful backup actions } 
create table bar_instance  
( 
    ins_aid         integer not null,   { action that created the instance } 
    ins_oid         integer not null,   { object identifier } 
    ins_time        integer,    { timestamp from the server } 
    ins_level       smallint default 0 not null, { backup level: 0, 1, or  2 } 
    ins_copyid_hi   integer not null,{ high bytes of the copyid } 
    ins_copyid_lo   integer not null,{ low bytes of the copyid } 
    ins_req_aid     integer not null,{aid of the required BU for an incremental} 
    ins_first_log   integer not null,{ first log needed for restore } 
    ins_verify              integer default 0 not null, {verified? 0=F 1=T} 
    ins_verify_date         datetime year to second, 
     
    primary key (ins_aid, ins_oid), 
    foreign key (ins_aid, ins_oid) references bar_action(act_aid, act_oid) 
) lock mode row; 
revoke all on bar_instance from public; 
grant select on bar_instance to public; 
grant all on bar_instance to root; 
 
     
{*****************************************************************************} 
{*   creates the catalog for the NSM on the sysutils database                 } 
{*****************************************************************************} 
 
{ nsm managed tables } 
create table msm_tdevice  
(  
        tdev_mid             integer,   { internal ID for the device        } 
        tdev_status          integer,   { 0 = NULL, 1=IDLE, 2=READ, 3=WRITE } 
        tdev_sessionid       integer    { session that has locked device    } 
 
) lock mode row; 
revoke all on msm_tdevice from public;
grant select on msm_tdevice to public;
grant all on msm_tdevice to informix;
 
create table msm_ldevice  
(  
        ldev_mid             integer,   { internal ID for the device        } 
        ldev_status          integer,   { 0 = NULL, 1=IDLE, 2=READ, 3=WRITE } 
        ldev_sessionid       integer    { session that has locked device    } 
 
) lock mode row; 
revoke all on msm_ldevice from public;
grant select on msm_ldevice to public;
grant all on msm_ldevice to informix;
 
 
insert into msm_tdevice values (0, 1, 0);
insert into msm_ldevice values (0, 1, 0);
 
create table msm_media 
( 
        med_mid             serial not null, { unique deviced ID a serial value } 
        med_int_label       nchar(120),       { Internal Label for the tape      } 
        med_ext_label       nchar(120),       { External Label for the tape      } 
        med_type            char(1),          { T=TAPE, F=FILE                  } 
 
        primary key (med_mid) 
 
) lock mode row;
 
revoke all on msm_media from public;
grant select on msm_media to public;
grant all on msm_media to informix;
         
create table msm_object 
( 
        obj_oid            serial,     { unique Object ID for a session     } 
        obj_name           char(1024), { name as given by onbar             } 
        obj_pathname       char(1024), { server as presented by onbar       } 
        obj_status         char(1),    { A=Active, I=Inactive               } 
        obj_type           char(1),    { D=DBSPACE, L=LOG                   } 
        obj_copy_id_hi     integer,      
        obj_copy_id_lo     integer,      
                                       { msm id for object                  } 
 
        primary key (obj_oid) 
) lock mode row; 
revoke all on msm_object from public;
grant select on msm_object to public;
grant all on msm_object to informix;

create table msm_location 
( 
        loc_mid             integer references msm_media(med_mid),  { unique device Id      } 
        loc_oid             integer references msm_object(obj_oid), { unique object Id      } 
        loc_seqNo           integer not null                        { Object fragment No.   } 
) lock mode row; 
revoke all on msm_location from public;
grant select on msm_location to public;
grant all on msm_location to informix;
 
grant connect to public; 
grant dba to root; 
close database; 

发表评论