| View / Table ------------------------------ |
Purpose / Usage ----------------------------------------------------------------------------------- |
|---|---|
v$dataguard_stats |
Shows Data Guard apply/transport lag statistics. |
v$dataguard_status |
Displays Data Guard error/status messages. |
v$dataguard_config |
❌ Not a standard Oracle view (possibly custom). |
v$dataguard_process |
Shows active Data Guard background processes (RFS, MRP, etc.). |
v$bgprocess |
Lists all background processes running in the instance. |
v$active_instances |
Lists active instances in RAC environments. |
v$active_services |
Shows currently active services in the instance. |
v$active_session_history |
ASH data; samples active sessions for performance diagnostics. |
dba_activity_table |
❌ Not standard — likely custom. Use DBA_AUDIT_TRAIL for DML audit. |
dba_app_errors |
Lists compilation errors for PL/SQL programs. |
dba_applications |
Lists applications registered (e.g., Workspace Manager). |
dba_ddl_locks |
Shows schema-level locks (DDL operations). |
dba_dml_locks |
Displays row-level DML locks (e.g., UPDATE, INSERT). |
dba_db_links |
Lists all defined DB links and their properties. |
dba_db_link_sources |
Shows which users/objects use DB links. |
dba_dependencies |
Shows object dependencies (views, packages, tables). |
dba_directories |
Lists Oracle Directory objects (for UTL_FILE, Data Pump, etc.). |
dba_goldengate_privileges |
Lists users with Oracle GoldenGate replication privileges. |
v$dbfile |
Lists datafiles and status info for current instance. |
v$tempfile |
Lists tempfiles used by temporary tablespaces. |
v$logfile |
Lists redo log files and their group/size/status. |
dba_data_files |
Lists all permanent datafiles and their details. |
dba_temp_files |
Lists all tempfiles in temp tablespaces. |
v$rman_configuration |
Displays RMAN configuration parameters (retention, device type). |
v$result_cache_objects |
Lists cached results; check for cache flushes here. |
v$passwordfile_info |
Shows info about Oracle password file usage. |
v$pdbs |
Lists PDBs (Pluggable Databases) in a CDB environment. |
v$parameter_valid_values |
Lists valid values for init parameters (for validation). |
v$obsolete_backup_files |
Shows obsolete backups eligible for deletion by RMAN. |
v$obsolete_parameter |
Lists deprecated/obsolete init parameters. |
v$instance_ping |
RAC view; shows block ping stats between instances. |
v$session_connect_info |
Shows connection protocol/service per session. |
Wednesday, August 6, 2025
Dataguard standby views
Friday, July 25, 2025
RMAN BACKUP FOR PATCHING AND UPGRADES
| NAME | SCN | GUARANTEE_FLASHBACK_DATABASE | TIME |
|---|---|---|---|
| GRP_B4UPGRADE | 123456789 | YES | 25-JUL-25 07.10.05.000000 PM |
| Column/Function | Respects Session Time Zone? | Type |
|---|---|---|
startup_time |
❌ No | DATE |
SYSTIMESTAMP |
✅ Yes | TIMESTAMP WITH TIME ZONE |
CURRENT_TIMESTAMP |
✅ Yes | TIMESTAMP WITH TIME ZONE |
LOCALTIMESTAMP |
✅ Yes | TIMESTAMP |
To convert a DATE value to IST (Indian Standard Time) in Oracle, you need to:
-
Cast the DATE to TIMESTAMP (because
DATEdoes not store time zone info). -
Attach the database time zone using
FROM_TZ. -
Convert it to IST using
AT TIME ZONE 'Asia/Kolkata'.
✅ General Syntax
sqlSELECT
FROM_TZ(CAST(your_date_column AS TIMESTAMP), DBTIMEZONE)
AT TIME ZONE 'Asia/Kolkata' AS converted_to_ist
FROM your_table;
Friday, July 4, 2025
Grants read-only access on all schemas tables in oracle
SQL> BEGIN
FOR x IN (select table_name from dba_tables where owner='SCHEMA_OWNER') LOOP
EXECUTE IMMEDIATE 'GRANT SELECT ON PUNE.'|| x.table_name ||' TO <role_name>';
END LOOP;
END;
/
SQL> CREATE USER <username> IDENTIFIED BY "<password>"
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
PROFILE "DEFAULT"; 2 3 4
User created.
SQL> create role pune_ro;
role created.
SQL> show user;
USER is "SYS"
SQL> BEGIN
FOR x IN (select table_name from dba_tables where owner='PUNE') LOOP
EXECUTE IMMEDIATE 'GRANT SELECT ON PUNE.'|| x.table_name ||' TO pune_ro';
END LOOP;
END;
/ 2 3 4 5 6
PL/SQL procedure successfully completed.
SQL> alter user <username> default role all;
User altered.
SQL> grant app_user_dbpull to <username> ;
Grant succeeded.
SQL> revoke select on pune.alert from <username>;
Revoke succeeded.
SQL> grant pune_ro to <username>;
Grant succeeded.
---
1. create a user
1.1 alter user <username> default role all;
2. create a role
3. grant all tables select on access on schemas tables
4. grant the role to <username>
Saturday, May 24, 2025
Monday, April 21, 2025
Thursday, March 20, 2025
Thursday, March 13, 2025
SQL styling and formatting !!!!!
2025-03-12 00:11:11 ERROR OGG-01169 Encountered an update where all key columns for target table SCHEMA.TABLE_NAME are not present
INDEX REBUILD TIME SQL
select sql_text,sql_id from gv$sqlstats where sql_text like '%SCHEMA.INDEX_NAME%';
abfxhr2v2bqgf
select sid,serial# from gv$session_longops where sql_id='abfxhr2v2bqgf ';
SID SERIAL#
----------------------------
2200 44444
select round(time_remaining/60) time_remaining_mins from gv$session_longops where sid='2200' and serial# = '44444';
TIME_REMAINING_MINS
----------------------------------
33
Wednesday, March 12, 2025
DBMS_METADATA package to extract objects DDL
Thursday, February 27, 2025
DBMS_STATS.GATHER_STATS for tables schemas indexes columns
| Action | Full Command | Description |
|---|---|---|
| Update statistics for a specific table | EXEC DBMS_STATS.GATHER_TABLE_STATS('HR', 'EMPLOYEES'); | Updates statistics for the EMPLOYEES table in the HR schema. |
| Update statistics for a table and its indexes | EXEC DBMS_STATS.GATHER_TABLE_STATS('HR', 'EMPLOYEES', cascade => TRUE); | Updates statistics for the EMPLOYEES table and all its indexes. |
| Update statistics for a specific index | EXEC DBMS_STATS.GATHER_INDEX_STATS('HR', 'EMP_SALARY_IDX'); | Updates statistics for the EMP_SALARY_IDX index in the HR schema. |
| Update statistics for all tables in a schema | EXEC DBMS_STATS.GATHER_SCHEMA_STATS('HR'); | Updates statistics for all tables and indexes in the HR schema. |
| Update statistics for the entire database | EXEC DBMS_STATS.GATHER_DATABASE_STATS; | Updates statistics for all schemas and tables in the database. (Time-consuming on large DBs) |
| Check last statistics update for a table | SELECT table_name, last_analyzed FROM user_tables WHERE table_name = 'EMPLOYEES'; | Shows the last time statistics were gathered for the EMPLOYEES table. |
| Check last statistics update for an index | SELECT index_name, last_analyzed FROM user_indexes WHERE table_name = 'EMPLOYEES'; | Shows the last time statistics were gathered for indexes of EMPLOYEES. |
| Update statistics in parallel for faster execution | EXEC DBMS_STATS.GATHER_TABLE_STATS('HR', 'EMPLOYEES', degree => 4); | Runs statistics gathering in parallel for faster performance (using 4 CPU threads). |
| Update statistics for specific columns | EXEC DBMS_STATS.GATHER_TABLE_STATS('HR', 'EMPLOYEES', columns => ('SALARY')); | Updates statistics only for the SALARY column. |
Best Practices:
✔ Use cascade => TRUE to update both table and indexes.
✔ Use degree => 4 for faster execution on large tables.
✔ Schedule statistics updates during off-peak hours.
Would you like a PL/SQL script to automate this for multiple tables? 😊
Enable OpenSSH on Windows 11
Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...
-
Action Full Command Description Update statistics for a specific table EXEC DBMS_STATS.GATHER_TABLE_STATS('HR', 'EMPLOYEES...
-
If the ALTER SYSTEM SUSPEND statement is entered on one system in an Oracle RAC configuration, then the internal locking mechanisms propagat...
