我试图自动增加我的主键,每次增加 0.1。从 0.1 开始。这可能吗?
CREATE TABLE NewTable
(
ID BigInt IDENTITY NOT NULL,
CONSTRAINT PK_ID PRIMARY KEY (ID),
)
我试图自动增加我的主键,每次增加 0.1。从 0.1 开始。这可能吗?
CREATE TABLE NewTable
(
ID BigInt IDENTITY NOT NULL,
CONSTRAINT PK_ID PRIMARY KEY (ID),
)
不,BigInt 是一个 8 字节的integer
值。注意:假设为 Microsoft SQL Server。
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)
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.
一些解决方案将是一个视图:
CREATE VIEW v_NewTable AS
SELECT ID/10
FROM NewTable