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

關于選擇數據類型

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

問題描述

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

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 個字節,但在 SQL Server 中最多可以將 8 個 BIT 字段合并為一個 BYTE.
  • 存儲兩個值之一:1(表示真)和 0(表示假),因此該列需要可以為空,以便 NULL 作為您的第三個值傳遞
    • 占用 1 個字節
    • ASCII 不區分大小寫為 26 個字符,區分大小寫為 52 個字符
    • 占用 1 個字節
    • 值從 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 是您想要通過外鍵關聯的表中的主鍵的不錯選擇,并且將描述性文本存儲在另一列中.

    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 個區分大小寫的值)——人工/代理鍵與描述更改隔離.

    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.

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

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
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屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 国产电影一区二区 | 岛国在线免费观看 | 免费黄色av网站 | 国产精品区二区三区日本 | 欧美xxxⅹ性欧美大片 | 欧美三级久久久 | 久久国产精品视频 | 日日摸夜夜爽人人添av | 噜久寡妇噜噜久久寡妇 | 欧美成人h版在线观看 | www日韩| 欧美一区中文字幕 | 国产美女精品视频 | 亚洲国产欧美在线人成 | 国产视频1区2区 | 精品国产乱码久久久久久蜜柚 | 99综合| 日韩在线一区二区 | 精品久久1| 日韩中文一区二区三区 | 男人午夜视频 | 激情三区| 无码日韩精品一区二区免费 | 亚洲精品一区二区三区免 | 成人午夜电影在线观看 | 日韩高清一区 | 亚洲一二三区在线观看 | 亚洲午夜av久久乱码 | 国产高清不卡 | 久久av一区二区三区 | 在线看免费| 欧美影院 | 在线不卡视频 | 成人精品一区二区三区中文字幕 | 久久新视频 | 国产精品成人一区二区 | 九九九视频在线 | 久久专区 | 免费观看一级视频 | 成年视频在线观看福利资源 | 羞视频在线观看 |