I have the following code to check if database is up and running and it works in most cases but sometimes I get an error
"ORA-01219: database not open: queries allowed on fixed tables/views only".
ps -ef|grep -v grep| grep $ORACLE_SID | grep ora_pmon > /dev/null
if (( $? == 0 )) # is the pmon process running zero is yes
#check if sqlplus is installed
if [ -f $ORACLE_HOME/bin/sqlplus ]
sqlplus -s "/ as sysdba" <<! >> $FILE1
set lines 132
set wrap off
select * from dba_data_files;
If I just run select name from v$database;, it returns the result without an issue but does not work on dba_data_files and other similar tables and views.
I also tried to manually loggin in to the database and ran
SQL> select * from dba_data_files;
select * from dba_data_files
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only.
The same issue also happens when checking a standby database in a Dataguard configuration.
But gotten the same result. Is there any way to check if database is open or if it is a standby database, using ksh script?