Posts

Showing posts from February, 2024

Query to find tablespace usage

Use the below query to find table space usage  set pages 10000 set linesize 250 col tablespace_name format a15 heading 'TableSpace|Name' col AvailSpace format 9999990.90 heading 'Total Size|(in Mb)' col FreeSpace format 9999990.90 heading 'FreeSpace |(in Mb)' col UsedSpace format 9999990.90 heading 'UsedSpace |(in Mb)' SELECT  dts.tablespace_name,  (ddf.bytes / 1024 / 1024) "AvailSpace",  (ddf.bytes - (dfs.bytes))/1024/1024 "UsedSpace",  (dfs.bytes / 1024 / 1024) "FreeSpace",  TO_CHAR(((ddf.bytes - (dfs.bytes)) / ddf.bytes * 100),'990.00') "Used %"  FROM  sys.dba_tablespaces dts,  (select tablespace_name, sum(bytes) bytes   from dba_data_files group by tablespace_name) ddf,    (select tablespace_name, sum(bytes) bytes     from dba_free_space group by tablespace_name) dfs     WHERE      dts.tablespace_name = ddf.tablespace_name(+)     AND dts.tablespace_name = dfs....

Four ways to connect to PDB

How do I connect to a PDB?   This is a common question among new DBAs, and a valid one indeed!  We are all used to connect to a database with the “/ as sysdba” option, and this is not really working for a PDB. Or is it now? Let’s find out!  Did you know that a PDB is exposed to us as a service, as a service name. When you create a new PDB, and you open it, a service with the same name as the PDB is also created.  This service name will register with the listener, and it will show in the listings of lsnrctl status, or lsnrctl service. You will use this service name of the PDB to create aliases in the tnsnames.ora file, and connect to the PDB. Let’s see the ways we can connect to a PDB.  1) The most common way of connecting to a PDB, if you are on a database server, is to connect first to the CDB, and from there to the PDB. This way you do not need to remember passwords for the admin accounts. Let’s say you have the following container database: PRODCDB, whi...

How Many Processes In the Database Historically?

Image
  The other day, I had an interesting challenge to look at. The maximum number of processes in the database instance was reached, and I had to review if this is was an isolated case, or something that occurred often. There is a data dictionary view that keeps track of the number of processes in the instance for each hourly interval, or however often you take AWR snapshots. Since this view is a   DBA _HIST view, and it is part of AWR, you need to have appropriate licensing in place, before you query it. You have been warned! I personally was not aware of this view! I won’t keep it from you any longer! The view name is:   DBA _HIST_RESOURCE_LIMIT . This view contains snapshots of   V$RESOURCE_LIMIT . The current value, the maximum utilization and the init parameter value for the resource are captured, along with other information. Knowing about this view, makes it easy to track the usage of processes over time, especially if your retention for AWR data is greater than ...