Is there any way join tables of MySql and PostgreSQL? - mysql

I have a table in MySql in one server and a table in PostgreSQL in another server.
I want use use JOIN operation with those tables.
Is there any way to join the columns?
If not, is there any way to print the rows in same order?
Please help!!

Use mysql_fdw to define the MySQL table as a foreign table in PostgreSQL. Then you can join it with the PostgreSQL table in PostgreSQL.

You can use Materialize to achieve this.
Here is a sample demo project that you can run to see this in action:
You can find the code for the demo project and how to run it on GitHub here:
https://github.com/bobbyiliev/materialize-tutorials/tree/main/mz-join-mysql-and-postgresql

Hope this reference helps.
Yes, it is possible to work with multiple databases at the same time but you're looking in the wrong place. psycopg2 is just a library that simplifies accessing and manipulating data coming out of PostgreSQL but it doesn't go far beyond what you can do with psql. What you're looking to do you can solve on the database level by using Foreign Data Wrappers.
This does become more complicated in your schema definition but brings remote tables from host some.other.server database remote_db to appear as though they live on localhost in database local_db....
More:
https://dba.stackexchange.com/a/120682/197899

Related

MySQL Update of Columns using INFORMATION_SCHEMA - is this possible?

I know that I can view the properties and do some amazing things to learn my db/table/field structure using INFORMATION_SCHEMA.
However, is it possible to update a field value in for example the COLUMNS table and thus update the actual column? For example setting nullable from NO to YES.
If this is not directly possible, I realize that I could use the query to CONCAT an ALTER string and then run those strings. However is there in that case a way to instead run an eval() command to do this in one operation? Thanks.
To learn INFORMATION_SCHEMA: I'd start from reading documentation - INFORMATION_SCHEMA Tables. Then I'd try to edit objects and see what happens in these tables.
INFORMATION_SCHEMA tables are system tables, they cannot be modified. ALTER TABLE is the only way to change a table.
It was a beautiful idea, but unfortunately, it won't work.
The tables in INFORMATION_SCHEMA are read-only views, and are not actually tables. So there aren't any files or directories associated with them. You can only read their contents and can't run INSERT, UPDATE, or DELETE operations on them.
See https://dev.mysql.com/doc/refman/5.7/en/information-schema-introduction.html#information-schema-usage-notes for the lowdown.
And FYI, there's a Database Administrators Stack Exchange site if you want more targeted answers to database questions.

Retrieve Comments from tables and columns in a Mysql database

i have to build an application to manage an existing MySQL database. This database was created with MySQLworkbench and some useful comments were added to its tables and columns.
I think it would be great to somehow, query that comments and show them to the user to explain "what that field is". The problem is i don't know if its possible to retrieve that comments (they are only visible from the workbench).
EDIT:
in the MySQL existing database i have to work with there is no INFORMATION_SCHEMA table. I think is something usual to find it but in my model there is no :S
Try with:
SELECT column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='table_name';
You can parse the output of
show create table `YOURTABLE`;

Importing records from PostgreSQL to MySQL

Was wondering if anyone had any insight or recommended tools for exporting the records from a PostgreSQL database and importing them into a MySQL database. I believe the table structure is 100% identical.
Thoughts? Thanks!
The command
pg_dump --data-only --column-inserts <database_name>
will generate SQL-standard-compliant INSERT statements with all column names listed and one VALUES clause per INSERT. This is the most portable way of moving data from PostgreSQL to any other SQL database.
Check out SquirrelSQL, it can pump data from one database brand into another via the DBCopy plugin. When the table structures are really identical it works quite well.
There is a ruby app called Taps that will do it. I've used it before with great success:
http://adam.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/

How can I make tables in MySQL?

I have two distinct scenarios.
One, where there is a many to many case, you must create a third table. But I'm not familiar with MySQL syntaxis.
Two, is this one:
How can I declare using SQL code?
In MYSQL my create tables using the CREATE TABLE command. If you don't feel too confident to write your tables with that syntax, I'd suggest using a tool like the MySQL Workbench. That tool can greatly help you there.
You need to have a look at CREATE TABLE Syntax

How to add relation between two tables in Mysql using Mysql control center

I want to create two tables with one to many relations. I use MySql Control center,but I did not find to add foreign key.I do not want to use console commands,How can I do? I also want to use transation so I use InnoDB table type, How can I add relation between two tables in Control Center.Is there another GUI software to handle Mysql?Pls tell me.
You should check SQLYog by Webyog
http://www.webyog.com/en/downloads.php#sqlyog
Why don't you give a try to MySQL Workbench 5.1 OSS it can do the job for, after created the entity you just export it as SQL format or XML as you wish, then import to your mysql database.
Folow the link Download Here