Primary data file extension showing as bak - sql-server

In one of my production environment the data file extension for a database showing some crazy extension.
Normally for a database files mdf is for data and ldf for log. But in my case instead of mdf it is showing as bak.
As per my understanding bak extension is for backup file. So how it comes as a data file extension and how it is working.
It will cause any database corruption. How I can resolve this one ?

The name of the file is actually irrelevant. As long as it is properly mapped in the metadata then it will cause no issues.
The MDF, NDF, LDF, BAK extensions are all just a convenience to quickly identify the file type without querying.
If it bothers you, you could change it (https://www.mssqltips.com/sqlservertip/4419/renaming-physical-database-file-names-for-a-sql-server-database/).

Related

Copy Multiple DBF files content to other DBF files

I have 200 DBF files (related to Windows program) that I need to transfer their content to different DBF files that have the same names.. , i.e. file1.dbf content should be transferred to file1.dbf content from different folder, I need to do that for all 200 files. I can only find manual solution but its slow , I need to do it for all at once. The reason I need to do that is because the files have some protection or I don't get it, if I simply replace them the program will give error realated to db, other easier solution is welcome.
What really happened -
The files are used in accounting software. I have created the backup with backup function from the software, it was done daily automatically. Restore function is protected for free version. I can only manually restore the files, but the backup files work only on the exact software version as protection. The thing is that the software is 100% free as long as you don't update it, I didn't knew that until I selected the update menu option. Now the software is updated but it asks me for license key which is very expensive. I have the backup files, but as the restore function is blocked I can't restore it with the program. I can only replace the files myself from the backup , its a directory that is backed up. The problem is that it has some protection on files itself , they are not recognized but only if I manually edit the files with DBF Manager software, if I open a default software file and paste the content from backup file it works, but I have many files.Now I'm stuck with company documents locked not been able to access it
Thank you

Lightroom database corrupted after recovery

I am trying to rebuild an Adobe Lightroom catalog file which is basically a SQLite database. In this case the file was accidently deleted and recovered using Disk Drill. When I use .dump to create an SQL file, I only get a very small file out of there original 5.5GB catalog file and it is useless. If I try to open the file in DB browser for SQLite it thinks it is encrypted and asks for a password. Any suggestions how I could fix that would be greatly appreciated.

SQL server Backups Files types

I am trying to read the content of my backup E.g.(testdb.bak) in a text format E.g.(Notepad or another text editor)
This command is retrieving only the file holds:
Restore HEADERONLY From disk = 'C:\backups\testdb.bak'
Is there any way or file extension, file type or format, where I can see the whole content of a backup? without restoring it.
Is there any way or file extension, file type or format, where I can see the whole content of a backup? without restoring it.
No there is no command in SQL Server which would let you see the content of .bak file. If you open it in notepad you would see some information and lots of garbage characters. This is also not supported
The best way to see its content is restore it on SQL Server database and run as many select statements you like on the tables.

Why do we need the LDF files along with MDF files?

What would happen if I delete the .ldf file that is in the same folder that my .mdf file?
The LDF file is the transaction log and is required for all SQL server configurations. Depending on the recovery mode, will determine how it is used. However all queries basically get stored here until successfully committed to the database (MDF).
You will not be able to delete it while SQL server service is running. You can detach the database, delete the log file (LDF) and reattach the data file (MDF). However it will just create a new log file. You really should not need to delete it. If it is getting too large you will need to manage it, typically through the backup process.
The database will be marked as suspect on SQL Server restart and inaccessible without some in depth fiddling to recover it.
The LDF is an essential part of the database: you need this file.
You can of course ignore us, and delete it and see for yourself...
As already pointed out, the .LDF file is crucial for the DB and the DB will not be available without one. The .LDF can be deleted only if the DB is offline, or detached or SQL Service is stopped.
Assuming that one of the above 3 scenario was true and you did delete the .LDF file, then the DB would be suspect when SQL server is restarted. If the DB was offline and you try to bring it back online, it will give you an error:
File activation failure. The physical file name "<<filename.ldf>>" may be incorrect.
Msg 945, Level 14, State 2, Line 1
Database '<<DB Name>>' cannot be opened due to inaccessible files or insufficient
memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
It is quite simple to fix this error, but you will need to delete all the Metadata pertaining to the DB from system files. The easiest way to do that would be to drop the DB. Here is what you will need to do.
Take the DB offline or detach the DB
Make a copy of the .MDF file to your backup directory
Now Drop the DB (You will have to reattach the DB, if you detached, of course)
Copy the .MDF back to the original location
After these steps, run the following:
SP_ATTACH_SINGLE_FILE_DB #dbname='<<DBName>>'
,#physname=N'<<filepath\filename.MDF>>'
This should return you the following:
File activation failure. The physical file name "<<Filepath\filename.ldf>>"
may be incorrect.
New log file '<<Filepath\filename.ldf>>' was created.
That would bring your DB back to an usable state.
The million $$$$ question still remains - why would anyone want to delete the .LDF file???
Raj
The best way to keep the size of .LDF file in check is:
to regularly take transaction log backups at least once a day or
change your recovery model from full to simple ( by default, its full)

H2 database: What is and why appears database.xx.log.db.corrupt binary file

I am extensively using H2 database for my project (lots of inserts and selects) and I have noticed that in the database directory appear binary files which have the name:
database.xx.log.db.corrupt, where xx - a number.
Does anybody know if there are possibility to understand what this file stands for and why it appears?
At most one file with this name may be created when the database is started, after a crash (power failure or killed process), if the file header of the transaction log file (database.xx.log.db) is corrupt. Usually the file can be ignored, it's just not deleted to that the crash can be investigated if necessary. It doesn't mean you have lost data. By the way the relevant source code is here: http://code.google.com/p/h2database/source/browse/branches/version-1.1.x/h2/src/main/org/h2/log/LogSystem.java#300
This means you are using H2 version 1.1.x. In the meantime (since version 1.2.x) H2 doesn't use separate transaction log files. Instead, the transaction log is integrated into the main database file. I suggest to upgrade to a more recent version of H2.

Resources