<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                1005 - Can't create table 'xxx' (errno 150) 當你試圖在mysql中創建一個外鍵的時候,這個出錯會經常發生。 可應用操作系統:Windows、Mac、Linux、iOS 可應用 Navicat 產品:Navicat for MySQL、Navicat for MariaDB、Navicat Premium 可應用 Navicat 版本編號:全部 有些可能的情況會導致在 MySQL 數據庫創建外鍵和表失敗。這些錯誤都關系到MySQL 本身。 * * * * * 例子情況: 如果兩個字段(字段名和外鍵名)使用不相容的字段類型,MySQL 會返回錯誤。 如果你使用 "On Delete Set Null",但字段不允許 null,MySQL 會返回錯誤。 * * * * * 150錯誤的常見原因列出來了,并且我以可能性的大小作了排序 已知的原因: 1, 兩個字段的類型或者大小不嚴格匹配。 例如,如果一個是INT(10), 那么外鍵也必須設置成INT(10), 而不是 INT(11) 也不能是 TINYINT. 你得使用 SHOW 命令來查看字段的大小,因為一些查詢瀏覽器有時候把 int(10) 和int(11) 都顯示為integer。 另外,你還必須確定兩個字段是否一個為 SIGNED,而另一個是UNSIGNED, 這兩字段必須嚴格地一致匹配。 2, 你試圖引用的其中一個外鍵沒有建立起索引,或者不是一個primary key , 如果其中一個不是primary key 的話,你必須為它創建一個索引。 3, 外鍵的名字是一個已經存在的一個鍵值了,這個時候,你應該檢查你的數據庫以確保外健名字是唯一的,或者你在鍵名后面加上幾個隨機的字符以測試是否是這個原因。 121錯誤:重名錯誤。 外鍵和表一樣,在同一個庫中是不允許與其他外鍵重名的。 遇到這個錯誤請給你定義的外鍵換唯一無重復的名字。 4, 其中一個或者兩個表是MyISAM引擎的表,若想要使用外鍵約束,必須是InnoDB引擎,(實際上,如果兩個表都是MyISAM 引擎的,這個錯誤根本不會發生,但也不會產生外鍵),你可以通過查詢瀏覽器來設置表的引擎類型 5, 你可能設置了ON DELETE SET NULL, 但是相關的鍵的字段又設置成了NOTS NULL 值。你可能通過修改cascade 的屬性值或者把字段屬性設置成 allow null 來搞定這個bug. 6, 請確定你的Charset 和 Collate 選項在表級和字段級上的一致 7, 你可能設置為外鍵設置了一個默認值,如 default=0 8, 在這個關系里面,其中的一個字段是一個混合鍵值中的一個,它沒有自己獨立的索引,這時,你必須為它創建一個獨立的索引。 9, ALTER 聲明中有語法錯誤 。 10, 要連接的兩個表的編碼格式不同 * * * * * 可能有各種情況下會導致同樣的錯誤。欲了解更多信息,請隨時訪問 http://dev.mysql.com/doc/refman/5.1/en/cannot-create.html * * * * * Can’t create table ‘XX.frm’ (errno: 150) MySQL Error Number 1005 * * * * * [Err] 1005 - Can't create table 'blog_db.#sql-136c_4' (errno: 150) If you get this error while trying to create a foreign key, it can be pretty frustrating. The error about not being able to create a .frm file seems like it would be some kind of OS file permission error or something but this is not the case. This error has been reported as a bug on the MySQL developer list for ages, but it is actually just a misleading error message. In every case this is due to something about the relationship that MySQL doesn’t like. Unfortunately it doesn’t specify what the exact issue is. Here is a running list of causes that people have reported for the dreaded errno 150. I’ve tried to put them in order based on the frequency that I hear about a particular cause. You may want to start by running the MySQL command “SHOW INNODB STATUS” immediately after receiving the error. This command displays log info and error details. (Thanks Jonathan for the tip) Note: If your script runs fine on one server, but gives an error when you try to run it on a different server, then there is a good chance that #6 is the problem. Different versions of MySQL have different default charset setting. Known Causes: The two key fields type and/or size doesn’t match exactly. For example, if one is INT(10) the key field needs to be INT(10) as well and not INT(11) or TINYINT. You may want to confirm the field size using SHOW CREATE TABLE because Query Browser will sometimes visually show just INTEGER for both INT(10) and INT(11). You should also check that one is not SIGNED and the other is UNSIGNED(我就是這里出錯的,被引用表的字段為unsigned,而引用表中為signed). They both need to be exactly the same. (More about signed vs unsigned here). One of the key field that you are trying to reference does not have an index and/or is not a primary key. If one of the fields in the relationship is not a primary key, you must create an index for that field. (thanks to Venkatesh and Erichero and Terminally Incoherent for this tip) The foreign key name is a duplicate of an already existing key. Check that the name of your foreign key is unique within your database. Just add a few random characters to the end of your key name to test for this. (Thanks to Niels for this tip) One or both of your tables is a MyISAM table. In order to use foreign keys, the tables must both be InnoDB. (Actually, if both tables are MyISAM then you won’t get an error message – it just won’t create the key.) In Query Browser, you can specify the table type. You have specified a cascade ON DELETE SET NULL, but the relevant key field is set to NOT NULL. You can fix this by either changing your cascade or setting the field to allow NULL values. (Thanks to Sammy and J Jammin) Make sure that the Charset and Collate options are the same both at the table level as well as individual field level for the key columns. (Thanks to FRR for this tip) You have a default value (ie default=0) on your foreign key column (Thanks to Omar for the tip) One of the fields in the relationship is part of a combination (composite) key and does not have it’s own individual index. Even though the field has an index as part of the composite key, you must create a separate index for only that key field in order to use it in a constraint. (Thanks to Alex for this tip) You have a syntax error in your ALTER statement or you have mistyped one of the field names in the relationship (Thanks to Christian & Mateo for the tip) The name of your foreign key exceeds the max length of 64 chars. (Thanks to Nyleta for the tip) The MySQL documentation includes a page explaining requirements for foreign keys. Though they don’t specifically indicate it, these are all potential causes of errno 150. If you still haven’t solved your problem you may want to check there for deeper technical explainations.If you run into this error and find that it’s caused by something else, please leave a comment and I’ll add it to the list.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看