pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

    1. <tfoot id='Uwt7p'></tfoot>

    2. <i id='Uwt7p'><tr id='Uwt7p'><dt id='Uwt7p'><q id='Uwt7p'><span id='Uwt7p'><b id='Uwt7p'><form id='Uwt7p'><ins id='Uwt7p'></ins><ul id='Uwt7p'></ul><sub id='Uwt7p'></sub></form><legend id='Uwt7p'></legend><bdo id='Uwt7p'><pre id='Uwt7p'><center id='Uwt7p'></center></pre></bdo></b><th id='Uwt7p'></th></span></q></dt></tr></i><div class="5dddprn" id='Uwt7p'><tfoot id='Uwt7p'></tfoot><dl id='Uwt7p'><fieldset id='Uwt7p'></fieldset></dl></div>

      1. <legend id='Uwt7p'><style id='Uwt7p'><dir id='Uwt7p'><q id='Uwt7p'></q></dir></style></legend>
          <bdo id='Uwt7p'></bdo><ul id='Uwt7p'></ul>

        為 DATE 或 DATETIME 設置默認值時 MySQL 中的錯誤

        Error in MySQL when setting default value for DATE or DATETIME(為 DATE 或 DATETIME 設置默認值時 MySQL 中的錯誤)

          • <tfoot id='0H3vO'></tfoot>
              <tbody id='0H3vO'></tbody>

              <bdo id='0H3vO'></bdo><ul id='0H3vO'></ul>
                <i id='0H3vO'><tr id='0H3vO'><dt id='0H3vO'><q id='0H3vO'><span id='0H3vO'><b id='0H3vO'><form id='0H3vO'><ins id='0H3vO'></ins><ul id='0H3vO'></ul><sub id='0H3vO'></sub></form><legend id='0H3vO'></legend><bdo id='0H3vO'><pre id='0H3vO'><center id='0H3vO'></center></pre></bdo></b><th id='0H3vO'></th></span></q></dt></tr></i><div class="5rhh1x7" id='0H3vO'><tfoot id='0H3vO'></tfoot><dl id='0H3vO'><fieldset id='0H3vO'></fieldset></dl></div>
              • <legend id='0H3vO'><style id='0H3vO'><dir id='0H3vO'><q id='0H3vO'></q></dir></style></legend>

                  <small id='0H3vO'></small><noframes id='0H3vO'>

                  本文介紹了為 DATE 或 DATETIME 設置默認值時 MySQL 中的錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我運行的是 MySql Server 5.7.11 和這句話:

                  I'm running MySql Server 5.7.11 and this sentence:

                  updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00'
                  

                  不起作用.給出錯誤:

                  ERROR 1067 (42000): Invalid default value for 'updated'
                  

                  但是以下:

                  updated datetime NOT NULL DEFAULT '1000-01-01 00:00:00'
                  

                  剛剛好.

                  DATE 的情況相同.

                  The same case for DATE.

                  作為旁注,它在MySQL 文檔:

                  DATE 類型用于具有日期部分但沒有時間部分的值.MySQL 以 'YYYY-MM-DD' 格式檢索和顯示 DATE 值.支持的范圍是1000-01-01"到9999-12-31".

                  The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.

                  即使他們也說:

                  無效的 DATE、DATETIME 或 TIMESTAMP 值將轉換為適當類型的零"值('0000-00-00' 或 '0000-00-00 00:00:00').

                  Invalid DATE, DATETIME, or TIMESTAMP values are converted to the "zero" value of the appropriate type ('0000-00-00' or '0000-00-00 00:00:00').

                  還考慮到 MySQL 文檔中的第二個引用,誰能告訴我為什么會出現該錯誤?

                  Having also into account the second quote from MySQL documentation, could anyone let me know why it is giving that error?

                  推薦答案

                  該錯誤是由于 sql 模式,根據最新的 MYSQL 5.7 文檔可以是嚴格模式

                  The error is because of the sql mode which can be strict mode as per latest MYSQL 5.7 documentation

                  MySQL 文檔 5.7 說:

                  嚴格模式會影響服務器是否允許0000-00-00"作為有效日期:如果未啟用嚴格模式,則允許使用 '0000-00-00' 并且插入不會產生警告.如果啟用了嚴格模式,則不允許使用 '0000-00-00' 并且插入會產生錯誤,除非也給出了 IGNORE.對于 INSERT IGNORE 和 UPDATE IGNORE,允許使用0000-00-00"并且插入會產生警告.

                  Strict mode affects whether the server permits '0000-00-00' as a valid date: If strict mode is not enabled, '0000-00-00' is permitted and inserts produce no warning. If strict mode is enabled, '0000-00-00' is not permitted and inserts produce an error, unless IGNORE is given as well. For INSERT IGNORE and UPDATE IGNORE, '0000-00-00' is permitted and inserts produce a warning.

                  檢查MYSQL模式

                  SELECT @@GLOBAL.sql_mode 全局,@@SESSION.sql_mode 會話

                  禁用 STRICT_TRANS_TABLES 模式

                  但是要允許格式 0000-00-00 00:00:00您必須在 mysql 配置文件中或通過命令禁用 STRICT_TRANS_TABLES 模式

                  However to allow the format 0000-00-00 00:00:00you have to disable STRICT_TRANS_TABLES mode in mysql config file or by command

                  通過命令

                  SET sql_mode = '';

                  SET GLOBAL sql_mode = '';

                  使用關鍵字 GLOBAL 需要超級特權,它會影響從那時起所有客戶端連接的操作

                  Using the keyword GLOBAL requires super previliges and it affects the operations all clients connect from that time on

                  如果以上不起作用,請轉到 /etc/mysql/my.cnf(根據 ubuntu)并注釋掉 STRICT_TRANS_TABLES

                  if above is not working than go to /etc/mysql/my.cnf (as per ubuntu) and comment out STRICT_TRANS_TABLES

                  此外,如果您想在服務器啟動時永久設置 sql 模式,請在 Linux 或 MacOS 上的 my.cnf 中包含 SET sql_mode=''.對于 Windows,這必須在 my.ini 文件中完成.

                  Also, if you want to permanently set the sql mode at server startup then include SET sql_mode='' in my.cnf on Linux or MacOS. For windows this has to be done in my.ini file.

                  注意

                  然而,在 MYSQL 5.6 中默認沒有啟用嚴格模式.因此它不會按照 MYSQL 6 產生錯誤文檔其中說

                  However strict mode is not enabled by default in MYSQL 5.6. Hence it does not produce the error as per MYSQL 6 documentation which says

                  MySQL 允許您將0000-00-00"的零"值存儲為虛擬日期".這在某些情況下比使用 NULL 值更方便,并且使用更少的數據和索引空間.要禁止0000-00-00",請啟用 NO_ZERO_DATE SQL 模式.

                  MySQL permits you to store a "zero" value of '0000-00-00' as a "dummy date." This is in some cases more convenient than using NULL values, and uses less data and index space. To disallow '0000-00-00', enable the NO_ZERO_DATE SQL mode.

                  更新

                  關于@Dylan-Su 所說的錯誤問題:

                  Regarding the bug matter as said by @Dylan-Su:

                  我不認為這是 MYSQL 隨著時間的推移演變的方式的錯誤,因為根據產品的進一步改進,某些事情發生了變化.

                  I don't think this is the bug it the way MYSQL is evolved over the time due to which some things are changed based on further improvement of the product.

                  但是我有另一個關于 NOW() 函數的相關錯誤報告

                  However I have another related bug report regarding the NOW() function

                  日期時間字段不接受默認的 NOW()

                  另一個有用的說明 [參見 TIMESTAMP 和 DATETIME 的自動初始化和更新]

                  從 MySQL 5.6.5 開始,TIMESTAMP 和 DATETIME 列可以自動初始化并更新為當前日期和時間(即當前時間戳).在 5.6.5 之前,這僅適用于 TIMESTAMP,并且每個表最多有一個 TIMESTAMP 列.下面的注釋首先描述了 MySQL 5.6.5 及更高版本的自動初始化和更新,然后是 5.6.5 之前版本的差異.

                  As of MySQL 5.6.5, TIMESTAMP and DATETIME columns can be automatically initializated and updated to the current date and time (that is, the current timestamp). Before 5.6.5, this is true only for TIMESTAMP, and for at most one TIMESTAMP column per table. The following notes first describe automatic initialization and updating for MySQL 5.6.5 and up, then the differences for versions preceding 5.6.5.

                  關于 NO_ZERO_DATE 的更新

                  自 MySQL 5.7.4 起,此模式已棄用.對于以前的版本,您必須注釋掉配置文件中的相應行.請參閱 關于 NO_ZERO_DATE 的 MySQL 5.7 文檔

                  As of MySQL as of 5.7.4 this mode is deprecated. For previous version you must comment out the respective line in the config file. Refer MySQL 5.7 documentation on NO_ZERO_DATE

                  這篇關于為 DATE 或 DATETIME 設置默認值時 MySQL 中的錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 數據幀讀取?)

                  <small id='0huFW'></small><noframes id='0huFW'>

                  1. <tfoot id='0huFW'></tfoot>
                    <i id='0huFW'><tr id='0huFW'><dt id='0huFW'><q id='0huFW'><span id='0huFW'><b id='0huFW'><form id='0huFW'><ins id='0huFW'></ins><ul id='0huFW'></ul><sub id='0huFW'></sub></form><legend id='0huFW'></legend><bdo id='0huFW'><pre id='0huFW'><center id='0huFW'></center></pre></bdo></b><th id='0huFW'></th></span></q></dt></tr></i><div class="xflhrhv" id='0huFW'><tfoot id='0huFW'></tfoot><dl id='0huFW'><fieldset id='0huFW'></fieldset></dl></div>

                        <tbody id='0huFW'></tbody>
                      • <legend id='0huFW'><style id='0huFW'><dir id='0huFW'><q id='0huFW'></q></dir></style></legend>
                          <bdo id='0huFW'></bdo><ul id='0huFW'></ul>
                            主站蜘蛛池模板: 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 浙江工业冷却塔-菱电冷却塔厂家 - 浙江菱电冷却设备有限公司 | 置顶式搅拌器-优莱博化学防爆冰箱-磁驱搅拌器-天津市布鲁克科技有限公司 | 软装设计-提供软装装饰和软装配饰及软装陈设的软装设计公司 | loft装修,上海嘉定酒店式公寓装修公司—曼城装饰 | 湖南档案密集架,智能,物证,移动,价格-湖南档案密集架厂家 | 南方珠江-南方一线电缆-南方珠江科技电缆-南方珠江科技有限公司 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格 | 精雕机-火花机-精雕机 cnc-高速精雕机-电火花机-广东鼎拓机械科技有限公司 | 气力输送_输送机械_自动化配料系统_负压吸送_制造主力军江苏高达智能装备有限公司! | 苏州西装定制-西服定制厂家-职业装定制厂家-尺品服饰西装定做公司 | 美名宝起名网-在线宝宝、公司、起名平台 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 西门子伺服电机维修,西门子电源模块维修,西门子驱动模块维修-上海渠利 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 广州/东莞小字符喷码机-热转印打码机-喷码机厂家-广州瑞润科技 | 公交驾校-北京公交驾校欢迎您!| 求是网 - 思想建党 理论强党| 胜为光纤光缆_光纤跳线_单模尾纤_光纤收发器_ODF光纤配线架厂家直销_北京睿创胜为科技有限公司 - 北京睿创胜为科技有限公司 | 大功率金属激光焊接机价格_不锈钢汽车配件|光纤自动激光焊接机设备-东莞市正信激光科技有限公司 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | 智慧物联网行业一站式解决方案提供商-北京东成基业 | 双杰天平-国产双杰电子天平-美国双杰-常熟双杰仪器 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 不锈钢搅拌罐_高速搅拌罐厂家-无锡市凡格德化工装备科技有限公司 | 工业铝型材生产厂家_铝合金型材配件批发精加工定制厂商 - 上海岐易铝业 | 老房子翻新装修,旧房墙面翻新,房屋防水补漏,厨房卫生间改造,室内装潢装修公司 - 一修房屋快修官网 | 预制直埋蒸汽保温管-直埋管道-聚氨酯发泡保温管厂家 - 唐山市吉祥保温工贸有限公司 | 小型铜米机-干式铜米机-杂线全自动铜米机-河南鑫世昌机械制造有限公司 | 临朐空调移机_空调维修「空调回收」临朐二手空调 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 长沙中央空调维修,中央空调清洗维保,空气能热水工程,价格,公司就找维小保-湖南维小保环保科技有限公司 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 粉末包装机,拆包机厂家,价格-上海强牛包装机械设备有限公司 | 高效复合碳源-多核碳源生产厂家-污水处理反硝化菌种一长隆科技库巴鲁 | 三轴曲线机-端子插拔力试验机|华杰仪器| 影像测量仪_三坐标测量机_一键式二次元_全自动影像测量仪-广东妙机精密科技股份有限公司 | 沙盘模型公司_沙盘模型制作公司_建筑模型公司_工业机械模型制作厂家 | 防火窗_耐火窗_防火门厂家_防火卷帘门-重庆三乐门业有限公司 | 双效节能浓缩器-热回流提取浓缩机组-温州市利宏机械 | 网带通过式抛丸机,,网带式打砂机,吊钩式,抛丸机,中山抛丸机生产厂家,江门抛丸机,佛山吊钩式,东莞抛丸机,中山市泰达自动化设备有限公司 | 电子元器件呆滞料_元器件临期库存清仓尾料_尾料优选现货采购处理交易商城 | 长沙网站建设制作「网站优化推广」-网页设计公司-速马科技官网 |