Navicat中的MySQL视图-如何定义“主键"? [英] MySQL Views in Navicat - How to define 'primary key'?

查看:970
本文介绍了Navicat中的MySQL视图-如何定义“主键"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在Navicat中定义视图时,会收到以下消息:

xxx没有主键.使用以下伪语句对表进行更新:UPDATE xxx SET ModifiedFieldsAndValues WHERE AllFieldsAndOldValues LIMIT 1

很明显,我仅使用视图来查看数据,而不使用更新.但这确实使我感到好奇:

是否可以在视图上定义主键"或唯一索引"?

解决方案

表示视图使用其基表的索引和主键.您可以通过使用CASCADING CHECK选项来更改通过视图使用插入和更新时如何发生的语义

请参阅可更新和可插入视图

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?

解决方案

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

这篇关于Navicat中的MySQL视图-如何定义“主键"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆