10.28.2009

Pinter Setting

Suppose,
My printer IP: 192.168.4.101
Queue Name: PS-FL1-U
Manufacturer/Model: HP/LaserJet 1020

Now, I have to follows the steps:

The following steps are for debian users. This should work on ubuntu too.
Other linux distribution/OS users please see corresponding cups documentation.

* As root issue the following command
apt-get install cupsys foomatic-db foomatic-filters-ppds
* Fire up your browser and go http://localhost:631
* Click "Administration"
* Click "Add printer"
* Give a name e.g ."HP". The rest two are optional. Click "Continue"
* Choose "LPD/LPR Host or Printer"
* Put "lpd://printer-ip-address/queue-name" from above table like "lpd://192.168.1.213/PS-FL2-U"
* Select "HP"
* Choose "HP LaserJet 1010 Foomatic/hpijs (en)"
* Click "Add Printer"
* You are done.
* Don't give "Test page" print.
* Print the first page of your document you want to print to test whether the setup is successful.

OEM Basic

I have created a new user USER1. I want to connect OEM for this user. So -
grant connect, resource to user1;
grant select_catalog_role to user1;

To create a new DBControl repository:

emca -config dbcontrol db -repos create

To start a DB Console:
emctl start dbconsole

Managing the agent:
oracle@terminus ~$ set ORACLE_SID=sid
oracle@terminus ~$ echo $ORACLE_SID
THRP
oracle@terminus ~$ emctl stop agent
Stopping Oracle Enterprise Manager 10g Database Control Stopped.
Agent is not running.

oracle@terminus ~$ emctl start agent
Starting agent .... started.
oracle@terminus ~$ emctl start dbconsole
oracle@terminus ~$ emctl status agent

Agent is Running and Ready

When error:
emca -config dbcontrol db -repos recreate


Oracle Enterprise Manager (OEM) is a set of systems management tools provided by Oracle Corporation for managing the Oracle environment and automate tasks.

Database control: OEM application for managing a single Oracle Database.

Grid control: OEM's web based interface for centrally managing all your Oracle environments from a single point.

Implementation: OEM creates a SYSMAN schema in the Oracle DB to store metadata and statistics. SYSMAN also acts as the super-administrator account for first-time login. The default password for SYSMAN is oem_temp.

10.22.2009

ORA-00600

ORA-00600: internal error code, arguments: [kkoljt1], [], [], [], []


I was getting this ERROR by running a query in saturn.
I was also running the same query in terminus, but there was no error.

Then I checked in both server:

1. select banner from v$version;

Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production


Both was same.

2. show parameter optimizer

@saturn:
optimizer_features_enable string 10.2.0.3

@terminus:
optimizer_features_enable string 10.2.0.2

Then @saturn I run -
alter system set optimizer_features_enable='10.2.0.2';

And, the problem solved. :)

10.19.2009

Tablespaces

CREATE:
CREATE
SMALLFILE TABLESPACE "TEST_NAHAR"
DATAFILE '/oracle/oradata/TEST_NAHAR_01.dbf'
SIZE 10M
REUSE LOGGING
EXTENT MANAGEMENT LOCAL
UNIFORM SIZE 1024K
SEGMENT SPACE MANAGEMENT AUTO;

Syntax-2:

DROP TABLESPACE "DATA02" INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;

CREATE TABLESPACE "TS_DATA02"
DATAFILE '/oradata/datafiles/THRP/DF_DATA02.dbf'
SIZE 1G
AUTOEXTEND ON
NEXT 50M
MAXSIZE 30G
BLOCKSIZE 8K;


Syntax-3:
CREATE TABLESPACE "DATA02"
DATAFILE '/oracle/oradata/JUPITER/DATA02_01.dbf'
SIZE 100M
BLOCKSIZE 8K;



DROP:
DROP TABLESPACE TEST_NAHAR
INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;

ALTER:

SQL> ALTER TABLESPACE users OFFLINE;
SQL> ALTER TABLESPACE users ONLINE;

DBA_TABLESPACES Details:

If I set
REUSE LOGGING, then LOGGING=LOGGING will set.
If I set BLOCKSIZE 8K, then BLOCKSIZE=8192 will set.
If I set BLOCKSIZE 16K, then BLOCKSIZE=16384 will set.

Default Settings:
LOGGING=LOGGING
EXTENT MANAGEMENT = LOCAL
SEGMENT_SPACE_MANAGEMENT=AUTO

DBA_DATA_FILES Details:
BYTES=10485760 =>SIZE 10M (10*1024*1024)

Q: Which Tablespace contains which datafile?
select t.tablespace_name, d.file_name, t.segment_space_management, t.block_size, t.bigfile
from DBA_TABLESPACES t,DBA_DATA_FILES d
where t.tablespace_name=d.tablespace_name
order by t.tablespace_name;

Or simply,
select d.tablespace_name,d.file_name
from DBA_DATA_FILES d
order by d.tablespace_name;

Q: How to Check OBJECT on Tablespace?
select owner, segment_name, segment_type, tablespace_name
from dba_segments
where lower(segment_name) like lower('%SYS_LOB0000151343C00022%')
order by owner, segment_name;

Q: How to Check all OBJECTs of a Tablespace?
select owner, segment_name, segment_type, tablespace_name
from dba_segments
where lower(tablespace_name) like lower('%DATA02%')
order by owner, segment_name;

10.08.2009

Working with Vi

Positioning the Cursor:

® Move cursor one space right.
¬ Move cursor one space left.
­ Move cursor up one line.
¯ Move cursor down one line.

ctrl-F Move forward one screen.
ctrl-B Move backward one screen.

$ Move cursor to end of line.
^ Move cursor to beginning of line.
:1 Move to first line of file
:$ Move to last line of file
/ Search for a character string.
? Reverse search for a character string.
x Delete the character at the cursor position.
dd Delete the current line.
p Paste data that was cut with x or dd commands.
u Undo.


Entering Input Mode:
a Add text after the cursor.
i Insert text before the cursor.
R Replace text starting at the cursor.
o Insert a new line after the current one.


Entering Command Mode:
esc Switch from Input mode to Command mode.


Exiting or Saving Your File:
:w Write file to disk, without exiting editor.
ZZ Save the file and exit.
:q! Quit without saving.

10.05.2009

Hints

Why using hints?
Oracle comes with an optimizer that promises to optimize a query's execution plan.
When this optimizer is really doing a good job, no hints should be required at all.

Sometimes, however, the characteristics of the data in the database are changing rapidly, so that the optimizer (or more accuratly, its statistics) are out of date. In this case, a hint could help.
It must also be noted, that Oracle allows to lock the statistics when they look ideal which should make the hints meaningless again.

All hints except /*+ rule */


Example:

SELECT /*+ index(t1 t1_abc) index(t2 t2_abc) */ COUNT(*)
FROM t1, t2
WHERE t1.col
1 = t2.col1;


FIRST_ROWS(n):
The FIRST_ROWS hint explicitly chooses the cost-based approach to optimize a statement block with a goal of best response time (minimum resource usage to return first row).

set autotrace trace exp

SELECT table_name FROM dba_tables
WHERE owner = 'SYS' AND table_name LIKE '%$' ORDER BY 1;

SELECT
/*+ FIRST_ROWS(10) */ table_name
FROM dba_tables WHERE owner = 'SYS'
AND table_name LIKE '%$' ORDER BY 1;

Access Method INDEX:

CREATE INDEX ix_customers_gender
ON customers(gender);

set autotrace traceonly explain

SELECT * FROM customers WHERE gender = 'M';

SELECT /*+ INDEX(customers ix_customers_gender) */ *
FROM customers WHERE gender = 'M';

SELECT
/*+ INDEX_ASC(customers ix_customers_gender) */ *
FROM customers WHERE gender = 'M';

SELECT
/*+ INDEX_DESC(customers ix_customers_gender) */ *
FROM customers WHERE gender = 'M';

We can use First row and Index Together:

/*+FIRST_ROWS(20) INDEX(table_alias index_name) */

Links:

http://psoug.org/reference/hints.html
http://www.adp-gmbh.ch/ora/sql/hints/index.html