Remote Link between PostgreSQL and Oracle database - database

how to create a synonym for a table of a schema in postgresql database on a server into a schema of oracle database on another server?
I have a schema on oracle database on a server and want to create a synonym a table present in a schema of postgresql database on another server.
To create the synonym, we need to have database remote link between these two databases present on two different servers.
How can we do this? Please provide me one solution.

Just to clarify, I believe the question is trying to figure out how to get PostgreSQL data to appear as a table inside of Oracle. (The existing comments seem to be reading it the other way around, in which case, yes, an FDW would be the solution, but in this case that will not work).
In the past (on older versions of Oracle) when we needed this we were forced to build custom replication scripts to transfer data from Postgres into Oracle systems. For a single table, it is pretty straightforward to do with something like Perl & DBI... feel free to substitute that with your favorite scripting language.
On newer Oracle systems, I believe you can use Oracle Database Gateway to accomplish this. I am not sure if they support Postgres directly, but they do support ODBC (and I think JDBC) which should work. Here is an example blog post setting this up with MSSQL (http://oracle-help.com/oracle-database/installation-oracle-database-gateway/), the process should be similar for Postgres.
Hope this helps!

Related

SQLite schema based on SQL Server DB schema

I maintain a Windows based application backed by SQL Server DB so there is a set of SQL entities, like tables, views. With time I add new features and fix bugs so schema of the tables and views changes. Once I need to deploy a new version of the application I deploy the DB part by relying on DacPac/DacFx which automatically generates a difference between already deployed DB and the supplied DacPac so the already deployed DB is altered to match the DacPac's content. This way I don't have to write a code which compares 2 schemas and then generates a difference - DacFx does that for me.
That works well but now I need to expand the application so it also supports SQLite DB, I will for sure have to create a new application layer working with SQLite which is doable but one place I need help with is being able to create and maintain SQLite DB schema in the same way I do for SQL Server with DacPac/DacFx so a difference in schemas is computed and applied. While doing that I ideally want do write the SQL schema once so it could be applied to SQL Server as well as SQLite. Ideally, I need to generate SQLite schema based on the schema specific to SQL Server.
I looked into sqldiff which is capable of generating difference between 2 SQLIte DBs and thought I could:
use a technique from here to migrate SQL Server schema to SQLite
generate a temporary SQLite DB based on the generated above schema
compare the above deployed temporary DB to an existing SQLite DB by using the sqldiff and finally apply the difference to the target SQLite DB
but the sqldiff, as stated in the Limitations section:
The sqldiff utility is not designed to support schema migrations
In addition it has limitations around views:
The sqldiff.exe utility does not (currently) display differences in
TRIGGERs or VIEWs.
So I interpret that like that tool could probably be used for some migration cases but it is not really recommended.
How do you suggest generating and applying the schema differences?
I'm also interested to know how others solve the task of incrementally updating schema of their SQLite DB even if I take SQL Server completely out of equation and would instead maintain SQLite schema, in the source code, only. Does everyone create their own schema comparing tools instead of using something similar like DacFx in SQL Server world?

Keep two different databases synchronized

I'm modeling a new microservice architecture migrating some part of a monolithic software to microservices.
I'm adding a new PostgreSQL database and the idea is in the future use that database but for now I still need to keep updated the old SQL Server database and also synchronize the PostgreSQL database if something new appears in the old database.
I've searched for ETL tools but are meant to move data to a datawarehouse (that's not what I need). I just can't replicate the information because the DB model is not the same.
Basically I need a way to detect new rows inserted in the SQL Server database, transform that information and insert it in my PostgreSQL.
Any suggestions?
PostgreSQL's foreign data wrappers might be useful. My approach would be, to change the frontend to use PostgreSQL and let postgreSQL handle the split via it's various features (triggers, rules, ...)
Take a look at StreamSets Data Collector. It can detect changes in SQL Server and insert/update/delete to any DB that has a JDBC driver including Postgres. It is open source but you can buy support. You can also make field changes/additions/removals/renaming to the data stream so that the fields match the target table.

Entity Framework Oracle and Sql Server - how to build a database independent application

We are trying to build a data access layer for using both Oracle and SQL Server (not at the same time).
We use EF Model-first for creating the model and the create the SQL scripts for building the database. Our first thought was to create 2 EDMX files, one for each type, and use the appropriate one depending on the client's need. We are using the Oracle and SQL Server database generation workflow and DDL generation template to create the scripts for each database.
Our main problem is when the database schema changes we do not want to drop and recreate the DB but only create the migration scripts to update the DB base on our model (clients have many data that will be lost).
We use EF power pack for extracting the migration scripts for SQL Server but there is nothing like it for Oracle.
We want help to find a good data layer (1 EDMX for both Oracle and SQL Server if it's possible and not complicated) and a good way to generate database changes from our model to update existing client DBs in case of a new application release
We found this as a starting point
http://msdn.microsoft.com/en-us/data/ff830362 but there is not mention for Oracle support.
We have tried code-first and EF Migrations but Oracle failed us again on the DB creation and migration.
Any recommendation on how we can accomplish this?
Thank You
There is no way to have single EDMX for both SQL Server and Oracle. EDMX consists of three parts CSDL (entity definition), SSDL (database definition), MSL (mapping between those definitions). SSDL must always target concrete database so you need at least separate SSDL for Oracle and SQL Server and if you are lucky you will not need separate MSL as well (mapping must be exactly same which will probably not happen if you are using any tool to generate the database).
So you always need at least part of EDMX file for second DB and manually maintain it.
If you need DB migration supporting Oracle you must look for tool from Oracle (or third party). For example RedGate offers tools supporting schema migration for both SQL Server and Oracle.
Visual Studion Premium and Ultimate edition also offers tools for comparing database schemas. It by default supports only SQL Server but Toad Extensions should add support for Oracle as well.
Once you have any of these tools you just need to compare schema deployed on customer server with your new schema and the tool should create migration script for you.
The best article I found on this topic is from Paul Reynolds Blog.
Try to go through from part 5 to part 9.
There are so many gotchas about Oracle mentioned there... is very helpful!

Where does Oracle DBCA come in?

I'm planning to play around with Oracle Business Intelligence (for fun). I have access to a number of Oracle products, and may have gone overboard installing them all (quite possibly more than I need).
Problem is I'm not too sure how all the different Oracle components fit together, but I think I am still missing something, a crucial part - DBCA.
All the online help material I can find says use DBCA to create a database - but I don't seem to have DBCA anywhere.
What I do have installed is:
Oracle - OraClient11g_home1
Oracle - OraDb11g_home1
Oracle Business Intelligence
Oracle Weblogic
Does Oracle have a separate Database Server that is not included in the above? (Like MS SQL Server)
I'll note that I am completely new to Oracle and may be missing something very simple, so any help would be appreciated.
I'm looking for an answer that can lead me to how I can install DBCA and create my database but extra kudos for any additional brief information on how these Oracle building blocks work independently and together.
DBCA is the database configuration assistant. It is a wizard used to create a database and should be instaled during the server install. If you are testing you just want to create a database as part of the server insall and ignore dbca.
Oracle - OraDb11g_home1 is the database (most probably at least - given then Oracle naming conventions). DBCA was called as part of the installation process.
Note that a "database" in Oracle terms is something completely different than a "database" in MS SQL Server. A SQL Server "database" is closer to an Oracle schema.

Is it possible to create databases programmatically using DBX?

Looks like the TSQLConnection only connects to existing databases, and I could not find another component that allows me to send commands to the database server.
I'm using Delphi 2009 with Firebird and MSSQL.
One idea that came was to connect to a system database (master or tempdb in MSSQL for example) and then send create commands to the server. This could be an option for MSSQL, but I'm not sure for Firebird.
I'm also aware of the new DBX metadata in Delphi 2009, but I couldn't find a way to create databases using it. All examples I've found is to modify existing databases.
Yes, you can. dbExpress now includes a powerful set of meta-data classes for doing just that.
Steve Shaughnessy gives a good introduction here.
Erick if you use Devart drivers you can connect without the databasename parameter and send the t-sql create database command.
dbExpress included in Delphi uses a "least common denominator" strategy. Information like query statistics which is available through native drivers is invisible with dbExpress. (Maybe I should ask a question like "Which feature in alternative dbExpress implementations made you switch?")
You can execute "CREATE DATABASE ..." on both databases with standard TSQLQuery.
Note that syntax differes between these two. Since dbx is lightweight lib, this SQL and DB specific action probbably will never be fully supported. It leaves you with SQL.
With Delphi 2007/2009 comes DBX4. You may use the low level structures there to create database programmatically. Look in dbxcommons.pas
You can send a "CREATE DATABASE" script through any connection (ADO, OLEDB, ODBC, etc) opened on any server (or even ms-access files) as long as it follows the specific server DDL syntax.

Resources