Monday, January 9, 2012

Oracle sql query for autoextend off

To find dba data files which are autoextensible:

$select FILE_NAME, AUTOEXTENSIBLE from dba_data_files where FILE_NAME like '%sapdata2%' and AUTOEXTENSIBLE='YES';

To turn off the auto extend for a file :

$ALTER DATABASE DATAFILE '/oracle/BIP/sapdata2/sr3usr_3/sr3usr.data3' autoextend off;

Oracle sql query to find sequence number of archive logs

Oracle sql query to find sequence number of archive logs to be applied for recovery during restoring online database:

$ Select SEQUENCE#,to_char(FIRST_TIME,'YYYY-MM-DD:HH24:MI:SS') FIRST_TIME from v$archived_log where to_char(FIRST_TIME,'YYYY-MM-DD HH24:mi:ss') between '2011-01-10 01:26:54' and '2011-01-11 21:00:00';

Index related oracle sql queries

To create index GLPCA~YG at Database level :

$create index 'GLPCA~YG' on 'GLPCA' ('RCLNT', 'KOKRS', 'RBUKRS', 'RYEAR', 'RPRCTR', 'RACCT', 'POPER') PCTFREE 01 INITRANS 002 TABLESPACE PSAPSR3 STORAGE (INITIAL 000000001 MAXEXTENTS UNLIMITED PCTINCREASE 0000 FREELISTS 001)
To display all indexes starting with the name GLPCA in database:

$select index_name from dba_indexes where index_name like 'GLPCA%';
To drop index GLPCA~YG1 in database:

$drop index sapsr3."GLPCA~YG1";

Monday, January 2, 2012

sort command in unix

To find out the biggest file in the directory in descending order

$du -sk * | sort -n

other beautiful command to find in which file the parameter is defined in directory:

$cd /sapmnt/PEP/profile
$grep "DIR_CCMS" *

ccms agent shared memory problems

During startup of CCMS agent, we were getting the shared memory errors:

$sapccm4x -DCCMS pf=/sapmnt/PEP/profile/PEP_DVEBMGS00_pep0v

INFO: use SAPLOCALHOST ew1app

INFO: CCMS agent sapccmsr working directory is /usr/sap/ccms/EW1_02/sapccmsr

INFO: CCMS agent sapccmsr config file is /usr/sap/ccms/EW1_02/sapccmsr/csmconf
INFO: Central Monitoring System is EW1. (found in config file)
INFO: additional Central Monitoring System is SMS. (found in config file)
INFO: Agent is running (actual pid file is detected)

**********************************************************
Another CCMS Agent is already running with this profile.
**********************************************************

EXITING with code 1

Executing the below command resolved this issue:

sapccm4x -initshm pf=/sapmnt/PEP/profile/PEP_DVEBMGS00_pep0v

when we started again it came up.

Thursday, December 22, 2011

Unix command to sort biggest size file in the directory

$du -sk * | sort -n

How to empty a Unix file system with cat /dev/null command dev null

First take the backup of existing file :

$cp dev_rd.log /sapcd/XVPdev


then empty the file

$cat /dev/null > dev_rd.log

still it was giving error : File exists.

It meant that noclobber option is set so gave command

$cat /dev/null >! dev_rd.log

and it worked