Wednesday, November 28, 2012

SQL Server SYNONYM


First introduced in SQL Server 2005.

SQL Server SYNONYM's can be very useful and can be created for

  • Tables
  • Views
  • Assembly Stored Procedures, Table Valued Functions, Aggregations
  • SQL Scalar Functions
  • SQL Stored Procedures
  • SQL Table Valued Functions
  • SQL Inline-Table-Valued Functions
  • Local and Global Temporary Tables
  • Replication-filter-procedures
  • Extended Stored Procedures


Benefits:

  • SYNONYMs provide a layer of abstraction over the referenced object
  • Allow changes to complicated (multi part) and lengthy names with a simplified alias as a same server resident object.
  • Provides flexibility for changing the location of objects without changing existing code.
  • SYNONYMs can be created in the same database to provide backward compatibility for older applications in case of drop or rename of objects.
  • SYNONYMs can be useful if you give the front-end query tools like spreadsheets and Access linked tables direct links in to the tables.


Limitations:

  • SYNONYMs are loosely bound to the referenced objects. So you can delete a SYNONYM without getting any warning that it is being referenced by any other database object.
  • Chaining is not allowed. It means that you can not create SYNONYM of a SYNONYM.
  • Obviously consumes possible object names, as you can not create a table with the same name of a synonym
  • The object for which the SYNONYM is being created is checked at run time. It is not checked at creation time. So this means that if you make any related error e.g. spelling error, the synonym will created, but you will get an error while accessing the object.
  • SYNONYM can not be referenced in a DDL statement


If we use this option frequently, then keping in mind the facts that:

  • you can delete a SYNONYM without getting any warning that it is being referenced by any other database object
  • the object for which the SYNONYM is being created is checked at run time. It is not checked at creation time.
  • It makes it imperitive that we should plan and monitor synonyms bit more than other objects/references in SQL Server.
  • An additional limitation is that you can't use TRUNCATE TABLE on a synonym.
  • The SSIS Data Profiling task cannot see synonyms



SQL Server synonym links:
http://www.mssqltips.com/sqlservertip/1576/benefits-and-limitations-of-using-synonyms-in-sql-server-2005/
http://connect.microsoft.com/SQLServer/feedback/details/311079/expand-synonym-to-other-entities-database-linked-server
http://msdn.microsoft.com/en-us/library/ms187552.aspx

Tuesday, November 27, 2012

Remote Diagnostic Agent (RDA)


1. Remote Diagnostic Agent (RDA) is a command-line diagnostic tool that is executed by an engine written in the Perl programming language. RDA provides a unified package of support diagnostics tools and preventive solutions. The data captured provides Oracle Support with a comprehensive picture of the customer's environment which aids in problem diagnosis.

2. Oracle document: Remote Diagnostic Agent (RDA) 4 - Getting Started [ID 314422.1]

3. RDA supports different platforms: Windows, UNIX, Linux

4. RDA supports lots of Oracle products: Oracle RDBMS Server (Standard and Enterprise Editions), etc

5. RDA download: a zip file for specific platform

6. Installation on Solaris: unzip

7. run RDA
--check perl version: perl -V
--rda.sh - Use this command if Perl is not available.
--rda.pl - Use this command if Perl is available.
--./rda.pl -S: set up setup.cfg
--run RDA report: ./rda.pl -v
  --ask for password for system to connect to the database


Oracle changePerm.sh script in versions 9.2.0.8, Oracle 10g

changePerm.sh is a script that allows users that do not belong to the "dba" group to access and execute files in the ORACLE_HOME directory.


The script is located in the ORACLE_HOME/install directory on Unix and Linux systems (there is no equivalent for Windows). This script ships with Oracle Database versions 9.2.0.8, Oracle 10g.

The changePerm.sh file is no more available nor necessary for Oracle database server 11.1.0.x because in 11g, permissions under the Oracle Home (including "others") are set correctly/relaxed. (oracle note 834626.1)


===================================
Before change:
$ ls -ld $ORACLE_HOME/lib
drwxr-x---   3 oracle   dba         5632 Nov 27 09:30 /fs/oracle/product/10204ee/lib

Running script:
$ cd $ORACLE_HOME/install
$ ls -l
total 964
-rwxr-xr-x   1 oracle   dba        11380 Nov 22  2007 changePerm.sh
-rw-r-----   1 oracle   dba            0 Jun  7  2005 createseed.sh
-rw-r-----   1 oracle   dba            0 Jun  7  2005 createseed1.sh
-rw-r-----   1 oracle   dba          618 Nov 26 14:19 envVars.properties
-rw-r-----   1 oracle   dba          131 Nov 26 13:51 envVars.properties.bak
-rwxr-xr-x   1 oracle   dba           38 Apr 19  2005 install.excl
drwxr-x---   2 oracle   dba          512 Nov 26 11:55 jlib
-rw-r-----   1 oracle   dba       437788 Nov 26 14:19 make.log
-rw-r-----   1 oracle   dba          102 Nov 26 14:19 portlist.ini
-rw-r--r--   1 oracle   dba          124 Nov 26 14:19 readme.txt
-rw-r--r--   1 oracle   dba         7609 Jan 12  2007 restrict.lst
-rwxr-xr-x   1 oracle   dba          822 Nov 26 14:16 rootdeletenode.sh
-rw-r--r--   1 oracle   dba        10031 Nov 26 14:16 rootlocaladd
-rw-r-----   1 oracle   dba            0 Jun  7  2005 seed.log
-rw-r--r--   1 oracle   dba         2808 Jul 14  2005 templocal
drwxr-x---   2 oracle   dba          512 Nov 26 14:19 unix
drwxr-x---   2 oracle   dba          512 Nov 26 14:13 utl
$ ./changePerm.sh

-------------------------------------------------------------------------------
Disclaimer: The purpose of this script is to relax permissions on some of the
files in the database Oracle Home so that all clients can access them.
Please note that Oracle Corporation recommends using the most restrictive file
permissions as possible for your given implementation.  Running this script
should be done only after considering all security ramifications.
-------------------------------------------------------------------------------

-n Do you wish to continue (y/n) [n]:
y
Spooling the error log /tmp/changePerm_err.log...

Finished running the script successfully

After change:

$ ls -ld $ORACLE_HOME/lib
drwxr-xr-x   3 oracle   dba         5632 Nov 27 09:40 /fs/oracle/product/10204ee/lib

===================================
Reference: http://www.orafaq.com/wiki/ChangePerm_sh