In SQL*plus i can't open the databse which is already created in my computer....
the error it shows that "the database is not yet open"
and i want to know that in what command is suitable to open database.
I assume you're getting an error such as ORA-01219: database not open: queries allowed on fixed tables/views only. In that case, the fix is to connect as SYS and execute ALTER DATABASE OPEN:
C:\Users\Luke>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sun Mar 17 10:31:40 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> select count(*) from user_tables;
select count(*) from user_tables
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> alter database open;
Database altered.
SQL> select count(*) from user_tables;
COUNT(*)
----------
935
If you get an error ORA-01507: database not mounted when you run ALTER DATABASE OPEN, run ALTER DATABASE MOUNT before ALTER DATABASE OPEN.
There might a reason why the database isn't open and/or mounted. Perhaps it failed to open? In that case, ALTER DATABASE OPEN is likely to result in an error other than ORA-01507. If so, the folks on https://dba.stackexchange.com/ should be able to help you.
Related
Is there a way to remove a SQL Server Managed Backup entry entirely? (Using Microsoft SQL Server 2017 Enterprise Edition)
We have a database that was renamed (the database name, not the files). Managed Backup configuration was setup again against the new database name. We now have two entries for the same db_guid that show up when we execute:
select * from managed_backup.fn_backup_db_config (null)
db_name
db_guid
...
is_managed_backup_enabled
DB1
e3ff68..
1
DB2
e3ff68..
1
In this example DB1 and DB2 are the same database, DB1 was renamed to DB2.
Now trying to disable the backup for DB1 using:
EXEC msdb.managed_backup.sp_backup_config_basic
#enable_backup = 0,
#database_name = 'DB1'
We get the error: SQL Server Managed Backup to Microsoft Azure cannot configure the database, 'DB1', because it either does not exist or is offline.
We tried creating a new database called DB1, configuring the managed backup to disable the backups, but that's only exacerbated the problem. We now have a new entry in the managed databases with a different db_guid:
db_name
db_guid
...
is_managed_backup_enabled
DB1
e3ff68..
1
DB2
e3ff68..
1
DB1
8ee1ca..
1
Upon dropping the 'new' DB1, it's disappeared from the managed backup.
How do I remove the old duplicate DB1 entry though (without dropping the database which we don't want to do).
delete d
FROM msdb.[dbo].[autoadmin_managed_databases] d
where d.drop_date is not null
I'm using Oracle express edition. Whenever I use the savepoint statement, I get an invalid statement error. Is it not valid in Oracle express edition. I'm using the latest version. I also faced the same problem when I was using the desktops in my university. I don't know what's wrong with it. I'll be so happy with your help. Many thanks.
Edit:
My code:
savepoint s;
The error that I'm getting
ORA-00911: invalid character
ROLLBACK to SAVEPOINT is supported by the free Oracle Database Express Edition.
Tested with the 18c release: https://www.oracle.com/database/technologies/appdev/xe.html
Limitations of this version are listed here: https://docs.oracle.com/en/database/oracle/oracle-database/18/xelic/licensing-information.html#GUID-0F2574A6-360F-4237-8098-17B02FFC3BB3
Your error "00911: invalid character" is related to the way you invoke the "SAVEPOINT S;" command...
For instance in Java, you would need to get rid of the ";" character to make it work:
[...]
Statement s = c.createStatement();
ResultSet r = s.execute( "SAVEPOINT S" ); // "SAVEPOINT S;" will produce ORA-00911
[...]
Just to answer the title question: yes.
SQL> select * From v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for 64-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> savepoint a;
Savepoint created.
SQL> delete from emp;
14 rows deleted.
SQL> rollback to a;
Rollback complete.
SQL>
I have developed an Oracle pro*C/C++ library that provides an API to other applications to read data from database tables and insert/update data in the tables. Recently a customer reported that the API did not return any error when underlying file systems (ASM) that hold tables spaces went down for a few days! This must be due to caching data by Oracle instance.
My question is this: Can we make Oracle return error, without affecting its caching scheme, for any read/write access to a table immediately after its table space is found to be not accessible due to corruption or any disk related errors?
I did a small experiment to simulate the customer's problem. I have created a new directory on my Linux system. Created a table space in it and created a table to use the table space. Inserted a few rows using sqlplus and fetched rows from the table and verified results. They are OK. Then I renamed table space file to some other file to simulate missing/corruption of the table space. Oracle still returned rows even though physical table space was missing. I could even insert a few rows successfully and commit went through without any error(probably this may fail for large number of inserts). However, I could not shut down the database instance. Once I aborted the instance, start up failed with an error saying the table space could not be identified/locked. After that sqlplus could not connect to the database. But my requirement is to get an error for any DML operation if the table space file found to be missing or corrupted.
Following is my experiment:
Created a directory for a new tablespace
[root#mvsLTOraLin u01]# mkdir /orats
[root#mvsLTOraLin u01]# chown oracle /orats
[root#mvsLTOraLin u01]# chgrp oinstall /orats
Created a table space using sysdba user as following:
SQL> create tablespace orats datafile '/orats/ots1.dbf' size 5M;
Tablespace created.
[root#mvsLTOraLin orats]# pwd
/orats
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 ots1.dbf
Created a table in the table space using fis_admin user and inserted 3 rows:
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 17:56:50 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table tbl1(c1 int not null primary key, c2 varchar2(100)) tablespace orats;
Table created.
SQL> insert into tbl1 values(1, 'one');
1 row created.
SQL> insert into tbl1 values(2, 'two');
1 row created.
SQL> insert into tbl1 values(3, 'three');
1 row created.
SQL> select * from tbl1;
C1
----------
C2
--------------------------------------------------------------------------------
1
one
2
two
3
three
Renamed table space file from ots1.dbf to gone.dbf to simulate corruption of the table space.
[root#mvsLTOraLin orats]# date
Sat Jul 11 18:03:00 IST 2015
[root#mvsLTOraLin orats]# mv ots1.dbf gone.dbf
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 gone.dbf
Selected data from sqlplus which is still connected
SQL> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.05.20.525276 PM +05:30
2
11-JUL-15 06.05.20.525276 PM +05:30
3
11-JUL-15 06.05.20.525276 PM +05:30
Retrieved data even though table-space disappeared.
This shows Oracle is returning from its cache.
Restarted sqlplus and queried. Still server did not realise that its table space is missing!
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-4.1$
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:07:24 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.07.42.014083 PM +05:30
2
11-JUL-15 06.07.42.014083 PM +05:30
3
11-JUL-15 06.07.42.014083 PM +05:30
Tried to shutdown the instance
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:08:42 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL>
It failed as expected.
Tried to insert a row.
SQL> insert into tbl1 values(4, 'four');
1 row created.
Surprise! The insert was successful. It must may fail for many inserts.
Forced shutdown
SQL> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown immediate
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> quit
Restarted instance
SQL> startup;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 742395736 bytes
Database Buffers 318767104 bytes
Redo Buffers 5554176 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/orats/ots1.dbf'
Error is shown as expected.
Tried access to tbl1:
SQL> select c1, current_timestamp from tbl1;
select c1, current_timestamp from tbl1
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
Failed as expected.
So, is there a way to make Oracle return error on next access to the table for reading or writing even though data may be returned from cache?
Ours is a SQL Server (2008-R2) - Windows Forms based application. We have a backup/restore utility provided with our software which performs some logical checks before restoring a backup to ensure that the backup is functionally valid.
However, our clients often use the SQL Server Enterprise Manager utility to:
Restore backups or
Attach data files (kept aside before formatting) directly.
This type of action bypasses all our functional checks and allows the user to restore an invalid backup.
We want to detect that a database was restored/attached and may be we will stop the software from loading if such a thing happened. We think that this information (attach/restore) should be available within some table of SQL Server itself but don't know the right location/query.
If any change is required in our software to achieve the above, we are ready to do the same too, e.g. may be we need to store some data at some point of time to make the detection happen, please advise.
So, how can we detect that
A database backup was restored using SQL Server Management Utility
(Note: MSDB.Restorehistory may not be a good option as we have often found this table blank for unknown reasons even after backup was restored and just in case user restores the MSDB from MSDB backup or MSDB template due to a data corruption, may be due to abnormal shutdown of system, then the RestoreHistory table data is gone)
A database was created by attaching a data/log file using SQL Server Management Utility
Any help in this regard is highly appreciated.
Rajarshi
Method 1:
You can use SQL Server Audit (Security\Server Audit Specification), and add Backup-Restore_Group option to it in order to log all backup and restore in your server.
You can also read audited data with following query:
SELECT *
FROM sys.fn_get_audit_file('Your Audit File Path',DEFAULT, DEFAULT)
this feature is in SQL Server 20088 R2 and above version and not exists in SQL Server 2008.
Method 2:
You can use SQL server error log in order to get backup and restore history:
In order to get backup log of your database:
EXEC sys.sp_readerrorlog #p1 = 0, -- int
#p2 = 1, -- int
#p3 = N'Database backed up. Database: Attach', -- nvarchar(4000)
#p4 = N'' -- nvarchar(4000)
In order to get restore log of your database:
EXEC sys.sp_readerrorlog #p1 = 0, -- int
#p2 = 1, -- int
#p3 = N'Database was restored: Database: Attach, -- nvarchar(4000)
#p4 = N'' -- nvarchar(4000)
you can use this method on SQL Server Express 2008-R2 edition.
When trying to connect to an ORACLE user via TOAD (Quest Software) or any other means (Oracle Enterprise Manager) I get this error:
ORA-011033: ORACLE initialization or shutdown in progress
After some googling, I found the advice to do the following, and it worked:
SQL> startup mount
ORACLE Instance started
SQL> recover database
Media recovery complete
SQL> alter database open;
Database altered
Here is my solution to this issue:
SQL> Startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> Show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string C:\APP\USER\ORADATA\ORACLEDB\C
ONTROL01.CTL, C:\APP\USER\FAST
_RECOVERY_AREA\ORACLEDB\CONTRO
L02.CTL
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT'
2
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT';
MEMBER
--------------------------------------------------------------------------------
GROUP# STATUS
---------- ----------------
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
3 CURRENT
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 4234808 generated at 01/21/2014 18:31:05 needed for thread 1
ORA-00289: suggestion :
C:\APP\USER\FAST_RECOVERY_AREA\ORACLEDB\ARCHIVELOG\2014_01_22\O1_MF_1_108_%U_.AR
C
ORA-00280: change 4234808 for thread 1 is in sequence #108
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
And it worked:
I had a similar problem when I had installed the 12c database as per Oracle's tutorial . The instruction instructs reader to create a PLUGGABLE DATABASE (pdb).
The problem
sqlplus hr/hr#pdborcl would result in ORACLE initialization or shutdown in progress.
The solution
Login as SYSDBA to the dabase :
sqlplus SYS/Oracle_1#pdborcl AS SYSDBA
Alter database:
alter pluggable database pdborcl open read write;
Login again:
sqlplus hr/hr#pdborcl
That worked for me
Some documentation here
This error can also occur in the normal situation when a database is starting or stopping. Normally on startup you can wait until the startup completes, then connect as usual. If the error persists, the service (on a Windows box) may be started without the database being started. This may be due to startup issues, or because the service is not configured to automatically start the database. In this case you will have to connect as sysdba and physically start the database using the "startup" command.
I used a combination of the answers from rohancragg, Mukul Goel, and NullSoulException from above. However I had an additional error:
ORA-01157: cannot identify/lock data file string - see DBWR trace file
To which I found the answer here: http://nimishgarg.blogspot.com/2014/01/ora-01157-cannot-identifylock-data-file.html
Incase the above post gets deleted I am including the commands here as well.
C:\>sqlplus sys/sys as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 30 19:07:16 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 778387456 bytes
Fixed Size 1384856 bytes
Variable Size 520097384 bytes
Database Buffers 251658240 bytes
Redo Buffers 5246976 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 11 – see DBWR trace file
ORA-01110: data file 16: 'E:\oracle\app\nimish.garg\oradata\orcl\test_ts.dbf'
SQL> select NAME from v$datafile where file#=16;
NAME
--------------------------------------------------------------------------------
E:\ORACLE\APP\NIMISH.GARG\ORADATA\ORCL\TEST_TS.DBF
SQL> alter database datafile 16 OFFLINE DROP;
Database altered.
SQL> alter database open;
Database altered.
Thanks everyone you saved my day!
Fissh
The issue can also be due to lack of hard drive space. The installation will succeed but on startup, oracle won't be able to create the required files and will fail with the same above error message.
I hope this will help somebody, I solved the problem like this
There was a problem because the database was not open.
Command startup opens the database.
This you can solve with command alter database open
in some case with alter database open resetlogs
$ sqlplus / sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 624952632 bytes
Database Buffers 436207616 bytes
Redo Buffers 3952640 bytes
Database mounted.
Database opened.
SQL> conn user/pass123
Connected.
I faced the same problem. I restarted the oracle service for that DB instance and the error is gone.
What worked for me is that i hadn't set the local_listener, to see if the local listener is set login to sqlplus / as sysdba, make sure the database is open and run the following command
show parameter local_listener, if the value is empty, then you will have to set the local_listener with the following SQL command ALTER SYSTEM SET LOCAL_LISTENER='<LISTENER_NAME_GOES_HERE>'