Mysql – Check if a database table has been renamed

MySQLpostgresqlpythonsqlalchemy

My app has a list of an external db's tables and it needs to be regularly updated. How do I check if a table has been renamed? i.e. how to differentiate between a new table and an old table that's been renamed? Looking for sql/python/sqlalchemy solutions that'll work in as many engines as possible.

I'm aware of OID in postgres but as far as I could tell it isn't very reliable and there's no equivalent in mysql. I suppose I could do something with the create time and modify time but I'm trying to see if there's an easier way.

Edit: The app is a data visualisation tool to which external dbs connect. I do not have control over the design of dbs that connect to the app which is why I need to account for tables getting renamed.

Best Answer

There is no other way to establish the identity of a database table in PostgreSQL than through the OID (system column tableoid). Creation time is not stored in PostgreSQL.

Relying on the table OID is not only proprietary to PostgreSQL, but also somewhat unsafe, since OIDs can get reused. I recommend that you keep an inventory of your table modifications in a separate database table.