Tuesday, August 31, 2010

Nice script to check TBS usage

SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", d.extent_management "Extent Management",
NVL(a.bytes / 1024 / 1024, 0) "Size (M)",
(NVL(a.bytes -NVL(f.bytes, 0), 0)/1024/1024) "Used (M)",
TO_CHAR(NVL((a.bytes -NVL(f.bytes, 0)) / a.bytes * 100, 0), '990.00') "Used %"
FROM sys.dba_tablespaces d, (select
tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, (select
tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f WHERE
d.tablespace_name like '&TABLESPACE%' and d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) AND NOT
(d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')
UNION ALL
SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", d.extent_management "Extent Management",
NVL(a.bytes / 1024 / 1024, 0) "Size (M)", NVL(t.bytes, 0)/1024/1024 "Used (M)",
TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') "Used %"
FROM sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes from dba_temp_files
group by tablespace_name) a, (select tablespace_name, sum(bytes_cached) bytes from
v$temp_extent_pool group by tablespace_name) t WHERE d.tablespace_name = a.tablespace_name(+) AND
d.tablespace_name = t.tablespace_name(+) AND d.extent_management like 'LOCAL' AND d.contents like
'TEMPORARY'
order by 2
/

Monday, March 1, 2010

bumping one particular sequence

----------------checking the nextval in seq---------
conn platform/platform
select SCDB_SUBSCRIPTIONS_ID_SEQ.nextval from dual;

NEXTVAL
----------
140
----------------checking max id in table which is using seq----------

conn scdb_user/scdb_user

select max(id) from SCDB_SUBSCRIPTIONS;

MAX(ID)
----------
50236


note: here table id is more than sequence.
________________________________________________-


so difference b/w table id and seqnnextval should be incremented

50236
- 140
________
50096

SQL> alter sequence platform.SCDB_SUBSCRIPTIONS_ID_SEQ increment by 50096;

Sequence altered.

SQL> select SCDB_SUBSCRIPTIONS_ID_SEQ.nextval from dual;

NEXTVAL
----------
50237


SQL> conn scdb_user/scdb_user

SQL> select max(id) from SCDB_SUBSCRIPTIONS;

MAX(ID)
----------
100333

note: here scdb_user is accessing the sequence of platform user to insert a row in SCDB_SUBSCRIPTIONS table
_____________________________________________________________________________________________________________-

Wednesday, January 27, 2010

Changing hostname on RHEL

Changing hostname on RHEL:

1. Change the HOSTNAME line in /etc/sysconfig/network

2. Change the hostname (FQDN and alias) in /etc/hosts

3. Run /bin/hostname new_hostname for the hostname change to take effect immediately.

4. Run /sbin/service syslog restart for syslog to log using the new hostname.

A reboot is not required to change the system hostname.