Oracle Database Check Scripts and Database Inventory Scripts | Oracle DBA Scripts All in One -6

Hi,

I will share all Oracle DBA Scripts ( Oracle RAC, Dataguard, Performance Tuning, Monitoring and etc.. ) in this tutorial series.

 

 

Oracle DBA Scripts All in One

Oracle DBA ( Database Administrator ) needs useful scripts to monitor, analyze and check Oracle database for routine database operations and monitoring.

 

 

 

 

Before Oracle DBA Scripts, If you don’t know Oracle database and want to learn, click following link to start learning Oracle database with this tutorial.

 

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

 

 

 

 

Oracle Database Check Scripts

Oracle Database Size, Segment Size and Schema Size Scripts

You can learn Top Schema of database and Schema size with following script.

SELECT * FROM (
SELECT OWNER, SUM(BYTES)/1048576 MB 
from DBA_SEGMENTS 
GROUP BY OWNER 
ORDER BY MB DESC)
WHERE ROWNUM < 20;


You can learn Top segment of database and Table size with following script.

SELECT * FROM (
SELECT SEGMENT_NAME,SEGMENT_TYPE, round(SUM(BYTES)/power(2,20)) SEGMENT_SIZE
FROM DBA_SEGMENTS
GROUP BY SEGMENT_NAME, SEGMENT_TYPE
ORDER BY 3 desc)
WHERE ROWNUM < 31;





Database Inventory Scripts

You can check character set of oracle database with following scripts.

SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';

PARAMETER VALUE
------------------------------ ----------------------------------------
NLS_CHARACTERSET WE8ISO8859P9

 

 

SQL> SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET';

VALUE$
---------------------------------------------------------------------------

WE8ISO8859P9
==========================================================================




You can see all nls database parameters with following script.

SQL> SELECT * FROM NLS_DATABASE_PARAMETERS;




To list installed components of Oracle database, you can execute following query.

SELECT comp_name, version, status FROM dba_registry;


 

Sometimes you need moving tables and indexes to the new tablespace in Oracle.

 

Especially you want to drop any tablespace so you need to discharge or move all tables and indexes to the new tablespace.

 

You can move lots of tables to the new tablespace with using generate move scripts.

select 'ALTER TABLE '||owner||'.'||table_name||' move tablespace '||'NEW_TBS_NAME;' from dba_tables where tablespace_name='PMDB_DAT1';



If your tables are very big, you can use parallel option and move tables parallel like following.

select 'ALTER TABLE '||owner||'.'||table_name||' move tablespace '||'new_tablespace_name parallel 8;' from dba_tables where tablespace_name='DATA';



Use above sql query result and execute them to move tables from one tablespace to new tablespace.

 

You can move lots of indexes to the new tablespace with using generate rebuild scripts.

select 'ALTER INDEX '||owner||'.'||index_name||' REBUILD TABLESPACE '||'new_tablespace online parallel 8;' 
from dba_indexes where tablespace_name='PMDB_NDX1';

 

 

 

You can access the third Oracle DBA scripts related to Blocking Sessions and Lock Kill Scripts with following link.

 

Useful RMAN Backup & Recovery & Restore Scripts | Oracle DBA Scripts All in One -5

 

https://ittutorial.org/dataguard-status-standby-monitoring-command-and-scripts-oracle-dba-scripts-all-in-one-2/

 

 

 

 

Do you want to learn Oracle Database Performance Tuning detailed, then read the following articles.

Performance Tuning and SQL Tuning Tutorial in the Oracle Database

 

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Leave a Reply

Your email address will not be published. Required fields are marked *