mysqldbcompare skip some tables - mysql

I need to compare 2 mysql databases. But i need to compare not all tables. Some tables must be skipped.
I wanted to use the tool mysqldbcompare . It looks what i need but i don't see an option to skip some tables. seems it will just compare all tables , which will not work for me (i know some tables are different, i want to skip them)
Is it possible to skip tables with this tool?
Maybe there is some alternative tool which can compare only selected tables?
In this manual there is nothing about tables skipping https://dev.mysql.com/doc/mysql-utilities/1.5/en/mysqldbcompare.html

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.

synchronize two tables stored in different databases

I have two tables in different databases. The tables are exactly alike (same name,same columns,etc). My question is, how can I retrieve new rows from parent table and store into the child table? I thought of using mysqldbcompare but it compares Two Databases and Identify Differences but i need to do it on a table.
mysqldbcompare --server1=root:root#192.100.0.0\
--server2=root:root#192.160.0.01 \
inteliviz:inteliviz\
--run-all-test --changes-for=server2 --difftype=sql
how to pass tables in here.
Thanks in advance.
mysqldbcompare can be made to generate the required sql to synchronise the two databases. My approach would be to use the --difftype=sql option to generate the sql required to generate the changed or missing rows. To reduce the surrounding "noise" in the mysqldbcompare report, you could limit the comparison to data consistency checks using --skip-... for all but the data-check option.
Something like:
mysqldbcompare --server1=... \
--server2=... \
--difftype=sql \
--skip-object-compare --skip-object-diff --skip-option-count > report.txt
Alternatively, you could use INSERT IGNORE or REPLACE as per this answer:
MySQL INSERT INTO WHERE NOT EXIST

Batch replacements in MySQL Database

I've learned how to do simple search and replace operations in my MySQL databases using phpMyAdmin...
UPDATE my_table SET my_column = replace(my_column,'Spain','Spanish')
I just wondered if there are ways to target more than one fields and/or tables at a time. For example, if you have three tables named One, Two and Three and each one has a field named Article, could you do a search-and-replace operation in all three tables simultaneously? Or could you even search fields with different names, like One.Article, Two.Article, Three.Content?
Solutions don't have to be limited to phpMyAdmin. I'm interested in learning about other popular DB administration programs.
Yes, UPDATE supports multi-table syntax:
UPDATE One, Two, Three
SET One.Article = replace(One.Article,'Spain','Spanish'),
Two.Article=replace(Two.Article,'Spain','Spanish'),
Three.Content=replace(Three.Content,'Spain','Spanish');

How to compare two databases' altered tables

I have inserted new columns in one database, and I now want to add the same type of columns to a second database. I need to know which columns are in the first database that are not in the second. I have many tables in each database that needs column difference comparing. I searched the web and I can only find ways to see the difference of the contents of columns in two tables. I don't need to compare the contents, just different columns in all the tables in each database. Each database has the same tables.
Thanks!
I found that you can do a database dump that just has the structure from phpmyadmin.
Are you doing this manually? You could just use SHOW CREATE to see the structure of the tables, and then something like the diff command in Linux to compare them.
For a commercial product answer: I use Red Gate's SQL Compare which works great. It can compare the entire schema of two databases. It can also update your target database to match your source database.
Use redgate SQL compare to comapre schema of two tables.
sql-dbdiff works well too. Its an open source.

How do i dump all the tables from a single database in a sql file except for the ones mentioned?

I wanted to know if it was possible can do a db dump of all the tables in a database, but leaving a couple of tables specified on the command line. this is for mysql. i know there is one for adding specific tables on an sql, but i dont know if you can exclude specific tables. Thanks in advance.
Mysqldump has an --ignore-table option.