Auto refresh view in MySql

Is the view updated automatically when the base tables are updated in MySQL without a query?

Further development - if I update the table, is the view updated, even if I do not run any query in the view?

+9
mysql view
source share
5 answers

Each time you execute a query in a view, it will retrieve the data currently in the tables, including all committed transactions, but not those UPDATE or INSERT queries that have not yet been executed.

but of course, once you receive this data, it will not send it again. There are triggers for this, but your database client must request view data.

To clear the bit more: the view does not store (cache) data, it is a logical structure and will always look at the main tables.

+13
source share

A view is a stored query, accessible as a virtual table, and consists of a set of query results. Changing the data in the reference tables changes the data specified in subsequent presentation calls.

see: http://en.wikipedia.org/wiki/View_(database)

its a bit like this .....

If you ask me now, I will tell you that it is ten o'clock.

If you ask me after 2 hours, I will tell you that it is twelve hours.

If you do not ask me, I will not tell you the time.

+6
source share

If you have created a view for a specific table, the data in the view will automatically update when data changes or insert new data into the corresponding table.

However, if you want to add more columns to the database table and update the corresponding view, this change will not be automatic.

You can use "SQLYog" for this. This is a good tool for working with presentations.

+3
source share

Usually VIEW is updated automatically.

From MySQL Documentation

Some views are being updated. That is, you can use them in statements like UPDATE, DELETE, or INSERT to update the contents of a table. In order to be updatable, there must be a one-to-one relationship between the rows in the view and the rows in the base table. There are also some other designs that create a view that cannot be updated.

+2
source share

Yes, views are automatically updated in MySQL; including but not limited to:

  • Change table structure
  • Insert / update / delete procedures in tables
  • Change view structures with CREATE OR REPLACE VIEW

NOTE. To change the structure of the table, you must recreate the view.

0
source share

All Articles