How to export data from SQL Server to PostgreSQL? - postgresql

I need to export all tables from SQL Server to PostgreSQL.
Try: I tried from SQL Server IDE but at some stage its giving the error about data types are different.
Question:How can I do export of data from SQL Server to PostgreSQL? Is COPY does my job? If yes, then how can I export all tables including records?

You can't export data from MSsql then import to PostgreSql because it is not same syntax, data type, but you can use tool to migration data from mssql to postgreSql,
See more in topic
migrate data from MS SQL to PostgreSQL?

Use https://dbeaver.io/
Create MS SQL and PostgreSQL database connections (login)
Create target tables in PostgreSQL (same structures in MS SQL)
F5 to see new tables
Right-click on new tables -> 'Import Data' -> You will see 'Data Transfer' window
Choose 'Table' type then click 'Next' -> You will see 'Select input object', where you can choose tables from MS SQL connection
Just 'next' and check settings that you need, done :D

First export the schema into a file and run it against PostgreSQL until you've removed all incompatibilities.
You could try to do the same with the data you want to export but you may be better off writing a Python script to migrate it.

There is an absolutely simple way using built-in SSIS tool using Management Studio. You can find the detailed answer here.

Use https://dbeaver.io/ , as An Le mentioned.
After 40 years of DB development, migrating DB data is still a challenge. DBeaver is a free tool to use for data migration. But you still have to migrate the schema.
Exporting data from DBeaver
From contextual menu of your SQLServer database or schema select Tools > Create new Task > Common > Data Export
You will generate SQL insert files or CSV files. For migration between database types use CSV files.
Cons of SQL Server Migration Tool
Unable to migrate rows containing booleans.
Export ended up in errors of migrationg data with Bool columns, complaining that value is not boolean, although both source and destination columns where of boolean type.
Unable to continue with the next tables afer one table migration fails.
SQL Server - A single error stops all migration even for tables that are not related to the initial error.
Configuring the tool over and over again, trying to export your data is a waste of time. SQL Server migration task does not save the configuration of the source and destination connections. And the wizard is not user friendly, spending your time on it is frustrating. I assume the migration project was abandoned for at least 10 years.

Related

How do i dump data from an Oracle Database without access to the database's file system

I am trying to dump the schema and data from an existing Oracle DB and import it into another Oracle DB.
I have tried using the "Export Wizard" provided by sqldeveloper.
I found answers using Oracle Data Pump, however i do not have access to the filesystem of the DB server.
I expect to get a file that i can copy and import into another DB
Without Data Pump, you have to make some concessions.
The biggest concession is you're going to ask a Client application, running somewhere on your network, to deal with a potentially HUGE amount of data/IO.
Withing reasonable limits, you can use the Tools > Database Export wizard to build a series of SQLPlus style scripts, both DDL (CREATEs) and DATA (INSERTs).
Once you have those scripts, you can use SQLPlus, SQLcl, or SQL Developer to run them on your new/target database.

export data from database in liquibase format

is it possible to export data in liquibase format from already exist postgresql database? until today i each time when i run my project in groovy grails i was using bootstrap file where i was generating everything to database. to export schemas i used grails dbm-generate-changelog and works fine. i used configure tutorial from http://grails-plugins.github.io/grails-database-migration/2.0.x/index.html
best regard!!! :-)
You can use a regular SQL Dump from your DB in the liquibase migrations with minor effort:
Create your SQL file and put it under grails-app/migrations. E.g.
grails-app/migrations/2016-03-17-002-activiti-5.19.0.2.mysql.create.engine.sql
Add that file to your changelog.groovy
Add the following preamble to the SQL file
--liquibase formatted sql
Separate your SQL file into sections you want to see as changesets (add at least one at the beginning):
--changeset activiti:5.19.0.2-create-engine
See the docs: http://www.liquibase.org/documentation/sql_format.html

Linking Access tables into a PostgreSQL Database using a foreign data wrapper

I'm new to postgres so this problem is probably a relatively easy one for someone else. However, I have spent many frustrating hours trying to figure out the solution. I have an Access Database of metadata that must be kept updated for sending records to other groups. I also have a database using PostgreSQL and PGAdmin which also has these same metadata tables. Currently these tables in the Postgres database get updated manually by exporting the Access tables as excel files, and then importing them into the SQL tables. It's not the most efficient process and could lead to errors in the SQL database if someone forgets to check before running any queries that they are using the most recent data from Access. So I would like to integrate some of the tables from my Access database with my Postgres database.
Originally I tried just installing drivers to export the Access tables directly to Postgres which worked, but not in the way that I wanted since it just brings in a table which I would still need to manually update. From my understanding, I can create a server connection in postgres to access and that would then bring in updated data using a foreign data wrapper.
I tried to use ogr_fdw.
CREATE EXTENSION ogr_fdw;
When I try:
CREATE SERVER metadata
FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
datasource 'H:\Databases\20170712.accdb',
format 'ODBC' );
I receive: ERROR: unable to connect to data source "H:\Databases\20170712.accdb"
SQL state: HV00D
When I try:
CREATE SERVER metadata
FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
datasource 'H:\Databases\20170712.accdb',
format 'ACCDB' );
I receive: ERROR: unable to find format "ADDCB"
HINT: See the formats list at http://www.gdal.org/ogr_formats.html.
I also tried MDB and received the same error. However, MDB is the code name given by the website but it says that it needs JDK/JRE to compile and I'm not really sure if that's another type of driver that I would need or what it is.
When I try:
CREATE SERVER metadata
FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
datasource 'H:\Databases\20170712.mdb',
format 'ODBC' );
I receive: ERROR: unable to connect to data source "H:\Databases\20170712.mdb"
SQL state: HV00D
Hint: Unable to initialize ODBC connection to DSN for DRIVER=Microsoft Access Driver (*.mdb);DBQ=H:\Databases\20170712.mdb,
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
However I thought after looking at the github help page for ogr_fdw didn't need ODBC and special drivers https://github.com/pramsey/pgsql-ogr-fdw/blob/master/FAQ.md.
A lot of this is probably due to my limited knowledge of the terminology when I'm reading through a lot of this stuff. Also my Access database is an .accdb file but since that wasn't working I tried around with mdb and ODBC as the "format" too. If anyone has any suggestions I would greatly appreciate it.
Thanks!

I am in need of connecting to DB2 AS/400 database from Oracle Apex.

Is there any feasibility from Oracle to have a connection established to DB2 database so that I can query on DB2 database and generate reports from Oracle Apex?
OR
Is it possible to create a View in Oracle from a remote DB2 database?
OR
What options do i have in order to develop reports in Oracle Apex from the data i have in DB2 database?
(I know, this is an old question and you've already found a workaround. Anyway,) the keyword you might be interested in is gateway. This is Oracle 10g Database Gateway for DB2/400 Installation and User's Guide. I don't know which database you use, but - if 10g is not the one, I hope you'll manage to find the right documentation.
Shortly: after installing the gateway between Oracle and DB2, you'd create a database link. Then, in your Oracle schema, create a view that selects data over that database link from DB2 database. Finally, fetch data in Apex from the view.
As i didn't find a way to directly connect to DB2 from Oracle PL/SQL, i used a work-around. As this is a reporting tool, we are ok to have this tool running with the data which is 1 day off, we did the following:
1) Extract the data required from DB2 database to CSV files. We used a DB2 command which can be run at command line to extract the data into a CSV
2) Then we imported the data into Oracle tables using sqlldr

How to create a graphical schema for Postgres database?

I have got a sql file where is configured a database in PostgreSQL technology. I created a database from sql file but from code it is hard to understand action/connecting between the tables. Is it some tool which show all the connections between tables for PostgreSQL?
pgDesigner
Data Architect
Datastudio
DbDesigner fork
DbSchema
dbwrench
DeZign for Database
Please take a look to this list of tools.