MySQL中的表的列設置為varchar(0)或char(0)


在MySQL中對表創建的char、varchar列選擇長度時,當使用例如varchar(20)時,在5.0.3版本后表示20個字符。當使用例如varchar(0)時,在MySQL官方參考手冊中是這樣寫的:

MySQL permits you to create a column of type CHAR(0). This is useful primarily when you must be compliant with old applications that depend on the existence of a column but that do not actually use its value. CHAR(0) is also quite nice when you need a column that can take only two values: A column that is defined as CHAR(0) NULL occupies only one bit and can take only the values NULL and '' (the empty string).

大致意思是長度為零的char或varchar表示該列用來兼容舊應用(無須更改業務代碼),可以為NULL或者''只需1bit存儲。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM