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

創建我的自定義唯一鍵

Creating my Custom Unique Key(創建我的自定義唯一鍵)
本文介紹了創建我的自定義唯一鍵的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的 SQL Server 中有一個表.目前我使用身份列來唯一標識每條記錄,但我不斷變化的需求需要以特定格式生成的唯一密鑰(由我的客戶指定).我試圖通過將一個唯一的整數(在每次插入時遞增)附加到我的客戶對我當前的解決方案不滿意的指定格式來從我的應用程序生成唯一鍵.如果我能被引導到更好的技術來解決我的問題而不是我當前的解決方案,那就太好了.

I have a table in my SQL Server. Currently I am using the identity column to uniquely identify each record but my changing needs required a unique key generated in a certain format (as specified by my client). I have tried to generate the unique key from my application by appending a unique integer (that is incremented on every insert) to the format specified my client is not satisfied with my current solution. It would be great if I can be directed to a better technique to solve my problem rather then my current solution.

格式如下:

PRN-YEAR-MyAppGeneratedInt

推薦答案

基本上,保留當前的 ??identity 列.這是識別和管理表中行的最佳方式.

Basically, keep the current identity column. That is the best way for you to identify and manage rows in the table.

如果客戶端需要另一個唯一鍵,則添加它.據推測,它將是一個字符串(假設它具有格式").您可以將鍵創建為生成的列.或者,您可能需要使用觸發器來計算它.

If the client needs another unique key, then add it. Presumably, it will be a string (given that it has a "format"). You can possibly create the key as a generated column. Alternatively, you may need to use a trigger to calculate it.

一般來說,整數更適合標識列,即使最終用戶從未看到它們.以下是一些優點:

In general, integers are better for identity columns, even if end users never see them. Here are some advantages:

  • 它們對數據庫中行插入的順序進行編碼.例如,您可以獲取最后插入的行.
  • 它們對于外鍵引用更有效(因為數字是固定長度的并且通常比字符串短).
  • 當需要修復數據時,它們可以直接尋址一行.

這篇關于創建我的自定義唯一鍵的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 | 国产一级特黄真人毛片 | 久久亚洲一区 | 日韩精彩视频 | 国产亚洲精品久久久优势 | 久久久久久久91 | 日韩喷潮| 国产精品毛片久久久久久久 | 午夜午夜精品一区二区三区文 | 免费一级欧美在线观看视频 | 中文字幕免费观看 | 99精品网 | 日韩欧美国产一区二区三区 | 一区二区三区四区在线视频 | 天天操操 | 久国产视频 | 中文字幕乱码一区二区三区 | 韩国av网站在线观看 | 国产日韩欧美一区二区 | 成人欧美一区二区三区黑人孕妇 | 欧美黄色片 | 日韩精品 电影一区 亚洲 | 日韩中文字幕免费在线观看 | 成人黄色在线 | 国产精品无码专区在线观看 | 国内毛片毛片毛片毛片 | 国产高清在线精品一区二区三区 | 成人国产免费观看 | 亚洲欧美国产毛片在线 | 欧美日韩国产精品激情在线播放 | 澳门永久av免费网站 | 国产精品久久久久久久久久久久 | 中文字幕一区二区三区在线观看 | 久久99精品久久久久子伦 | 国产精品美女久久久久久久久久久 | 亚洲国产二区 | 亚洲日韩中文字幕一区 | 国产精品永久免费观看 | 国产在线中文 |