开发者

MySQL foreign key to table list

开发者 https://www.devze.com 2023-03-06 10:35 出处:网络
Lately I have been doing some work with MySQL and have come across the need to store table names as a field in one of my tables (which is not ideal). Instead I would like to reference a list of tables

Lately I have been doing some work with MySQL and have come across the need to store table names as a field in one of my tables (which is not ideal). Instead I would like to reference a list of tables t开发者_JAVA百科hat currently exist in the database as a foreign key. I have found that the information_schema database stores a list of these tables however I cannot reference them as a foreign key as they are Memory tables. Is there another way I can reference the list of tables in the database as a foreign key.

For those interested, the reason I need to store the table names is because I am developing a basic PHP framework that exposes each table in the database as a class.


How dynamic is the list of tables in your database? One option is to create your own table and (periodically) fill it with the table names from information_schema.

0

精彩评论

暂无评论...
验证码 换一张
取 消