11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 34 • MYSQL VIEWSwww.it-ebooks.infoIf experienced_age_view were defined with the CASCADED CHECK OPTION option, an attempt to executethe following INSERT query would end in failure:INSERT INTO experienced_age_view SETfirst_name = 'Jason', last_name = 'Gilmore', age = '89', years_experience = '3';The reason that it would fail is that the years_experience value of 3 would violate the constraint ofexperienced_age_view that requires years_experience to be at least 5 years. On the contrary, if theexperienced_age_view view were defined as LOCAL, the INSERT query would be valid because only the agevalue would be greater than 65. However, if age were set to anything below 65, such as 42, the querywould fail because LOCAL checks against the view being referenced in the query, which in this case isexperienced_age_view.Viewing View Information<strong>MySQL</strong> offers three ways to learn more about your existing views: the DESCRIBE command, the SHOWCREATE VIEW command, or the INFORMATION_SCHEMA database.Using the DESCRIBE CommandBecause a view is akin to a virtual table, you can use the DESCRIBE statement to learn more about thecolumns represented by the view. For example, to review the view named employee_contact_info_view,execute the following command:DESCRIBE employee_contact_info_view;This produces the following output:+----------------+--------------+------+-----+-------------+----------+| Field | Type | Null | Key | Default | Extra |+----------------+--------------+------+-----+-------------+----------+| First Name | varchar(100) | NO | | | || Last Name | varchar(100) | NO | | | || Email Address | varchar(100) | NO | | | || Telephone | char(10) | NO | | | |+----------------+--------------+------+-----+-------------+----------+Using the SHOW CREATE VIEW CommandYou can review a view’s syntax by using the SHOW CREATE VIEW command. Its prototype follows:SHOW CREATE VIEW view_name;For instance, to review the employee_contact_info_view view syntax, execute the followingcommand:666

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!