Exporting database on oracle - database

I have a DB on oracle on Windows Server 2003. How do I export it with all the data and put it into other Windows server?

Use RMAN to take a full backup. Then restore it on the new server.
See Clone using RMAN Article

You can use Oracle Data Pump to export and import database. Quote from documentation:
Oracle Data Pump is a feature of Oracle Database 11g Release 2 that enables very fast bulk data and metadata movement between Oracle databases.
Procedure is like this:
Export existing database using expdp utility
Install Oracle database server on new Windows server
Import database on new server using impdp utility
Check this link: Oracle Data Pump. There you will find complete documentation and examples how to use this utility.

If you are wanting to create an exact copy of an existing database on a new sever of the same operating system (though not necessarily the same O/S version) and the same Oracle version, the quickest and least problematic method is to just copy the database files. This is often referred to as database cloning, and it is a common method DBAs use to setup development and test databases that are intended to be exact duplicates of production databases.
Stop all instances of the database on the existing system. You could login to each instance "as sysdba" using SQLPlus and run the "shutdown immediate" command. You could also stop the Windows Services for the instances. They are named OracleServicesid where "sid" is the instance name. Usually, there is just one instance, but there could be multiple instances to a single database. All instances must be stopped for this procedure.
Locate the database files. Look for an "oradata" folder somewhere below the Oracle root folder and then find the folder for the database sid in there. (There could be multiple oradata folders. You need to find the one that has the folder named for the SID of your database.) There are also the files in the Admin folder for the sid as well as the %ORACLE_HOME%/database folder. If DBCA had been used to create the database, then the location of all of these files varies by the Oracle version.
Once you have identified all of the files for the database, you can use any method at your disposal to copy these files to the same locations on the new server. (Note: The database files, control files, and redo logs must be placed in the same locations (i.e., file system paths) where they exist on the old server. Otherwise, configuration files must be changed and commands must be run to alter the database's internal file paths.) The parameter file (initSID.ora) and server parameter file (spfileSID.ora) must be placed in the %ORACLE_HOME%/database folder.
On the new sever, you must run the oradim utility. (Note: oradim is an Oracle utility that is specific to Windows and is used to create, maintain, and delete instance services.) Here is a sample command:
oradim -new -sid yourdbsid -startmode automatic
Startup the database with SQLPlus, and you should be in business.
This is a general overview of the process, but it should help you get the job done quickly and easily. The problem with other tools is the need to create an empty database on the target server before loading the data by whatever means. If the target server has a different version of Oracle, it will be necessary to run data dictionary scripts to upgrade or downgrade the database. (Note: A downgrade may not always be possible.) If the new server has a different O/S, then the above procedure would require additional steps that would significantly increase its complexity.
It also possible to duplicate a database using RMAN. Google the words "clone oracle database using rman" to get some good sites on how this is done using that tool. If you are not already using RMAN, the procedure I have described above would probably be the way to go.

Related

Duplicate localDB under SQL Servers on my laptop

I've been running into an issue recently when I attempt any tutorials that involve using a SQL database, entity framework, dapper, etc.
When it comes time to publish a database, or utilize an ORM, I'm given duplicate options for the same localdb under SQL Servers. Furthermore, then I attempt to publish, the database doesn't show up under the localdb that I've chosen.
I'm wondering how I go about removing the other SQL Servers and just having the one available.
If you look at the image below, the Browse option gives me two of the same LocalDbs. Plus I also get a 3rd one under \ProjectModels. I'm wondering what's causing this and how it can be fixed since no matter which one I choose, the sql database I attempt to publish doesn't show up within any of them.
My advice is not to use this method to publish the database. (right click to delete)
Please refer to this official documentation.
File-based databases like SQLite or SQL Server Express are designed to store their data in easily transferable files that can be served with your application/site.
"Copy to Output Directory" Property of the database file to "Copy if newer". Just point the address to it.
If you are using a server-based database like SQL Server, MySQL, etc., you need to make sure that the target machine/environment has the same database server installed, and you need to write a deployment script to append the pre-populated data files to the server. This might be troublesome for you.
You can also refer to these links. 1,2,3

I want to copy all the tables, it's data, views and SP's from one oracle DB to another.. I am using 12C. Softwares are DB viewer and SQL developer

I want to copy all the tables, it's data, views and SP's from one oracle DB to another.. I am using 12C. Software are DB viewer and SQL developer. Please note that I have tried twice on SQL developer but I am getting different errors.
There are utilities designed for such a purpose.
Use Data Pump Export (in the source database) and Data Pump Import (in the target database). Note that you should have access to an Oracle directory (database object, owned by SYS, who grants you read/write privileges on it so that you could store DMP file into a filesystem directory located on the database server). Normally, DBA does that (creates a directory and grants you privileges).
Alternatively, if you use the original EXP/IMP utilities, you can store the DMP file onto your own PC - which is (obviously) simpler. Oracle discourages us to use those utilities (since 11g).
Here are 12c Database Utilities; on the left hand side you'll see the menu; read about utilities I've just mentioned.

Repeatable Flyway Migration

How do I achieve repeateable migration of sql scripts to every database? I have a segment called API and this need to be deployed in all the existing databases in sql server.
Though I am able to repeatedly run/execute the set of scripts based on the naming convention, not able to run on every dbs.
As of now, I have a data-system.json file where all the dbs and segments are registered and I am using this to run the particular segment of a single db.
I'm not 100% on what you're asking, but in reference to the first part of your question:
How do I achieve repeateable migration of sql scripts to every database?
If you want to to run your Flyway scripts on multiple databases, you can use the 'migrate' command in the Flyway CLI to do that (https://flywaydb.org/documentation/command/migrate).
You can configure the environment specific info (e.g. login credentials) using environment variables (https://flywaydb.org/documentation/envvars).
Thanks

Embedded database on external drive

Have some application which uses SQL Server database on client server. Some time ago client requested to install application on external disk to be given someone else. My problem is somehow i have to attach database on external disk. Is it possible somehow to install sql server database on pendrive along with application? I heard something about sql compact. Can you update me on that topic?
I have not used SQL Compact but SQL Compact is suitable for in-proc, small, light-weight databases but has certain limitations as compared to SQL Express, no support for views, stored procedures, remote data access etc. You can find more at sql-express-v-localdb-v-sql-compact-edition
In a recent project, one of my clients had similar requirements and this is how achieved it with SQL Server Express.
As per my configuration I placed both the application and the database on the external disk. The database was placed in a subfolder named Database in the Bin folder. I declared my connection string as
Data Source=SERVER_NAME\SQLEXPRESS_INSTANCE;AttachDbFilename=DATABASE_FILE_NAME_WITH_FULL_PATH;Integrated Security=True;Connect Timeout=30;User Instance=True
As a quick solution SERVER_NAME\SQLEXPRESS_INSTANCE was configured and taken from App.Config but DATABASE_FILE_NAME_WITH_FULL_PATH was generated dynamically (external drive letters may change) using path constructs such as Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Database\ABC.MDF") etc. and inserted into the DataConnection string. So, whenever the application runs it searches for the ABC.MDF in Database subfolder of application executable path. You may need to tweak this approach as per your requirements such as Application.StartupPath / Application.ExecutablePath etc.
For more information and another example on AttachDbFilename check MSDN system.data.sqlclient.sqlconnectionstringbuilder.attachdbfilename

What do all these "Save DTS Package" options mean?

I'm creating a DTS package. After specifying the source, destination, and tables, I get the Save, schedule, and replicate package step, which has a Save DTS Package checkbox.
If I check the box to save, I get these options:
SQL Server
SQL Server Meta Data Services
Structured Storage File
Visual Basic File
Can anyone give a good explanation of what each option means, and the pros and cons of using it to save my DTS package? (Particularly if you have experience with the different options, and aren't just regurgitating something like this.)
These would be your primary options:
SQL Server means in tables in the msdb database
Structured Storage File means a .dts file
The file is portable and standalone. It can be run with dtsrun.exe and does not require a full install to run on an app server.
The msdb option means you need access to the msdb database but you gain backup/restore capability.
It depends on your setup and shop. I prefer the file option, but I'll use either as needed.
I would not use these:
Visual Basic File: once saved you can't edit it again, only run it (and I forgot how now)
SQL Server Meta Data Services: does it still apply?
Some more info on www.sqldts.com but it's not updated now. SSIS has mostly replaced DTS.

Resources