如何创建自动生成列 [英] How to create autogenerate column

查看:136
本文介绍了如何创建自动生成列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一列,该列在sql 2005中的表设计时具有自动生成的值.

I want to add a column which has autogenerate value at design time of table in sql 2005

推荐答案


要将列的标识值设置为是".
Hi,
To set the identity value of the column as YES.


请参阅:
http://www.w3schools.com/sql/sql_autoincrement.asp [ http://www.sqlteam.com/article/custom-auto-genic- sequence-with-sql-server [ ^ ]
refer:
http://www.w3schools.com/sql/sql_autoincrement.asp[^]

http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^]


自动生成的列的数据类型始终为Interger.
如果您有表并且只想添加列,则运行以下查询

Auto generated column has datatype as Interger always.
if you have table and you just want to add column then run the following Query

alter table TABLENMAE add COLUMNNAME int identity(1,1)



身份是列的自动递增,1是自动递增的种子.



where identity is for the autoincrement of column and 1 is the autoincrement seed.


这篇关于如何创建自动生成列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆