
怎样在sql中把主键值设成是自动加1
或者用语句也行,谢谢大家了stringstrSql="Insertintoz_GoodsInfo(Goods_ID,Goods_name,Type_typeID,Good...
或者用语句也行,谢谢大家了
string strSql = "Insert into z_GoodsInfo(Goods_ID,Goods_name,Type_typeID,Goods_addDate) values (............'" + strName + "','" + strType + "','" + DateTime.Now + "');"; 展开
string strSql = "Insert into z_GoodsInfo(Goods_ID,Goods_name,Type_typeID,Goods_addDate) values (............'" + strName + "','" + strType + "','" + DateTime.Now + "');"; 展开
4个回答
展开全部
1、如果你用的是SQL Server数据库,在你设计库表时把Goods_ID字段的数据类型设置为Int,在下面的标识中选择“是”,在标识种子中输入“1”,在标识递增量中输入“1”。这样你的这个Goods_ID字段就可以自动增加1了。
2、如果你用的是Access数据库,那才好设置呢,在表中的字段Goods_ID数据类型中选择“自动编号”。
3、如果不是以上两种数据库,那我就帮不上了。
2、如果你用的是Access数据库,那才好设置呢,在表中的字段Goods_ID数据类型中选择“自动编号”。
3、如果不是以上两种数据库,那我就帮不上了。
展开全部
主键值自动加1的方法如下:
create table mytest
(
id int primary key identity(1,1),--主键,自动+1
name varchar(20) unique not null,--不允许重复,不允许为空
Age tinyint,
notetime smalldatetime default getdate()
)
create table mytest
(
id int primary key identity(1,1),--主键,自动+1
name varchar(20) unique not null,--不允许重复,不允许为空
Age tinyint,
notetime smalldatetime default getdate()
)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
自动加1,要数据库支持,要不就插入前先select max goods_ID
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select max(id)+1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询