久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='DRAWt'><style id='DRAWt'><dir id='DRAWt'><q id='DRAWt'></q></dir></style></legend>

<small id='DRAWt'></small><noframes id='DRAWt'>

      • <bdo id='DRAWt'></bdo><ul id='DRAWt'></ul>
    1. <tfoot id='DRAWt'></tfoot>

        <i id='DRAWt'><tr id='DRAWt'><dt id='DRAWt'><q id='DRAWt'><span id='DRAWt'><b id='DRAWt'><form id='DRAWt'><ins id='DRAWt'></ins><ul id='DRAWt'></ul><sub id='DRAWt'></sub></form><legend id='DRAWt'></legend><bdo id='DRAWt'><pre id='DRAWt'><center id='DRAWt'></center></pre></bdo></b><th id='DRAWt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DRAWt'><tfoot id='DRAWt'></tfoot><dl id='DRAWt'><fieldset id='DRAWt'></fieldset></dl></div>

        MySQL 從 CSV 數據加載 NULL 值

        MySQL load NULL values from CSV data(MySQL 從 CSV 數據加載 NULL 值)

              <tbody id='WVSfg'></tbody>
            <tfoot id='WVSfg'></tfoot>
            <i id='WVSfg'><tr id='WVSfg'><dt id='WVSfg'><q id='WVSfg'><span id='WVSfg'><b id='WVSfg'><form id='WVSfg'><ins id='WVSfg'></ins><ul id='WVSfg'></ul><sub id='WVSfg'></sub></form><legend id='WVSfg'></legend><bdo id='WVSfg'><pre id='WVSfg'><center id='WVSfg'></center></pre></bdo></b><th id='WVSfg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WVSfg'><tfoot id='WVSfg'></tfoot><dl id='WVSfg'><fieldset id='WVSfg'></fieldset></dl></div>

            <small id='WVSfg'></small><noframes id='WVSfg'>

              <bdo id='WVSfg'></bdo><ul id='WVSfg'></ul>
              <legend id='WVSfg'><style id='WVSfg'><dir id='WVSfg'><q id='WVSfg'></q></dir></style></legend>

                  本文介紹了MySQL 從 CSV 數據加載 NULL 值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個文件,可以包含 3 到 4 列用逗號分隔的數值.空字段被定義為例外,當它們位于行的末尾時:

                  1,2,3,4,51,2,3,,51,2,3

                  下表是在 MySQL 中創建的:

                  <前>+-------+--------+------+-------+-------+-------+|領域 |類型 |空 |鑰匙 |默認 |額外 |+-------+--------+------+-------+-------+-------+|一 |整數(1) |是 ||空 |||二 |整數(1) |是 ||空 |||三 |整數(1) |是 ||空 |||四 |整數(1) |是 ||空 |||五 |整數(1) |是 ||空 ||+-------+--------+------+-------+-------+-------+

                  我正在嘗試使用 MySQL LOAD 命令加載數據:

                  LOAD DATA INFILE '/tmp/testdata.txt' INTO TABLE moo FIELDS終止于 "," 行終止于 "\n";

                  結果表:

                  <前>+------+------+-------+------+------+|一 |二 |三 |四 |五 |+------+------+-------+------+------+|1 |2 |3 |4 |5 ||1 |2 |3 |0 |5 ||1 |2 |3 |空 |空 |+------+------+-------+------+------+

                  問題在于,當原始數據中的字段為空且未定義時,MySQL 出于某種原因不使用列的默認值(即 NULL)而使用零.當字段完全丟失時,NULL 被正確使用.

                  不幸的是,在此階段我必須能夠區分 NULL 和 0,因此我們將不勝感激.

                  謝謝

                  編輯

                  顯示警告的輸出:

                  <前>+---------+------+--------------------------------------------------------+|級別 |代碼 |留言 |+---------+------+--------------------------------------------------------+|警告 |第1366章不正確的整數值:第 2 行的列 'four' 的 '' ||警告 |第1261章第 3 行不包含所有列的數據 ||警告 |第1261章第 3 行不包含所有列的數據 |+---------+------+--------------------------------------------------------+

                  解決方案

                  這將滿足您的需求.它將第四個字段讀入局部變量,然后將實際字段值設置為 NULL,如果局部變量最終包含一個空字符串:

                  LOAD DATA INFILE '/tmp/testdata.txt'INTO TABLE MOO以,"結尾的字段以\n"結尾的行(一,二,三,@vfour,五)SET 四 = NULLIF(@vfour,'');

                  如果它們都可能為空,那么您可以將它們全部讀入變量并有多個 SET 語句,如下所示:

                  LOAD DATA INFILE '/tmp/testdata.txt'INTO TABLE MOO以,"結尾的字段以\n"結尾的行(@vone、@vtwo、@vthree、@vfour、@vfive)放一 = NULLIF(@vone,''),二 = NULLIF(@vtwo,''),三 = NULLIF(@vthree,''),四 = NULLIF(@vfour,'');

                  I have a file that can contain from 3 to 4 columns of numerical values which are separated by comma. Empty fields are defined with the exception when they are at the end of the row:

                  1,2,3,4,5
                  1,2,3,,5
                  1,2,3
                  

                  The following table was created in MySQL:

                  +-------+--------+------+-----+---------+-------+
                  | Field | Type   | Null | Key | Default | Extra |
                  +-------+--------+------+-----+---------+-------+
                  | one   | int(1) | YES  |     | NULL    |       | 
                  | two   | int(1) | YES  |     | NULL    |       | 
                  | three | int(1) | YES  |     | NULL    |       | 
                  | four  | int(1) | YES  |     | NULL    |       | 
                  | five  | int(1) | YES  |     | NULL    |       | 
                  +-------+--------+------+-----+---------+-------+
                  

                  I am trying to load the data using MySQL LOAD command:

                  LOAD DATA INFILE '/tmp/testdata.txt' INTO TABLE moo FIELDS 
                  TERMINATED BY "," LINES TERMINATED BY "\n";
                  

                  The resulting table:

                  +------+------+-------+------+------+
                  | one  | two  | three | four | five |
                  +------+------+-------+------+------+
                  |    1 |    2 |     3 |    4 |    5 | 
                  |    1 |    2 |     3 |    0 |    5 | 
                  |    1 |    2 |     3 | NULL | NULL | 
                  +------+------+-------+------+------+
                  

                  The problem lies with the fact that when a field is empty in the raw data and is not defined, MySQL for some reason does not use the columns default value (which is NULL) and uses zero. NULL is used correctly when the field is missing alltogether.

                  Unfortunately, I have to be able to distinguish between NULL and 0 at this stage so any help would be appreciated.

                  Thanks S.

                  edit

                  The output of SHOW WARNINGS:

                  +---------+------+--------------------------------------------------------+
                  | Level   | Code | Message                                                |
                  +---------+------+--------------------------------------------------------+
                  | Warning | 1366 | Incorrect integer value: '' for column 'four' at row 2 | 
                  | Warning | 1261 | Row 3 doesn't contain data for all columns             | 
                  | Warning | 1261 | Row 3 doesn't contain data for all columns             | 
                  +---------+------+--------------------------------------------------------+
                  

                  解決方案

                  This will do what you want. It reads the fourth field into a local variable, and then sets the actual field value to NULL, if the local variable ends up containing an empty string:

                  LOAD DATA INFILE '/tmp/testdata.txt'
                  INTO TABLE moo
                  FIELDS TERMINATED BY ","
                  LINES TERMINATED BY "\n"
                  (one, two, three, @vfour, five)
                  SET four = NULLIF(@vfour,'')
                  ;
                  

                  If they're all possibly empty, then you'd read them all into variables and have multiple SET statements, like this:

                  LOAD DATA INFILE '/tmp/testdata.txt'
                  INTO TABLE moo
                  FIELDS TERMINATED BY ","
                  LINES TERMINATED BY "\n"
                  (@vone, @vtwo, @vthree, @vfour, @vfive)
                  SET
                  one = NULLIF(@vone,''),
                  two = NULLIF(@vtwo,''),
                  three = NULLIF(@vthree,''),
                  four = NULLIF(@vfour,'')
                  ;
                  

                  這篇關于MySQL 從 CSV 數據加載 NULL 值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                  <tfoot id='cJ8ie'></tfoot>
                  <legend id='cJ8ie'><style id='cJ8ie'><dir id='cJ8ie'><q id='cJ8ie'></q></dir></style></legend>

                  <small id='cJ8ie'></small><noframes id='cJ8ie'>

                    <tbody id='cJ8ie'></tbody>

                        • <bdo id='cJ8ie'></bdo><ul id='cJ8ie'></ul>
                          • <i id='cJ8ie'><tr id='cJ8ie'><dt id='cJ8ie'><q id='cJ8ie'><span id='cJ8ie'><b id='cJ8ie'><form id='cJ8ie'><ins id='cJ8ie'></ins><ul id='cJ8ie'></ul><sub id='cJ8ie'></sub></form><legend id='cJ8ie'></legend><bdo id='cJ8ie'><pre id='cJ8ie'><center id='cJ8ie'></center></pre></bdo></b><th id='cJ8ie'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cJ8ie'><tfoot id='cJ8ie'></tfoot><dl id='cJ8ie'><fieldset id='cJ8ie'></fieldset></dl></div>

                            主站蜘蛛池模板: 久久免费香蕉视频 | 九色在线视频 | 国产高清在线精品一区二区三区 | 国产va| 粉嫩一区二区三区性色av | 97国产成人 | 国产在线一区二区三区 | 精品久久影院 | h在线| 国产视频欧美 | 国产精品一区二区在线播放 | 九九精品在线 | 草久久 | 成人国产精品久久久 | a黄视频 | 国产91在线播放 | 成年人在线播放 | 91免费视频观看 | 久久网国产 | 中文字幕一区二区三 | 国产在线对白 | 久久国产99 | 日韩黄色小视频 | 欧美成人a | 欧美一区二区精品 | 免费在线观看一区二区三区 | 久久99国产精品 | 毛片在线免费 | 特黄视频 | 亚洲成av人影片在线观看 | 97精品超碰一区二区三区 | 伊伊综合网 | 日韩国产一区二区三区 | 亚洲一区二区三区免费在线观看 | 欧美精品一二三区 | 视频一区二区在线观看 | 99久久99 | 国产精品99久久久久久www | 国产精品亚洲综合 | 日韩美女一区二区三区在线观看 | 中文字幕视频网 |