主键或其他列以更好的方式 [英] Primary key or other column for better way

查看:69
本文介绍了主键或其他列以更好的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,

I have a table that is about title of invoice , 
i have a primary key that starts from 1 for my invoice i need a special number , i mean every invoice must have special number ,now tell me which one is more reasonable ?
you think if i add a column and name it SpecialNumber and with it give the numbers to my invoice titles ?
or i should use primary key?

It must be like that go up one by one ,
and sometimes start might change somewhere.

For example:

1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , ( I will change it ) , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57





我尝试过:



我需要找到更好的方法而且我还没找到任何东西



What I have tried:

I need to find better way and i didn't find anything yet

推荐答案

一般来说,税务机关不喜欢看到发票号码的差距:他们倾向于怀疑你是否隐藏数据(以及他们可以从口袋中强行取出的钱)。



我建议你您使用IDENTITY列 - 这意味着每次插入行时SQL都会保留数字并为您增加数量。尽管可以通过IDENTITY列强制更改编号,但这并不容易 - 这意味着除非您有充分的理由这样做,否则您的数字会让税务员满意。

使用IDENTITY列作为PRIMARY KEY也是一个好主意。
Generally speaking, tax authorities do not like to see gaps in invoice numbers: they tend to suspect that you are hiding data (and thus money they could forcibly remove from your pocket) from them.

I would suggest that you use an IDENTITY column - this means that SQL will maintain the number and increment it for you each time you INSERT a row. And while it is possible to force a change in the numbering with an IDENTITY column, it isn't easy - and that means your numbers will keep the taxman happy unless you have a damn good reason to do it.
Using the IDENTITY column as the PRIMARY KEY is also a good idea.


这篇关于主键或其他列以更好的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆