简体   繁体   English

视图存储在Mysql中的位置

[英]where views are stored in Mysql

I have some questions on views - 我对观点有一些疑问-

  1. Where views are created/stored in Mysql? 在Mysql中哪里创建/存储视图? Or they are only virtual and deleted after some time period? 还是它们只是虚拟的并在一段时间后被删除?

  2. When the data of views is refresh? 视图的数据何时刷新? (It refresh automatically when we insert data in actual table or we have to update view each time?) (当我们在实际表中插入数据或每次必须更新视图时,它会自动刷新吗?)

  3. Use of views is good or we should fire the queries each time? 使用视图好还是我们应该每次触发查询?

  1. Views are pure metadata. 视图是纯元数据。 MySQL doesn't copy any data during the creating of a view, and it's also it is not deleted after a time. MySQL在创建视图期间不会复制任何数据,而且一段时间后不会删除它。
  2. When you run a select on a view, mysql (or any other database) runs the query defined at creation time. 在视图上运行选择时,mysql(或任何其他数据库)将运行在创建时定义的查询。
  3. There's no performance difference (or almos not different) between running a query on a table or on a view. 在表或视图上运行查询之间没有性能差异(或almos相同)。

Some databases, such as oracle, support something called materialised views . 某些数据库(例如oracle)支持称为物化视图的内容 These views, do copy the data, so they have to be refreshed, so the data doesn't become stale. 这些视图确实会复制数据,因此必须刷新它们,以使数据不会过时。

Leaving this as it turned up in Google results. 将其保留在Google结果中。

To see view definitions in MySQL you can use this query: 要查看MySQL中的视图定义,可以使用以下查询:

SELECT * FROM information_schema.VIEWS;

Regards, 问候,

James 詹姆士

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM