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

關于選擇數(shù)據(jù)類型

About choosing Data type(關于選擇數(shù)據(jù)類型)
本文介紹了關于選擇數(shù)據(jù)類型的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果在我的表中的一列中,我希望值為 Yes、No 或 Optional,那么我需要使用什么數(shù)據(jù)類型?

If in one of my columns in my Table I want the values as either Yes, No or Optional then what data type do I need to use?

推薦答案

BIT:

  • 占用 1 個字節(jié),但在 SQL Server 中最多可以將 8 個 BIT 字段合并為一個 BYTE.
  • 存儲兩個值之一:1(表示真)和 0(表示假),因此該列需要可以為空,以便 NULL 作為您的第三個值傳遞
    • 占用 1 個字節(jié)
    • ASCII 不區(qū)分大小寫為 26 個字符,區(qū)分大小寫為 52 個字符
    • 占用 1 個字節(jié)
    • 值從 0 到 255

    所有選項占用相同的空間量,使得 JOIN/etc 的性能相當.

    All of the options take the same amount of space, making performance equivalent for JOINs/etc.

    BIT 如果可能的值有任何變化的機會,則不是最明智的選擇.CHAR(1) 是立即可讀的 IE: Y, N, O.TINYINT 是您想要通過外鍵關聯(lián)的表中的主鍵的不錯選擇,并且將描述性文本存儲在另一列中.

    BIT is not the wisest choice if there's any chance of the possible values changing. CHAR(1) is immediately readable IE: Y, N, O. TINYINT is a good choice for the primary key in a table you want to relate via foreign key, and store the descriptive text in another column.

    CHAR(1) 將是我的選擇,否則 TINYINT.
    使用 CHAR(1),自然主鍵是單個字符的可能性很小.如果您有 2 個以上以相同字符開頭的單詞,則假設基于前導字符的自然鍵會失敗,并且如果標簽需要更改,則會導致悲傷,因為鍵也應該更改并永久保留(除非您很懶惰& 喜歡解釋為什么代碼不遵循與其他代碼相同的方案).CHAR(1) 還提供了 TINYINT 所做的大約五分之一的可能性(假設上限為 52 個區(qū)分大小寫的值)——人工/代理鍵與描述更改隔離.

    CHAR(1) would be my choice if not using a foreign key relationship, TINYINT otherwise.
    With CHAR(1), having a natural primary key that is a single character is very unlikely. Assuming a natural key based on the leading character fails if you have 2+ words that start with the same character, and causes grief if the label needs to change because the key should also change and be perpetuated (unless you're lazy & like explaining why a code doesn't follow the same scheme as the others). CHAR(1) also provides roughly a fifth of the possibilities (assuming the upper end, 52 case sensitive values) that TINYINT does -- the artificial/surrogate key insulates from description changes.

    這篇關于關于選擇數(shù)據(jù)類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 不卡日本| 青草导航| 四虎新网址| 亚洲香蕉视频 | 在线中文字幕 | 中文字幕国产一区 | 亚洲最大的网站 | 九九热精品在线观看 | 欧洲色综合 | 日韩毛片网站 | 最近中文字幕在线观看 | 成人午夜网站 | 欧美视频网站 | 老司机午夜免费精品视频 | 国产精品久久久久久无人区 | 亚洲一区精品视频 | 欧美日韩国产成人 | 国产亚洲视频在线观看 | 欧美黑人一区二区三区 | 国产精品久久网 | 日韩欧美在线免费观看 | 免费一级片 | 久久精品一区二区 | 亚洲91在线 | 99精品国产一区二区 | 午夜精品久久久久 | 国产一区在线播放 | 欧美精品二区三区四区免费看视频 | 日韩久久一区 | 国产一级18片视频 | 中文字幕在线看 | 午夜影院在线免费观看 | 四虎影院在线免费观看 | 日韩va| 美女视频一区二区 | 一区二区三区四区国产 | 在线中文字幕 | 少妇一级片 | 91久久精品日日躁夜夜躁欧美 | 91福利视频导航 | 久久久久97 |