Thursday, 4 June 2015

Linux "history" command with timestamp

While trying to find out exactly at which time some Linux command ran, the history command can help, especially combined witht the below settings, to get the timestamp also:

 >export HISTTIMEFORMAT="%F %T "
>history 10
 1094  2015-06-04 11:56:32 showsess -a
 1095  2015-06-04 11:56:34 showsess -a
 1096  2015-06-04 11:56:36 cd Log/
 1097  2015-06-04 11:56:37 ll -tr
 1098  2015-06-04 11:58:59 export HISTTIMEFORMAT="%F %T "
 1099  2015-06-04 11:59:02 history -5
 1100  2015-06-04 11:59:05 history 5
 1101  2015-06-04 11:59:14 clear
 1102  2015-06-04 11:59:17 export HISTTIMEFORMAT="%F %T "
 1103  2015-06-04 11:59:20 history 10

Friday, 27 February 2015

On which table/index am I waiting?

Sometimes is handy to know on which object our query is working hard and there is a nice query that could help us with this:

  SQL>select segment_name,segment_type,owner,tablespace_name from
  2  dba_extents,v$session_wait
  3  where file_id=p1
  4  and p2 between block_id and block_id + blocks -1;

Of course, this will work when the wait event in v$session_wait is pointing on table/index scan (db buffer wait, scattered read and so on).

Sunday, 8 February 2015

How to trace a specific query, using its SQL_ID?

The answer is to use "set events":

alter system set events 'sql_trace[sql:gb07958tf8xdk] bind=true,wait=false';

A few more detailed examples at:
http://oraclue.com/2009/03/24/oracle-event-sql_trace-in-11g/


Monday, 26 January 2015

Use vi to replace some pattern, but only for specific lines

Sometimes is very handful to use the Unix/Linux utility "vi" to replace a specific pattern, but there is a special syntax if we only want to do it for a specific range of rows, see exmaple below:

Use find and replace on line ranges (match by line numbers)

You can also make changes on range of lines i.e. replace first occurrence of foo with bar on lines 5 through 20 only, enter:
:5,20s/foo/bar/

Tuesday, 16 December 2014

Running out of space in /tmp while using the "vi" editor

The "vi" editor is using the /tmp directory to place its buffer and whenever there is shortage of space there, vi is failing.
The solution below worked for me as a charm:

>cd my_directory
>vi

 Inside vi:

:set directory=my_new_temp
:e file_name

where my_new_temp is a directory with enough disk space free and file_name is the name of the file to edit.

Friday, 3 October 2014

Is supplemenal logging enabled for my table?

The answer comes in by querying the view below:

SQL>select * from dba_log_groups;

As easy as this :-)

dbua is failing during 12c upgrade: "you do not have enough tablespace free space or disk space to complete the upgrade."

During a 12c upgrade from 11.2, using dbua, I've received the error message above, even that all the tablespace had enough disk space and no space shortage in any file system either.
 The dbua trace file mentioned that the error was related to UNDOTBS tablespace.

The solution was to make the UNDOTBS datafile exensible, and the dbua went on :-)

SQL>alter database datafile '/mydb/ora_data02/undo_MYDB_01.dbf' autoextend on;

The issue here was that the dbua was failing, even that all the logs indicated that the space was OK.