<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL

        來源:懂視網 責編:小采 時間:2020-11-09 20:03:44
        文檔

        MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL

        MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL:Okay, so I thought I knew quite a bit about databases and so I added a unique index. For those who do not know: A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a ne
        推薦度:
        導讀MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL:Okay, so I thought I knew quite a bit about databases and so I added a unique index. For those who do not know: A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a ne
        Okay, so I thought I knew quite a bit about databases and so I added a unique index. For those who do not know:

        A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. – MySQL manual

        I added the unique index to my table that made it look like this:

        CREATE TABLE `table` (`a` int(11) DEFAULT NULL,`b` int(11) DEFAULT NULL,`c` int(11) DEFAULT NULL,UNIQUE KEY `a_b_c` (`a`,`b`,`c`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

        I was trying to insert or increment values in it like this:

        INSERT INTO `table` (a,b,c) VALUES (1,NULL,3),(1,NULL,3) ON DUPLICATE KEY UPDATE c=c+VALUES(c);

        I expected to get the following result:

        mysql> select * from `table`;+------+------+------+| a| b| c|+------+------+------+|1 | NULL |6 |+------+------+------+1 row in set (0.00 sec)

        But it did not do that! I got this result instead:

        mysql> select * from `table`;+------+------+------+| a| b| c|+------+------+------+|1 | NULL |3 ||1 | NULL |3 |+------+------+------+2 rows in set (0.00 sec)

        I was clueless until I read the documentation of MySQL a little better:

        This constraint does not apply to NULL values except for the BDB storage engine. For other engines, a UNIQUE index permits multiple NULL values for columns that can contain NULL. – MySQL manual

        Especially the part where it says: “does not apply to NULL values” makes things much, much clearer. :-) Note that Microsoft SQL Server behaves different (they way I expected). So keep this is mind when using a unique index in MySQL, because I certainly did not expect this behavior!

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL

        MySQLinsertsduplicaterecordsdespiteuniqueindex|Lease_MySQL:Okay, so I thought I knew quite a bit about databases and so I added a unique index. For those who do not know: A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a ne
        推薦度:
        標簽: 重復 mysql duplicate
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 国产成人无码区免费内射一片色欲| 亚洲AV无码国产精品永久一区| 成人免费乱码大片A毛片| 日本特黄特色免费大片| 亚洲人成网站在线播放2019| 国产在线国偷精品产拍免费| 男人天堂2018亚洲男人天堂 | 一级黄色免费大片| 亚洲综合精品网站| 特级做A爰片毛片免费看无码 | 在线观看永久免费| 亚洲国产精品线观看不卡| 国产99视频精品免费观看7| 亚洲日韩中文字幕无码一区| 国产精品成人免费综合| 午夜不卡AV免费| 亚洲国产精品无码久久久蜜芽 | 99久久免费国产精品热| 亚洲欧洲第一a在线观看| 97免费人妻无码视频| 亚洲精品av无码喷奶水糖心| 高清在线亚洲精品国产二区| 精品国产麻豆免费人成网站| 久久精品国产亚洲AV电影| 大香人蕉免费视频75| 有色视频在线观看免费高清在线直播| 久久精品亚洲男人的天堂| 午夜免费啪视频在线观看| 亚洲人成人77777网站不卡| 日本人护士免费xxxx视频| a级毛片毛片免费观看久潮| 亚洲人成7777影视在线观看| 又粗又大又猛又爽免费视频 | 国产99视频免费精品是看6| 精品国产免费人成网站| 亚洲国产成人无码av在线播放| 国产乱子影视频上线免费观看| 99视频在线观看免费| 亚洲熟女综合一区二区三区| 夜夜春亚洲嫩草影院| AV免费网址在线观看|