14.5. Checking Views


When you define a view, any object referenced by the view (such as a table, view, or column) must exist. However, a view can become invalid if a table, view, or column on which it depends is dropped or altered. To check a view for problems of this nature, use the CHECK TABLE statement. The following example shows the output from CHECK TABLE after renaming a table that a view depends on:

 mysql> CREATE TABLE t1 (i INT); Query OK, 0 rows affected (0.01 sec) mysql> CREATE VIEW v AS SELECT i FROM t1; Query OK, 0 rows affected (0.01 sec) mysql> RENAME TABLE t1 TO t2; Query OK, 0 rows affected (0.01 sec) mysql> CHECK TABLE v\G *************************** 1. row ***************************    Table: world.v       Op: check Msg_type: error Msg_text: View 'world.v' references invalid table(s) or column(s)           or function(s) 1 row in set (0.00 sec) 



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net