今天在看
Java5+Eclipse視窗應用程式開發-實作進銷存系統(附CD)
看到第十二章在建構MENUREGIST的資料表時,有一個欄位UNIQUEKEY要設成int IDENTITY,糟糕我在SQL 2008 expree裡不會設,只好設成int,後來才了解這跟MySQL的auto_increment是一樣的功能,我try了好幾次的alter table MENUREGIST alter column UNIQUEKEY IDENTITY(1,1) …之類的好幾種不同變更IDENTITY的可能語法,結果都錯了,只好放棄了,重建吧,還好資料還沒進去!
語法如下:
CREATE TABLE [dbo].[MENUREGIST](
[MENUNAME] [varchar](12) NOT NULL,
[MENUDESC] [varchar](36) NOT NULL,
[APPLDESC] [varchar](60) NOT NULL,
[MENUORFUNC] [varchar](2) NOT NULL,
[STARTUSE] [varchar](1) NOT NULL,
[DESCMARK] [varchar](60) NULL,
[UNIQUEKEY] [int] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_MENUREGIST] PRIMARY KEY CLUSTERED
(
[UNIQUEKEY] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]