I've been receiving Oracle 01033 Initialization or shutdown in progress error when I try to log in to Oracle database using TOAD. When I try in SQLPlus I can connect to the database. I tried "alter database open" command and I got the following errors:
ORA-01122: database file 7 failed verification check
ORA-01110: data file 7: 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\STAJ.DBF'
ORA-01203: wrong incarnation of this file - wrong creation SCN
I looked up the answers for the same problem in stackoverflow but they did not help me.
Your database needs to be recovered. The file fails the verification checks and so the database won't open, hence the message in TOAD. SQLPlus works (locally at least) because you use that to start and stop the database, hence why you don't get the message when you use that otherwise you wouldn't be able to do anything. Get your DBA to perform a recovery (via RMAN or the method of their choice).
Related
I have a very large table script that is about ^ GB in size and cannot open in in Query Editor (obviously) due to memory/size.
I am trying to run it on the db server with the command propmt and using sqlcmd:
I am 100% sure the path and script name are correct (marked out for privacy reasons). I then used the following two scripts to get the DBServer\SQLInstance:
SELECT ##servername
SELECT ##servicename
What am I missing as it appears it has not done anything with the 21? _ prompt just sitting there. Do I need to do anything else?
I'm pretty sure the Windows command line pipeline is just choking on your previous command.
I think the best chance you have is doing this using PyPy:https://pypi.org/project/pymssql/, given the SQL instance has the memory to handle the data stream.
Well I am a college student and I have a database project to build on Oracle 19c (SQL Developer) just like a management system. When I click on new connection in SQl Developer , then enter database name (my project name) and enter user name as system and pswd. and is SID I write 'orclpdb' and when I connect it gives an error that database is not open. How can I start making tables and stuff and complete my project on oracle 19c sql developer. Please guide me.
Update: While creating new database connection in SQL Developer, In Service name if I write 'orcl' and test then the connection is successful but when I write 'orclpdb' it says 'database not open'
So it sound like the container database (orcl) is started but the pluggable database (orclpdb) is not. You need to start it.
In order to actually manage a database you are going to have to learn to work without SQL Developer, and use the command-line utility sqlplus.
From a command line:
C:> set ORACLE_SID=orcl
C:> sqlplus / as sysdba
SQL> alter pluggable database orclpdb open;
In the above, the sqlplus command is launching the command line utility 'sqlplus'. the '/' indicates to make a local connection to the database specified by the env variable ORACLE_SID, using OS authentication (os user is a member of the ORACLE_DBA group), and connect with 'sysdba' authority. On the next line the 'SQL>' is just indicating you are now at the sql prompt within sqlplus, you actually enter the 'alter' command, whose purpose should be self-evident.
The listener is a totally separate process. It is like a telephone switchboard. It 'listens' (hence, its name) for connection requests coming across the network, and set up the connection, then is out of the picture. You check its status at the command line:
C:> lsnrctl status
One last bit of useful (for us) information. What this the connection 'type' you've defined in SQL Dev? Is it 'basic' or 'tns'? Either way, what did you specify for the values? Please name the field(s) AND the value you supplied.
I'm trying to migrate databases from an old, dying server, to the new one.
All over the internet, I found two handy scripts by Andrew Morgan, for saving and restoring databases. The backup part works well; I get my db.bak on my local pc by sharing the folder over the network and having the script backup the db to the unc path.
Unfortunately, the restoring part won't work, and I don't know why (and my senior DEV doesn't know either, and he's the one knowing SQL aorund here).
I'm calling it this way:
Restore-SQLdatabase -SQLServer "NEWSERVER\MSSQLSERVER" -SQLDatabase "DBToMigrate" -Path "C:\Backup\DBToMigrate.bak" -SQLusername "sa" -SQLpassword "IMAPLAINTEXTPASSWORD"
sa has complete power over the database.
It fails with the following message:
Attempting to connect to the Specified SQL server: Success
WARNUNG: An Exception was caught while restoring the database!
WARNUNG: Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en): "Incorrect syntax near '‘'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon."
WARNUNG: attempting to recover the database
The part in question is:
ALTER DATABASE $SQLDatabase
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE $SQLDatabase
FROM DISK = '$path'
WITH REPLACE
When it gets executed, the scipt gets the exception.
I tried putting a CREATE DATABASE $SQLDatabase in front of the ALTER part, but then it says something along the lines of "that database name already exists", after creating that db.
Also, when omitting the altering part and changing that part to
RESTORE DATABASE $SQLDatabase FROM DISK = '$path' WITH REPLACE
It says something about the database files, giving me the path on the old server (which I'd like to be completely irrelevant, but it seems there may be my next problem), cannot be found (of course, since I'm on my local machine now, which doesn't have those).
I'm doing it with a script, because there are around 15 databases we need to migrate, and also because I want to learn how to do this stuff without just using the SSMS wizard.
Update: I changed the apostrophes to normal ones, that was indeed the mistake. Now I just need to get the file name of the db files so I can MOVE them to the new server.
All you need is to write a new destinations to your files, you can check the syntax of RESTORE here: RESTORE Statements (Transact-SQL)
And your code will be like this:
RESTORE DATABASE AdventureWorks2012
FROM AdventureWorksBackups
WITH MOVE 'AdventureWorks2012_Data' TO
'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\NewAdvWorks.mdf',
MOVE 'AdventureWorks2012_Log'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\NewAdvWorks.ldf';
My database file of SQL Server 2012 cannot be opened, it causes the following error.
Msg 824, Level 24, State 2, Line 1
SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:903; actual 0:0). It occurred during a read of page (1:903) in database ID 6 at offset 0x0000000070e000 in file 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\inventoryDB.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
I also checked it by using
DBCC CHECKDB(inventoryDB, REPAIR_ALLOW_DATA_LOSS)
But the result is given below
DBCC results for 'inventoryDB'.
CHECKDB found 0 allocation errors and 0 consistency errors in database 'inventoryDB'.
Is any possibilities to recover my data from that database file? I am also done many methods in many of the sites. But it not working and shows same error messages.
Do you have any mdf backup after this error occurred? If yes, you should try to create a table and restore from it using your backup.
Or try reading this article:
https://support.microsoft.com/en-ph/kb/2152734
See if it helps with your error.
You've got corruption in your DB. Either the DB was corrupt before you tried working it and you didn't notice, or it was damaged in the work.
Here. We have few options.
Solution one - If you have a backup file, You can restore your database.
Solution two - If you do not have a backup file, you can use DBCC CHECKDB to repair it. (Resource : https://www.stellarinfo.com/blog/how-to-repair-sql-database-using-dbcc-checkdb-command/)
Thanks :)
Can anyone help me how to restore a database from vb.net,I tried to restore using stored procedure by taking retore template script from sql server2005. but there is error "the database is already in use please use a master database.."
I assume you used the same connection string you usually use to connect to the database you are actually restoring.
From you error message, I'd say you should create your connection to the server with a different InitialCatalog parameter (the error message indicates you should use "master").
The other option is to stick a "USE master" at the beginning of the script. Here is a small description of the USE statement.
From the error it doesn't look like there is an actual VB.net programmatic error.
It seems like the problem lies on the database restoration stored procedure.
Before restoring database, make sure that
• Your connection is not using the database you are restoring - That is one of the possible reasons for that error, "the database is already in use please use a master database.."
• Other connections to the target database should be closed off - Close all connection to it.
Denis Troller has mentioned "USE master" and make sure that your script has that statement as the very "first" statement in your restore batch script.
I just wrote this in my project so I thought I'd share my method.
I'm calling the backup and restore by firing the SQL at the server using an SqlCommand.CommandText and setting the SqlParameters for database and filename as follows:
Simple backup:
BACKUP DATABASE #dbName
TO DISK=#fileName
WITH FORMAT
Then restore it using :
USE master
RESTORE DATABASE #dbName
FROM DISK = #fileName
There are plethora of options on the BACKUP and RESTORE commands but I just wanted a quick sledge-hammer approach and this works nicely.
Thanks to Denis for the 'USE master' tip, which just fixed my 'in use' error!