0

我试图自动增加我的主键,每次增加 0.1。从 0.1 开始。这可能吗?

CREATE TABLE NewTable
 (
ID    BigInt    IDENTITY    NOT NULL, 
CONSTRAINT PK_ID PRIMARY KEY (ID),
  )
4

4 回答 4

1

不,BigInt 是一个 8 字节的integer值。注意:假设为 Microsoft SQL Server。

于 2013-03-03T20:58:06.780 回答
0

No, even if you changed the data type of the field, the identity increment 'must be a non-zero integral number containing 18 digits or less' (Presuming this is sql server)

于 2013-03-03T21:05:13.560 回答
0

In SQL Server, the Identity column cannot contain decimal values in its seed or increment.

Why would you need to do this -- for presentation purposes? If so, don't. If needed, one option is to create a trigger. You could also consider using a Computed column instead -- make it 1/10 the value of the Id (your Identity field seeded and incremented at 1 -- Identity(1,1)).

Again, not sure why you'd need to do this though.

于 2013-03-03T21:06:14.447 回答
0

一些解决方案将是一个视图:

CREATE VIEW v_NewTable AS
SELECT ID/10
FROM NewTable
于 2013-03-03T21:45:45.710 回答