Showing posts with label FAQ. Show all posts
Showing posts with label FAQ. Show all posts

Friday, April 10, 2009

Recompiling to validate the INVALID Objects : Oracle

On a DB schema, there are many database objects like tables, views, procedures, packages etc.

Here is a case study...
- You want to alter a table for some reason. As a result of running ALTER statement over the table, all dependend objects like Views, Packages gets invalidated irrespective of the fact that change affects/not affects the dependend objects.
- Eg: Assume a table ..

SQL> create table test_foo
( colA varchar2(2)
, colB varchar2(2)
, colC varchar2(2)
);

SQL> create view v_test_foo
as select colA, colB, colC from test_foo;


SQL> select object_name, object_type, status
from user_objects
where object_name in ('TEST_FOO', 'V_TEST_FOO');

----------------------------------------
object_name object_type Status
-----------------------------------------
V_TEST_FOO VIEW VALID
TEST_FOO TABLE VALID


SQL> alter table test_foo add colNew varchar(2);


SQL> select object_name, object_type, status
from user_objects
where object_name in ('TEST_FOO', 'V_TEST_FOO');

----------------------------------------
object_name object_type Status
-----------------------------------------
V_TEST_FOO VIEW INVALID
TEST_FOO TABLE VALID


How do you recompile these ?

I use...
SQL> exec dbms_utility.compile_schema('USERNAME');
-- Substitute an appropriate USERNAME above.

So, how does it behave in Oracle 9i and Oracle 10g ?

The behavior is different in both versions of the Oracle.
Oracle 10g: As you expect, all relevant invalid objects are recompiled and becomes Valid.

Oracle 9i: You should be cautitious.. as VIEWs are not validated.
You have to explicitly compile VIEWs as follows.
ALTER VIEW v_test_foo COMPILE;

Script to Find User Information and More ; Oracle

As a DBA, You might see a lots of users in the DB server.

There are times when you need to find out info about the roles/system pivileges assigned to an user. Following link contain some useful queries to dig information out of the data dictionary tables.

http://www.oracle.com/technology/oramag/code/tips2006/010906.html

Tuesday, March 17, 2009

Troubleshooting vncserver start issues

My purpose was to install Oracle DB server on a Linux server, for which I required to start a VNC session.

I ended up facing the following errors...

error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
X connection to :2.0 broken (explicit kill or server shutdown).
xterm: fatal IO error 32 (Broken pipe) or KillClient on X server ":2.0"

So, began to troubleshoot and fix errors one by one...

How to fix them ?

First, let us fix "error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy".

In my machine, the actual SecurityPolicy file was available in /etc/X11/xserver/SecurityPolicy.
So, created a symbolic link at /usr/X11R6/lib/X11/xserver/ for SecurityPolicy file.

Will post again on how to fix the next issue.

Continuation...
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

How did I get rid of this error ?
A colleague of mine disabled the firewall on the Linux box I was using. Voila, VNC works !