home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 December
/
PCWorld_1998-12_cd.iso
/
software
/
sybase
/
ASA
/
asa60.exe
/
data1.cab
/
scripts_files
/
sysviews.sql
< prev
next >
Wrap
Text File
|
1998-07-27
|
13KB
|
343 lines
-- ************************************************************************
-- * Copyright (C) 1998 by Sybase Inc. All rights *
-- * reserved. No part of this software may be reproduced *
-- * in any form or by any means - graphic, electronic or *
-- * mechanical, including photocopying, recording, taping *
-- * or information storage and retrieval systems - except *
-- * with the written permission of Sybase Inc. *
-- *************************************************************************
--
-- WARNING: This is a program generated file. Do not edit.
--
CREATE VIEW SYS.SYSUSERPERMS
as select user_id, user_name, resourceauth, dbaauth,
scheduleauth, user_group, publishauth, remotedbaauth, remarks
from SYS.SYSUSERPERM
go
GRANT SELECT on SYS.SYSUSERPERMS to SYS
go
IF @avoid_view_collisions = 'N' THEN
CREATE VIEW SYS.SYSCOLUMNS (creator, cname, tname, coltype, nulls, length,
syslength, in_primary_key, "colno", default_value,
column_kind, remarks)
as select (select user_name from SYS.SYSUSERPERM
where user_id = SYSTABLE.creator),
column_name, table_name,
(select domain_name from SYS.SYSDOMAIN
where domain_id = SYSCOLUMN.domain_id),
nulls, width, scale, pkey, column_id, "default",
column_type, SYSCOLUMN.remarks
from SYS.SYSCOLUMN == SYS.SYSTABLE;
GRANT SELECT on SYS.SYSCOLUMNS to SYS;
END IF
go
CREATE VIEW SYS.SYSCATALOG
(creator, tname, dbspacename, tabletype, ncols, primary_key, "check",
remarks)
as select (select user_name from SYS.SYSUSERPERM
where user_id = SYSTABLE.creator),
table_name,
(select dbspace_name from SYS.SYSFILE
where file_id = SYSTABLE.file_id),
if table_type='BASE' then 'TABLE' else table_type endif,
(select count(*) from SYS.SYSCOLUMN
where table_id = SYSTABLE.table_id),
if primary_root = 0 then 'N' else 'Y' endif,
if table_type<>'VIEW' then view_def endif,
remarks
from SYS.SYSTABLE
go
GRANT SELECT on SYS.SYSCATALOG to SYS
go
CREATE VIEW SYS.SYSVIEWS
(vcreator,viewname,viewtext)
as select user_name, table_name, view_def
from SYS.SYSTABLE == SYS.SYSUSERPERM
where table_type = 'VIEW'
go
GRANT SELECT on SYS.SYSVIEWS to SYS
go
IF @avoid_view_collisions = 'N' THEN
CREATE VIEW SYS.SYSINDEXES
(icreator, iname, fname, creator, tname, indextype,
colnames, interval, level_num )
as select (select user_name from SYS.SYSUSERPERM
where user_id = SYSINDEX.creator),
index_name,
(select file_name from SYS.SYSFILE
where file_id = SYSINDEX.file_id),
(select user_name from SYS.SYSUSERPERM
where user_id = SYSINDEX.creator),
table_name,
if "unique" = 'N' then 'Non-unique' else
if "unique" = 'U' then 'UNIQUE constraint'
else 'Unique' endif endif,
(select "list"( string(column_name,
if "order" = 'A' then ' ASC' else ' DESC' endif) )
from SYS.SYSIXCOL==SYS.SYSCOLUMN
where index_id=SYSINDEX.index_id
and SYSIXCOL.table_id=SYSINDEX.table_id),
0, 0
from SYS.SYSTABLE == SYS.SYSINDEX;
GRANT SELECT on SYS.SYSINDEXES to SYS;
END IF
go
CREATE VIEW SYS.SYSUSERAUTH
( name, password, resourceauth, dbaauth, scheduleauth, user_group )
as select user_name, password, resourceauth, dbaauth, scheduleauth, user_group
from SYS.SYSUSERPERM
go
CREATE VIEW SYS.SYSUSERLIST
( name, resourceauth, dbaauth, scheduleauth, user_group )
as select user_name, resourceauth, dbaauth, scheduleauth, user_group
from SYS.SYSUSERPERM
go
GRANT SELECT on SYS.SYSUSERLIST to SYS
go
CREATE VIEW SYS.SYSGROUPS
( group_name, member_name )
as select g.user_name, u.user_name
from SYS.SYSGROUP, SYS.SYSUSERPERM g, SYS.SYSUSERPERM u
where group_id = g.user_id and group_member = u.user_id
go
GRANT SELECT on SYS.SYSGROUPS to SYS
go
CREATE VIEW SYS.SYSCOLAUTH ( grantor, grantee, creator, tname, colname,
privilege_type, is_grantable )
as select
(select user_name from SYS.SYSUSERPERM
where user_id = SYSCOLPERM.grantor),
(select user_name from SYS.SYSUSERPERM
where user_id = SYSCOLPERM.grantee),
(select user_name from SYS.SYSUSERPERM == SYS.SYSTABLE
where table_id = SYSCOLPERM.table_id),
(select table_name from SYS.SYSTABLE
where table_id = SYSCOLPERM.table_id),
(select column_name from SYS.SYSCOLUMN
where table_id = SYSCOLPERM.table_id
and column_id = SYSCOLPERM.column_id),
privilege_type,
is_grantable
from SYS.SYSCOLPERM
go
GRANT SELECT on SYS.SYSCOLAUTH to SYS
go
CREATE VIEW SYS.SYSTABAUTH
( grantor, grantee, screator, stname, tcreator, ttname,
selectauth, insertauth, deleteauth,
updateauth, updatecols, alterauth, referenceauth )
as select
(select user_name from SYS.SYSUSERPERM
where user_id = SYSTABLEPERM.grantor),
(select user_name from SYS.SYSUSERPERM
where user_id = SYSTABLEPERM.grantee),
(select user_name from SYS.SYSUSERPERM == SYS.SYSTABLE
where table_id = SYSTABLEPERM.stable_id),
(select table_name from SYS.SYSTABLE
where table_id = SYSTABLEPERM.stable_id),
(select user_name from SYS.SYSUSERPERM == SYS.SYSTABLE
where table_id = SYSTABLEPERM.ttable_id),
(select table_name from SYS.SYSTABLE
where table_id = SYSTABLEPERM.ttable_id),
selectauth, insertauth, deleteauth,
updateauth, updatecols, alterauth, referenceauth
from SYS.SYSTABLEPERM
go
GRANT SELECT on SYS.SYSTABAUTH to SYS
go
CREATE VIEW SYS.SYSOPTIONS ( user_name, "option", "setting" )
as select
(select user_name from SYS.SYSUSERPERM
where user_id = SYSOPTION.user_id),
"option", "setting"
from SYS.SYSOPTION
go
GRANT SELECT on SYS.SYSOPTIONS to SYS
go
CREATE VIEW SYS.SYSUSEROPTIONS
( "user_name", "option", "setting" )
as SELECT
u.name,
"option",
isnull( (SELECT "setting"
FROM SYS.SYSOPTIONS s
WHERE s.user_name = u.name
AND s."option" = o."option" ),
"setting" )
FROM SYS.SYSOPTIONS o, SYS.SYSUSERAUTH u
WHERE o.user_name = 'PUBLIC'
go
GRANT SELECT on SYS.SYSUSEROPTIONS to SYS
go
CREATE VIEW SYS.SYSFOREIGNKEYS
( foreign_creator, foreign_tname,
primary_creator, primary_tname, role, columns )
as select
(select user_name from SYS.SYSUSERPERM == SYS.SYSTABLE
where table_id = foreign_table_id),
(select table_name from SYS.SYSTABLE
where table_id = foreign_table_id),
(select user_name from SYS.SYSUSERPERM == SYS.SYSTABLE
where table_id = primary_table_id),
(select table_name from SYS.SYSTABLE
where table_id = primary_table_id),
role,
(select "list"( string( FK.column_name, ' IS ', PK.column_name ) )
from SYS.SYSFKCOL == SYS.SYSCOLUMN FK, SYS.SYSCOLUMN PK
where foreign_table_id = SYSFOREIGNKEY.foreign_table_id
and foreign_key_id = SYSFOREIGNKEY.foreign_key_id
and PK.table_id = SYSFOREIGNKEY.primary_table_id
and PK.column_id = SYSFKCOL.primary_column_id)
from SYS.SYSFOREIGNKEY
go
GRANT SELECT on SYS.SYSFOREIGNKEYS to SYS
go
CREATE VIEW SYS.SYSPROCPARMS
(creator, parmname, procname, parmtype, parmmode, parmdomain,
length, remarks)
as select (select user_name from SYS.SYSUSERPERM
where user_id = SYSPROCEDURE.creator),
parm_name, proc_name,
parm_type,
if parm_mode_in = 'Y' and parm_mode_out = 'N' then 'IN'
else if parm_mode_in = 'N' and parm_mode_out = 'Y' then 'OUT'
else 'INOUT'
endif endif,
(select domain_name from SYS.SYSDOMAIN
where domain_id = SYSPROCPARM.domain_id),
width,
SYSPROCPARM.remarks
from SYS.SYSPROCPARM == SYS.SYSPROCEDURE
go
GRANT SELECT on SYS.SYSPROCPARMS to SYS
go
CREATE VIEW SYS.SYSTRIGGERS
("owner", trigname, tname, event, trigtime, trigdefn)
as select (select user_name from SYS.SYSUSERPERM
where user_id = SYSTABLE.creator),
trigger_name,
table_name,
if event = 'I' then 'INSERT'
else if event = 'U' then 'UPDATE'
else if event = 'C' then 'UPDATE'
else if event = 'D' then 'DELETE'
else if event = 'A' then 'INSERT,DELETE'
else if event = 'B' then 'INSERT,UPDATE'
else if event = 'E' then 'DELETE,UPDATE'
else 'INSERT,DELETE,UPDATE' endif endif endif endif endif endif endif,
if trigger_time = 'B' or trigger_time = 'P' then 'BEFORE'
else if trigger_time = 'A' or trigger_time = 'S' then 'AFTER'
else if trigger_time = 'R' then 'RESOLVE'
else 'INSTEAD OF' endif endif endif,
trigger_defn
from SYS.SYSTRIGGER == SYS.SYSTABLE
where foreign_table_id is null
go
GRANT SELECT on SYS.SYSTRIGGERS to SYS
go
CREATE VIEW SYS.SYSPROCAUTH
(grantee, creator, procname)
as select (select user_name from SYS.SYSUSERPERM
where SYSPROCPERM.grantee = SYSUSERPERM.user_id),
(select user_name from SYS.SYSUSERPERM
where SYSPROCEDURE.creator = SYSUSERPERM.user_id),
proc_name
from SYS.SYSPROCEDURE == SYS.SYSPROCPERM
go
GRANT SELECT on SYS.SYSPROCAUTH to SYS
go
CREATE VIEW SYS.SYSREMOTETYPES
as select type_id, type_name, publisher_address, remarks
FROM SYS.SYSREMOTETYPE
go
GRANT SELECT on SYS.SYSREMOTETYPES to SYS
go
CREATE view SYS.SYSPUBLICATIONS
as select
(select user_name from SYS.SYSUSERPERM u
where u.user_id = p.creator) as creator,
publication_name, remarks
FROM SYS.SYSPUBLICATION p
go
GRANT SELECT on SYS.SYSPUBLICATIONS to SYS
go
CREATE view SYS.SYSARTICLES
as select
(select publication_name from SYS.SYSPUBLICATION p
where p.publication_id = a.publication_id) as publication_name,
(select table_name from SYS.SYSTABLE t
where t.table_id = a.table_id) as table_name,
where_expr, subscribe_by_expr
FROM SYS.SYSARTICLE a
go
GRANT SELECT on SYS.SYSARTICLES to SYS
go
CREATE view SYS.SYSARTICLECOLS
as select
(select publication_name from SYS.SYSPUBLICATION p
where p.publication_id = ac.publication_id) as publication_name,
(select table_name from SYS.SYSTABLE t
where t.table_id = ac.table_id) as table_name,
(select column_name from SYS.SYSCOLUMN c
where c.table_id = ac.table_id
and c.column_id = ac.column_id) as column_name
FROM SYS.SYSARTICLECOL ac
go
GRANT SELECT on SYS.SYSARTICLECOLS to SYS
go
CREATE VIEW SYS.SYSREMOTEUSERS
as select
(select user_name from SYS.SYSUSERPERM u
where u.user_id = r.user_id) as user_name,
consolidate,
(select type_name from SYS.SYSREMOTETYPE t
where t.type_id = r.type_id) as type_name,
address, frequency, send_time,
( if frequency = 'A' then
NULL
else
if frequency = 'P' then
if time_sent IS NULL then
CURRENT TIMESTAMP
else
( select min( minutes( time_sent,
60 * hour(a.send_time)
+ minute( seconds( a.send_time, 59 ) ) ) )
FROM SYS.SYSREMOTEUSER a
WHERE a.frequency = 'P'
AND a.send_time = r.send_time )
endif
else
if CURRENT DATE + send_time >
coalesce(time_sent,CURRENT TIMESTAMP) then
CURRENT DATE + send_time
else
CURRENT DATE + send_time + 1
endif
endif
endif ) as next_send,
log_send,
time_sent, log_sent, confirm_sent, send_count, resend_count,
time_received, log_received, confirm_received, receive_count, rereceive_count
FROM SYS.SYSREMOTEUSER r
go
GRANT SELECT on SYS.SYSREMOTEUSERS to SYS
go
CREATE view SYS.SYSSUBSCRIPTIONS
as select
(select publication_name from SYS.SYSPUBLICATION p
where p.publication_id = s.publication_id) as publication_name,
(select user_name from SYS.SYSUSERPERM u
where u.user_id = s.user_id) as user_name,
subscribe_by, created, started
FROM SYS.SYSSUBSCRIPTION s
go
GRANT SELECT on SYS.SYSSUBSCRIPTIONS to SYS
go
COMMIT WORK
go