/*****************************************************************************
*
* Filename         - $Workfile:   privilege.sql  $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema: privilege table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   privilege.sql  $  $Revision:   1.4  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /pvcsarch/db_ora/db/source/live/tables/privilege.svl  $
 * 
 *    Rev 1.4   21 Jun 2001 14:48:08   tagtrak
 * OR:
 * CR:
 * Re-baseline version 4.0.0 to include patches.
 * 
 *    Rev 1.3   26 Feb 1999 08:56:00   tagtrak
 *  
 * 
 *    Rev 1.2   02 Apr 1998 19:43:36   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial Issue
 * See label for concession
 * 
 *    Rev 1.1   26 Feb 1998 11:08:18   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial core product version
 * 
 *    Rev 1.0   22 Oct 1997 11:08:14   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial check-in
*
****************************************************************************/

PROMPT Creating table PRIVILEGE

create table PRIVILEGE (
   PRIV_DESCRIPTION              varchar2(50) NOT NULL,
   PRIV_CODE                     char(1) NOT NULL,
   LAST_USER                     number(10) NOT NULL,
   PRIV_TYPE                     char(1) NOT NULL,
   row_create_time               date,
   row_date_time                 date,
   cuser                         varchar2(30),
   muser                         varchar2(30),
   mterm                         varchar2(64),
   source                        varchar2(8),
   to_be_archived                varchar2(1),
   appn_row_id                   number(18) not null,
   system_id                     number(4) default 0 not null
);

alter table privilege add ( constraint privilege_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table privilege add ( constraint privilege_uk1 unique (priv_code) using index tablespace &1._indexes);

alter table privilege add ( constraint privilege_fk_tagtrak_users foreign key (last_user) references tagtrak_users (user_id));

CREATE INDEX privilege_sk1 ON privilege(last_user) TABLESPACE &1._indexes;

COMMENT ON TABLE PRIVILEGE IS 'This table contains a list of user privileges';

COMMENT ON COLUMN PRIVILEGE.LAST_USER IS  'User identifier of the last user to update this row';
COMMENT ON COLUMN PRIVILEGE.PRIV_CODE IS  'One character privilege code';
COMMENT ON COLUMN PRIVILEGE.PRIV_DESCRIPTION IS  'Description of the privilege';
COMMENT ON COLUMN PRIVILEGE.PRIV_TYPE IS  'Type of privilege';
COMMENT ON COLUMN PRIVILEGE.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN PRIVILEGE.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN PRIVILEGE.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN PRIVILEGE.CUSER IS 'The user who created the row';
COMMENT ON COLUMN PRIVILEGE.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN PRIVILEGE.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN PRIVILEGE.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN PRIVILEGE.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN PRIVILEGE.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
