I have tried to understand through oracle docs but could not get it properly Any body please explain.
What is difference between spfile and init.ora file?
Thanks.
init.ora
init.ora or the pfile(parameter file) is a simple text file which can be updated by a standard editor like vi
which contains the various initialization parameters used while starting a database instance.
Here is a sample init.ora file:
db_cache_size = 176000M
db_2k_cache_size = 2048M
db_16k_cache_size = 99000M
db_keep_cache_size = 600000M
db_recycle_cache_size = 64000M
shared_pool_size = 14000M
We need to restart the database after editing the init.ora using a text editor so that the changes can come into effect.
If we want to start a remote db we need a local pfile.
RMAN(Recovery manager) which helps in data backup recovery process does not keep the backup of pfile or init.ora file.
spfile
The Oracle spfile is a binary representation of the text based init.ora file or pfile( parameter file) which contains the various initialization
parameters used while starting a database instance.Came into existence in and after Oracle 9i.
We do not edit this file using an editor as it is a binary file and may get corrupted and which may lead to your database instance not starting rather
it is altered by using the alter system query.
An example of editing a spfile :
ALTER SYSTEM SET open_cursors=300 SCOPE=SPFILE;
The changes come into effect after running the Alter system query and we do not need to restart the database.
We do not need a local copy in case of spfile if we need to start a remote database.
As this file is maintained by the server the parameters are validated before they are accepted.
RMAN keeps the backup of spfile.
By default our database uses pfile to start we can change that and create a spfile from a pfile or init.ora file by using the following query and we don't even need to restart the db.
sqlplus / as sydba;
CREATE SPFILE FROM PFILE='/u01/oracle/dbs/init.ora;
The difference between init.ora and spfile.
init.ora and spfile both contains Database parameters info. With
spfile you can set Oracle database settings with the ALTER SYSTEM
command that is used in sqlplus to add/Modify/delete settings.
However for init.ora you edit it as a text file because init.ora
saved in the format of ASCII.
init.ora info is read by oracle engine at the time of database
instance . in spfile modifications can applicable without restarting
oracle database.
When an Oracle database is started, the process will always use
spfile.ora, if it exists. If the spfile.ora is not found, the
init.ora would be used on startup.
Related
I have a database with lot of data which is used for my web application. For some reason I want to change the database name (phycially, .mdf and .log files).
How to do that?
You can use the command Rename-DbaDatabase that's present in dbatools.
Rename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName HR2
This is quoted from the command's help:
The process is as follows (it follows the hierarchy of the entities):
database name is changed (optionally, forcing users out)
filegroup name(s) are changed accordingly
logical name(s) are changed accordingly
physical file(s) are changed accordingly
if Move is specified, the database will be taken offline and the move will initiate, then it will be taken online
if Move is not specified, the database remains online (unless SetOffline), and you are in charge of moving files
If any of the above fails, the process stops.
Please take a backup of your databases BEFORE using this, and remember to backup AFTER (also a FULL backup of master)
For more information about the command you can look it up here.
My question is about the following, it is required to pass a database of Oracle Database 10g Express Edition to 11g. I was given the backup on a pendrive, it is a file with extension .dmp (Dump file).
I installed the 11g Express Edition on a new server but also installed the database that comes with this (XE).
I want to restore the database from the 10g to another unit other than C, which is where the Oracle 11g database is installed. I also want this new database to "replace" the XE (I do not know if it is the correct way to say it).
I have only found adjustments and location changes but only within the same unit.
Any scope would be very useful.
Thank you.
Judging from the comments, it sounds like you have been given a Database Dump file (.dmp) from a database on a pendrive, and you need to figure out how to get that file into a database, correct?
First, let's go over some background. What is a dump file (.dmp)? From Oracle:
The dump file set is made up of one or more disk files that contain
table data, database object metadata, and control information. The
files are written in a proprietary, binary format. During an import
operation, the Data Pump Import utility uses these files to locate
each database object in the dump file set.
At a high level, that .dmp file is a collection of DDL and DML statements that will recreate whatever data and objects that were exported. .dmp files make it easier to transport and move large amounts of data between databases using Data Pump. But what is Data Pump? Again, from Oracle:
Oracle Data Pump technology enables very high-speed movement of data and metadata from one database to another.
Basically, Data Pump is a set of utilities (EXPDP & IMPDP) that are used to move data between databases. The .dmp file you have was likely created using EXPDP. You will need to use IMPDP to import that .dmp file into a database.
Here's were it gets interesting - you say that you already have an 11g database, correct? If you want to, you should be able to import the 10g dump file directly into your 11g database without any issues. The reason is that Oracle tends to be backwards compatible, and typically speaking, anything that you do with one version of Oracle will be compatible with the version that immediately succeeds it. Jumping from something like Oracle 8i to 11g won't work, but you can always go from 8i to 9i, from 9i to 10g, and so on.
If you want to import that dump file into your 11g database, here's what you'll need to do:
Create a DBA account, or have an account that has been granted Data Pump privileges explicitly.
Move the .dmp file to the server where your 11g database lives. If you want to make it even easier for yourself, you can move the .dmp file to your database's datapump directory. If you don't know where that is, execute the following query on your database: select * from all_directories where directory_name = 'DATA_PUMP_DIR'; This query will return a directory. You don't have to use this directory, it will just make it easier.
Once you have the dump file in place and you have all of the necessary database and operating system privileges, you are ready to import the dmp file. Open a new command line window, set your Oracle home if it is not already set, and then navigate to the directory where you placed the .dmp file. Your import command will look something like this:
impdp [USERNAME]/[PASSWORD]#[DATABASE] directory=[DIRECTORY] dumpfile=[FILENAME].dmp logfile=[LOGFILE].log
Where [USERNAME]/[PASSWORD] are your credentials, [DATABASE] is the name of the database you're importing the dump file into, [DIRECTORY] is whatever directory you placed the dump file in, [FILENAME] is the name of the .dmp file, and [LOGFILE] is whatever name you chose for your log file.
Assuming your database has everything necessary for the .dmp file, the import should begin and you will start seeing status updates that look similar to this:
Starting [USERNAME]."SYS_IMPORT_FULL_01": [USERNAME]/******** directory=DATA_PUMP_DIR dumpfile=[FILENAME].dmp logfile=[LOGFILE].log
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Note that this is just an example, your results may look different. Assuming all goes well, you will see a message like this at the end:
Job [USERNAME]."SYS_IMPORT_FULL_01" completed
If you don't want to import it into your existing 11g database, you could always spin up a new database and import the .dmp file to that one using these same guidelines.
That should be enough to get you started down the right path, hope this helps and good luck!
P.S. Here is a great FAQ on the Data Pump utilities as well: http://www.orafaq.com/wiki/Import_Export_FAQ
I have a series of repetitive tasks here at work. One of these is the creation of new database from a template.
To achieve this we have a *master_db* database that act like a template and its location is something like C:\Backup\master_db.bak.
After the creation of a new database new_db, right-click on it and go through Task->Restore->Database. In the General tab I choose From device and then I set C:\Backup\master_db.bak as restoring source. In the Options tab I'll choose Overwrite existing database and I also need to change .mdf and .log file (currently C:\SQLData\master_db.mdf and C:\SQLData\master_db_log.ldf in C:\SQLData\new_db.mdf and C:\SQLData\new_db_log.ldf).
This iter is in working order but for automation sake I need to do this step through code. What should I do? What parameters needs my RESTORE command? What command should I use to properly set .mdf and .ldf files?
restore database new_db from disk = 'C:\Backup\master_db.bak'
with
move '<data_file>' to 'C:\SQLData\new_db.mdf',
move '<log_file>' to 'C:\SQLData\new_db_log.ldf',
replace
You need to update <data_file> and <log_file> with the logical file names for these files. You should be able to see them in the GUI.
I have created a SQLite database from Java. Now I want to know where it is stored physically on disk, so that I can push that file on to Android.
You specified a database name as part of the JDBC connection URL. Look for a file with that name on your harddisk. Example:
jdbc:sqlite:test.db
-> look for test.db
SQLite usually produces one file with the extension .sqlite, but this is just convention, the extension can be anything.
As already was said, the code which opens the database spefifies the path where the file should be stored, so you have to look there.
I'm trying to create a MS Sql Server database on a database instance running on a remote machine. When I'm doing so I need to be able to specify the path to the database (.mdf) file. If I try to create a database in a folder which doesn't exist, SQL Server will just fail (wouldn't it be nice if it created the folder structure automatically).
Is there any way that I can create the folder path on the target machine in SQL before I try to create the database, or at least to determine what the default folder is for new databases in which I could safely create the new database file?
If you have appropriate permissions, and xp_cmdshell is enabled, you can:
EXEC xp_cmdshell 'md "<path>"';
--...repeat for each node in the path
If cmdshell is disabled, again assuming appropriate permissions, you can enable it temporarily using sp_configure:
Ancient article removed
Don't forget to set it back!
Otherwise why can't you let the engine place the database files in their default location? If you are using a drive other than C:, you'll also need to verify that the drive you specify even exists, and shouldn't you check with the user that it is okay for you to put these files elsewhere? If you choose some arbitrary location they might not know to check there for active SQL Server files.
You can check the default path by using xp_regread (undocumented, unsupported)... these are in the registry as keys DefaultDataDir and DefaultLogDir for the default instance under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer
If it's not the default instance, check this article:
http://foxtricks.blogspot.com/2009/06/how-to-determine-default-database-path.html
Are you doing this just so that you can name your MDF/LDF files the way you want to, instead of dbname-data, dbname-log? If so, why? Have you written scripts that depend on the physical name of the file? Really curious as to the motivation behind this.