我想在sql server 2000中创建一个自动增量字段整数 [英] I want to create a auto incremental field integer in sql server 2000
本文介绍了我想在sql server 2000中创建一个自动增量字段整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Everyone,
我需要在sql server 2000的新表中创建一个自动增量字段
这个自动增量字段必须是表格的主键。
我怎么做。
谢谢你的到来!
Leonardo Ayala R.
解决方案
创建一个新表。
添加一个字段,make它是整数,并将Identity设置为true。
例如:
CREATE 表 [dbo]。[MyTable](
[Id] [ int ] IDENTITY ( 1 , 1 ) NOT NULL ,
[UseName] [ nvarchar ]( 50 ) NOT NULL ,
[JoinDate] [ datetime ] NOT NULL ,
[访问次数] [ int ] NOT NULL ,
CONSTRAINT [PK_MyTable] 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 ]
看看http://www.w3schools.com/sql/sql_autoincrement。 ASP
Hello Everyone,
I need I need to create an auto incremental field in my new table in sql server 2000
This auto incremental field must be the primary key of the table.
How I can do it.
Thanks in advence!
Leonardo Ayala R.
解决方案
Create a new table.
Add a field, make it integer, and set Identity to true.
For example:
CREATE TABLE [dbo].[MyTable]( [Id] [int] IDENTITY(1,1) NOT NULL, [UseName] [nvarchar](50) NOT NULL, [JoinDate] [datetime] NOT NULL, [Visits] [int] NOT NULL, CONSTRAINT [PK_MyTable] 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]
Take a look http://www.w3schools.com/sql/sql_autoincrement.asp
这篇关于我想在sql server 2000中创建一个自动增量字段整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文