MySQL Views in Navicat - How to define 'primary key'?
Asked Answered
L

1

6

Often when I define a View in Navicat I receive the following message:

xxx does not have a primary key. Updates to this table will be done using the following pseudo statement: UPDATE xxx SET ModifiedFieldsAndValues WHERE AllFieldsAndOldValues LIMIT 1

Obviously I only use my Views for viewing data, not updating. But this did make me curious:

Is there a way to define a "primary key" or "unique index" on a View?

Lophophore answered 19/5, 2009 at 17:51 Comment(0)
L
1

its implied that the view uses the indices and primary keys of its base table. You can change the semantics of how insert and updates occur when using them via views by playing with the CASCADING CHECK options

See Updatable and Insertable Views

Lauryn answered 19/5, 2009 at 18:0 Comment(2)
Ok, but most views consist of multiple tables which are joined together... Does it automatically check if there is a unique combination of indices?Lophophore
@Ropstah, For that to happen, it needs an index anyway. Does show keys in View give you an empty set?Hols

© 2022 - 2024 — McMap. All rights reserved.