Custom Search
www.rocket99.com : Technical Guides Sybase Oracle UNIX Javascript


Technical Guides
Sybase
Oracle
UNIX
Javascript




Of Interest

Business Intelligence and Analytics



Oracle Training





Sybase » Administration » DBA » Sybase IQ

Sybase IQ : Comparing grants / permissions between servers

     

The scripts detailed below will compare SERVER_A with SERVER_B .. and generate the SQL to be applied to SERVER_B, to make it current with SERVER_A.
 #!/bin/bash
 #==========================================
 #
 #  iq_compare_grants.sh
 #
 #==========================================
 
 server1=$1
 server2=$2
 
 if test $# -ne 2; then
      echo "Parms:  ServerA  ServerB"
      exit
 fi
 
 tfile1=/opt/dba/util/temp/${server1}.dat
 tfile2=/opt/dba/util/temp/${server2}.dat
 tfile3=/opt/dba/util/temp/${server2}_needs.dat
 
 cd /opt/dba/util/scripts
 
 echo "Examining $server1 ...."
 ./iq_perms_listing.sh $server1 > $tfile1
 sleep 2
 
 echo "Examining $server2 ...."
 ./iq_perms_listing.sh $server2 > $tfile2
 sleep 2
 
 echo "Detecting differences .."
 sleep 2
 
 ./file_diff.pl $tfile1 $tfile2 > $tfile3
 
 ct=`grep -i grant $tfile3 | wc -l`
 
 if test $ct -gt 0 ; then
    echo "Warning: $ct grant differences detected."
    sleep 2
    cat $tfile3
    echo " "
    echo "File to check .... $tfile3"
 else
    echo "Compare OK."
 fi
 
 #!/bin/bash
 #==============================================================
 # iq_perms_listing.sh
 #
 # Generate all grant statements for the specified IQ server
 #
 #==============================================================
 
 iqserver=$1
 
 sdir=/opt/dba/util/scripts
 secret=julia123
 sqlfile=iq_perms_listing.sql
 
 isqlx=${sdir}/isql.sh
 
 cd $sdir
 
 echo "ISQL .."
 
 $isqlx $iqserver -Udba -P$secret -i$sqlfile > _perms1.dat
 
 echo "Perl .."
 
 ./iq_perms_listing.pl _perms1.dat _perms2.dat
 
 echo "Done .."
 sleep 1
 
 cat _perms2.dat
 

 -- iq_perms_listing.sql
 
 select substring(t4.user_name,1,25) as USER1, substring(t1.table_name,1,44) as TNAME, substring(t2.user_name,1,25) as USER2,
 t3.selectauth, t3.insertauth, t3.deleteauth, t3.updateauth
 from    SYSTABLE t1, SYSUSERPERM t2, SYSTABLEPERM t3, SYSUSERPERM t4
 where   t3.stable_id = t1.table_id and
         t2.user_id   = t3.grantee  and
         t4.user_id   = t1.creator
 order by 1,2
 go
 

 #!/usr/bin/perl
 #==============================================================
 # iq_perms_listing.pl
 #
 # Filter / generate grant SQL
 #
 #==============================================================
 
 $infile   = $ARGV[0];
 $outfile  = $ARGV[1];
 
 open (FILE1,"<$infile") or die "Error .. FILE1\n\n" ;
 open (FILE2,">$outfile") or die "Error .. FILE2\n\n" ;
 
 while ()
   {
   $line1 = $_ ;
   chomp $line1;
 
   if ($line1 =~ / PUBLIC /)
      { $line1 = ' '; }
   if ($line1 =~ / dbo /)
      { $line1 = ' '; }
 
   @line1 = split ' ', $line1 ;
 
   $owner_user  = shift @line1 ;
   $tname  = shift @line1 ;
   $user   = shift @line1 ;
   $select = shift @line1 ;
   $insert = shift @line1 ;
   $delete = shift @line1 ;
   $update = shift @line1 ;
 
   if ($select eq 'Y')
        {  print FILE2  "grant select on $owner_user.$tname to $user;\n" }
   if ($update eq 'Y')
        {  print FILE2  "grant update on $owner_user.$tname to $user;\n" }
   if ($delete eq 'Y')
        {  print FILE2  "grant delete on $owner_user.$tname to $user;\n" }
   if ($insert eq 'Y')
        {  print FILE2  "grant insert on $owner_user.$tname to $user;\n" }
 
   }
 
 close (FILE1);
 close (FILE2);
 






Sybase : Related Topics

Sybase : Administration : Post-installation check
Sybase : Administration : Device initialization
Sybase : Administration : Database Creation
Sybase : Administration : A backup routine
Sybase : Administration : Striping Dump Devices
Sybase : Administration : Moving the transaction log to another device
Sybase : Administration : Adding a segment to a database
Sybase : Administration : Configuring the cache
Sybase : Administration : Apply multiple transaction dumps
Sybase : Administration : Database maintenance procedure
Sybase : Administration : Database maintenance script
Sybase : Administration : Server configuration
Sybase : Administration : Dealing with a Corrupted Database
Sybase : Administration : Dealing with a Server Failure
Sybase : Administration : DBCC Notes
Sybase : Administration : Create proxy tables and external logins
Sybase : Administration : Renaming a database
Sybase : Administration : Reorg: rebuilding a table
Sybase : Administration : Sybase ASE 15 Enhancements
Sybase : Administration : Setting the thresholds
Sybase : Administration : Apply a transaction dump
Sybase : Administration : Security Tasks
Sybase : Administration : Setting Process Priorities
Sybase : Administration : Sybase ASE Architecture Overview
Sybase : Administration : Drop an alias, with objects linked to login
Sybase : Administration : Display grants, effective rights to objects
Sybase : Administration : Displaying access information from sysprotects
Sybase : Administration : Database Engines: Status and Settings
Sybase : Administration : Replication Server 15 Configuration
Sybase : Administration : Loading data into Sybase IQ from a Remote Server
Sybase : Administration : Sybase IQ Overview
Sybase : Administration : Sybase IQ Functions
Sybase : Administration : Sybase IQ - Remote Access From ASE
Sybase : Administration : Sybase IQ : Procedure Profiling / Monitoring
Sybase : Administration : Sybase IQ: Restoring a Database from Dump Files
Sybase : Administration : Sybase IQ: Minimize Storage option
Sybase : Administration : Sybase IQ: Index Types
Sybase : Administration : Sybase IQ: HUGEPAGE Support
Sybase : Administration : Sybase IQ: Database Creation (Raw Devices)
Sybase : Administration : Sybase IQ : Repairing Problems / Troubleshooting Corruption
Sybase : Administration : Sybase IQ : Moving / Re-allocating / Re-org
Sybase : Administration : Sybase IQ: Sysmon / System Performance Analysis
Sybase : Administration : Sybase IQ: Monitoring Connections / Processes
Sybase : Administration : Sybase ASE: Installing a new server via srvbuildres utility
Sybase : Administration : Sybase IQ: Copying users/logins between databases
Sybase : Administration : Sybase IQ: Managing User Accounts
Sybase : Administration : Sybase ASE: Database Schema Compare
Sybase : Administration : Sybase IQ: Listing tables, ordered by size allocated
Sybase : Administration : Sybase ASE: Database page size
Sybase : Administration : Sybase ASE: Managing users and roles
Sybase : Administration : Sybase ASE: Setting resource limits for users
Sybase : Administration : Sybase ASE: Setting up user assigned custom tempdbs
Sybase : Administration : Sybase ASE: Setting up the transaction log cache using logiosize
Sybase : Administration : Sybase IQ: Server Startup Switches
Sybase : Administration : Sybase ASE: Managing Identity Columns
Sybase : Administration : Sybase IQ: Working with options and server settings
Sybase : Administration : Sybase IQ: Monitoring and Troubleshooting via System Procedures

Sybase Web Site
Sybase iAnywhere Mobile Web Site
Oracle Enterprise Web Site



Get the latest Rocket99 news and tech tips via






Site Index About this Guide to Sybase, Oracle, and UNIX Contact Us Advertise on this site




Copyright © 2016 Stoltenbar Inc All Rights Reserved.