问题
I'm trying to create some meta-data to extend mysql functionality but I can't create tables in the database INFORMATION_SCHEMA. I thought that I could just create another database and have my metadata in there but I need some foreign keys from my tables to some tables in the INFORMATION_SCHEMA DB. Nevertheless, I get errors when trying to create them. Then I thought I could create a trigger to get notified of changes but since triggers are associated to a table and I can't alter that database, I can't create triggers either.
Specifically I have some tables that references to information_schema.schemata(schema_name)
and to information_schema.schemata(columns)
and some others. I want to have those foreign key so I can use ON UPDATE CASCADE ON DELETE CASCADE
or otherwise I'll have some rows in my tables referencing to nothing and I can't allow that.
I'm using mariaDB 5.5.30 which uses MySql 5.3.
回答1:
INFORMATION_SCHEMA tables are actually views whose contents is automatically maintained by the MySQL server.
The manual gives more information:
Inside INFORMATION_SCHEMA there are several read-only tables. They are actually views, not base tables, so there are no files associated with them, and you cannot set triggers on them. Also, there is no database directory with that name.
Although you can select INFORMATION_SCHEMA as the default database with a USE statement, you can only read the contents of tables, not perform INSERT, UPDATE, or DELETE operations on them.
回答2:
They are not really views but temporary tables, that's why you don't see folders. show create view views; ERROR 1347 (HY000): 'information_schema./tmp/#sql_2ac_0' is not VIEW
来源:https://stackoverflow.com/questions/16502166/how-to-alter-information-schema-or-add-triggers-or-foreign-keys-to-it