How to get list of tables, that don`t have a specific column in MySQL - mysql

I need to have a list of tables in MySQL, that don`t have a column 'created' or 'modified', so I can add them if non existant. How can I achieve this?
Thanks in advance for any help / hint.

Query INFORMATION_SCHEMA database for this.
http://dev.mysql.com/doc/refman/5.1/en/information-schema.html

You can do this from PHP. Connect to the database and browse the mysql table. It will have all table definitions, then run DESCRIBE on each table, that will get you the structure.
I can give you some code examples if you like

Related

Is there any way join tables of MySql and PostgreSQL?

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

Get MySQL database structure alter queries

I'm working on a version control program, and I would like to implement database structure versioning as well.
Is there a way to get a list of all the queries that have altered the databse structure in any way?
For example I added a column to the 'users' table called 'remember_token'. Is there a way I can get the specific query that was executed on the MySQL server in order to add that column?
You may want to enable the mysql query log and then filter on ALTER queries or anything you need

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`;

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.

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