Data type: Difference between revisions

Jump to navigation Jump to search
2,854 bytes added ,  4 November 2025
m
 
(6 intermediate revisions by the same user not shown)
Line 32: Line 32:
參考資料
參考資料
* [http://support.microsoft.com/kb/208427 最大 URL 長度是在 Internet Explorer 中的 2,083 字元] for {{IE}}<ref>[http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers http - What is the maximum length of a URL in different browsers? - Stack Overflow]</ref><ref>[http://wiert.me/2010/04/20/maximum-url-lengths/ Maximum URL lengths « The Wiert Corner – irregular stream of stuff]</ref>
* [http://support.microsoft.com/kb/208427 最大 URL 長度是在 Internet Explorer 中的 2,083 字元] for {{IE}}<ref>[http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers http - What is the maximum length of a URL in different browsers? - Stack Overflow]</ref><ref>[http://wiert.me/2010/04/20/maximum-url-lengths/ Maximum URL lengths « The Wiert Corner – irregular stream of stuff]</ref>
=== Email ===
* data type:
** MySQL: {{kbd | key=VARCHAR(254)}}<ref>[https://www.rfc-editor.org/rfc/rfc5321 RFC 5321: Simple Mail Transfer Protocol]"4.5.3.1.3.  Path The maximum total length of a reverse-path or forward-path is 256 octets (including the punctuation and element separators)." Complete address in SMTP envelope (including {{kbd | key=<nowiki><...></nowiki>}})</ref>
* 遵循 [https://www.rfc-editor.org/rfc/rfc5321 RFC 5321: Simple Mail Transfer Protocol] 規格


=== 姓名欄位 ===
=== 姓名欄位 ===
Line 80: Line 85:


=== 雜湊碼 (hash value) e.g. MD5, SHA ===
=== 雜湊碼 (hash value) e.g. MD5, SHA ===
'''Hash Algorithm Output and Schema Reference'''
<ref>[https://en.wikipedia.org/wiki/Secure_Hash_Algorithms Secure Hash Algorithms - Wikipedia]</ref>
<table border="1" class="wikitable sortable" style="border-collapse: collapse; width: 100%;">
      <tr style="background-color: #f2f2f2;">
          <th style="text-align: left;">Algorithm</th>
          <th style="text-align: left;">Output Size (bits)</th>
          <th style="text-align: left;">Max Length (chars)</th>
          <th style="text-align: left;">Schema Recommendation (Text)</th>
          <th style="text-align: left;">Schema Recommendation (Binary)</th>
      </tr>
      <tr>
          <td>MD5</td>
          <td>128</td>
          <td>32</td>
          <td>char(32)</td>
          <td>binary(16)</td>
      </tr>
      <tr>
          <td>SHA-1</td>
          <td>160</td>
          <td>40</td>
          <td>char(40)</td>
          <td>binary(20)</td>
      </tr>
      <tr>
          <td>SHA-224</td>
          <td>224</td>
          <td>56</td>
          <td>char(56)</td>
          <td>binary(28)</td>
      </tr>
      <tr>
          <td>SHA-256</td>
          <td>256</td>
          <td>64</td>
          <td>char(64)</td>
          <td>binary(32)</td>
      </tr>
      <tr>
          <td>SHA-384</td>
          <td>384</td>
          <td>96</td>
          <td>char(96)</td>
          <td>binary(48)</td>
      </tr>
      <tr>
          <td>SHA-512</td>
          <td>512</td>
          <td>128</td>
          <td>char(128)</td>
          <td>binary(64)</td>
      </tr>
</table>
Explain the conversion process from 224 bits to 56 characters for SHA-224's output. Conversion process:
* Original output: 224 bits
* '''Text Representation (Hexadecimal)''': Every 4 bits converts to 1 hexadecimal character (hex character): 224 ÷ 4 = 56 Therefore, it requires 56 hexadecimal characters to represent
* '''Binary Storage Representation''': Every 8 bits equals 1 byte in binary storage: 224 ÷ 8 = 28 Therefore, it requires 28 bytes (binary(28)) to store efficiently
[https://zh.wikipedia.org/wiki/MD5 MD5]: {{exclaim}} Not recommended to use this function to secure passwords
[https://zh.wikipedia.org/wiki/MD5 MD5]: {{exclaim}} Not recommended to use this function to secure passwords
* Data type: CHAR(32) or VARCHAR(32)<ref>[https://stackoverflow.com/questions/14922208/can-i-use-varchar32-for-md5-values php - Can I use VARCHAR(32) for md5() values? - Stack Overflow]</ref>
* Data type: CHAR(32) or VARCHAR(32)<ref>[https://stackoverflow.com/questions/14922208/can-i-use-varchar32-for-md5-values php - Can I use VARCHAR(32) for md5() values? - Stack Overflow]</ref>
Line 127: Line 193:
* MySQL: [https://dev.mysql.com/doc/refman/8.0/en/hexadecimal-literals.html Hexadecimal Literals] e.g. {{kbd | key=<nowiki>SELECT HEX(UNHEX(SHA2('The quick brown fox jumped over the lazy dog.', 256)));</nowiki>}}<ref>[https://stackoverflow.com/questions/14608413/storing-a-binary-sha1-hash-into-a-mysql-binary20-column insert - Storing a binary SHA1 hash into a mySQL BINARY(20) column - Stack Overflow]</ref>
* MySQL: [https://dev.mysql.com/doc/refman/8.0/en/hexadecimal-literals.html Hexadecimal Literals] e.g. {{kbd | key=<nowiki>SELECT HEX(UNHEX(SHA2('The quick brown fox jumped over the lazy dog.', 256)));</nowiki>}}<ref>[https://stackoverflow.com/questions/14608413/storing-a-binary-sha1-hash-into-a-mysql-binary20-column insert - Storing a binary SHA1 hash into a mySQL BINARY(20) column - Stack Overflow]</ref>


=== GUID 全域唯一識別碼字串 ===
=== UUID 通用唯一辨識碼、GUID 全域唯一識別碼字串 ===
[https://zh.wikipedia.org/zh-tw/%E5%85%A8%E5%B1%80%E5%94%AF%E4%B8%80%E6%A0%87%E8%AF%86%E7%AC%A6 全域唯一識別碼 - 維基百科,自由的百科全書]
[https://zh.wikipedia.org/zh-tw/%E9%80%9A%E7%94%A8%E5%94%AF%E4%B8%80%E8%AF%86%E5%88%AB%E7%A0%81 通用唯一辨識碼 - 維基百科,自由的百科全書]、[https://zh.wikipedia.org/zh-tw/%E5%85%A8%E5%B1%80%E5%94%AF%E4%B8%80%E6%A0%87%E8%AF%86%E7%AC%A6 全域唯一識別碼 - 維基百科,自由的百科全書]
* BINARY(16)<ref>[https://stackoverflow.com/questions/412341/how-should-i-store-guid-in-mysql-tables How should I store GUID in MySQL tables? - Stack Overflow]</ref>
* BINARY(16)<ref>[https://stackoverflow.com/questions/412341/how-should-i-store-guid-in-mysql-tables How should I store GUID in MySQL tables? - Stack Overflow]</ref>
* VARCHAR(36) or CHAR(36)
* VARCHAR(36) or CHAR(36)
Line 158: Line 224:


=== 台灣公司統一編號 ===
=== 台灣公司統一編號 ===
統一編號 (Unified Business Number, 簡稱 UBN)
* 數值長度:八位數字  
* 數值長度:八位數字  
* 建議資料類型:因為可能以 0 開頭,所以建議使用 {{kbd | key= CHAR(8)}},而不建議使用 {{kbd | key= INT(8)}} <ref>[https://www.etax.nat.gov.tw/etwmain/web/ETW113W1_1 公示資料查詢服務-財政部稅務入口網]</ref><ref>[http://herolin.webhop.me/entry/is-valid-TW-company-ID/ » 營利事業統一編號驗證完全手冊(Javascript,Java,C#,PHP) - Hero Think~用手摀住我的嘴]</ref> {{exclaim}} 早期公司統一編號不是八位數字
* 建議資料類型:因為可能以 0 開頭,所以建議使用 {{kbd | key= CHAR(8)}},而不建議使用 {{kbd | key= INT(8)}} <ref>[https://www.etax.nat.gov.tw/etwmain/web/ETW113W1_1 公示資料查詢服務-財政部稅務入口網]</ref><ref>[http://herolin.webhop.me/entry/is-valid-TW-company-ID/ » 營利事業統一編號驗證完全手冊(Javascript,Java,C#,PHP) - Hero Think~用手摀住我的嘴]</ref> {{exclaim}} 早期公司統一編號不是八位數字
Line 239: Line 307:




[[Category:Web_Dev]] [[Category:Database]] [[Category:MySQL]] [[Category:Data Science]]
[[Category: Web_Dev]]  
[[Category: Database]]  
[[Category: MySQL]]  
[[Category: Data Science]]
[[Category: Revised with LLMs]]

Navigation menu