索引表中的mysql更新查询 [英] mysql update query in the indexed table

查看:108
本文介绍了索引表中的mysql更新查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一张表有主键组合,我都为该表做了索引。



EX:TableName - > StudentMark



Primay Key - > ClassName,RollNo(两者都是我设定的索引)





现在我在做查询



更新StudentMark set name =''XXX''其中ClassName =X且RollNo = 1



更新StudentMark set name =''XXX ''其中RollNo = 1且ClassName =X



查询是否合适。因为我做了索引类名,rollno。

One of my table having combintaion of primary key, both i did index for that table.

EX: TableName -> StudentMark

Primay Key -> ClassName, RollNo (Both are i set index)


Now i am doing the query

Update StudentMark set name =''XXX'' where ClassName ="X" and RollNo = 1

Update StudentMark set name =''XXX'' where RollNo = 1 and ClassName ="X"

which query is proper. because i did the index classname, rollno.

推荐答案

你的表结构错了。表应该只有1个主键,数据类型为数字/数字。

如果其他列想要具有不同的值,则给予约束唯一。



Plz在实施之前了解主键和唯一键的基本概念。

主键默认有索引。



同时感谢你,Vardhan Desai。
Your table structure is wrong. Table should have only 1 Primary Key with datatype Number/Numeric.
If other Columns you want to have different values then give constraint a "Unique".

Plz know basic concept of Primary Key & Unique Key before implementing.
Primary Key is having indexes by default.

Thanking you meanwhile, Vardhan Desai.


这篇关于索引表中的mysql更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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