SQL创建了[id] [int] IDENTITY(1,1) NOT NULL,为什么还不能自动增长ID

youmar 2009-04-05 02:17:10
请在我代码上写修改的SQL代码。并说出为什么,我有很多表,不能一个一个的从新建,请写出修改方法和代码,写的详细我会多加分的。

这是我的代码:
USE [exhi_Travel]
GO
/****** 对象: Table [dbo].[tbl_user] 脚本日期: 04/05/2009 02:09:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tbl_user](
[id] [int] IDENTITY(1,1) NOT NULL,
[uid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[pwd] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
[email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[username] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[cardid] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[tel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[qq] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[add] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[ip] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[mark] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[zcdate] [datetime] NULL,
[delpic] [int] NULL,
CONSTRAINT [PK_tbl_user] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
...全文
1161 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
语法没问题
htl258_Tony 2009-04-05
  • 打赏
  • 举报
回复
SET ANSI_NULLS ON 
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tbl_user](
[id] [int] IDENTITY(1,1) NOT NULL,
[uid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
[pwd] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
[email] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[username] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[cardid] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[tel] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[qq] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[add] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[ip] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[mark] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[zcdate] [datetime] NULL,
[delpic] [int] NULL,
CONSTRAINT [PK_tbl_user] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

insert [tbl_user] ([uid],[pwd]) values(1,223)
insert [tbl_user] ([uid],[pwd]) values(2,213)

select * from [tbl_user]

id uid pwd email username cardid tel qq add ip mark zcdate delpic
----------- -------------------- -------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ----------------------- -----------
1 1 223 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
2 2 213 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL

(2 行受影响)
我测试ID是会自动增长的。

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧