超级灵气txt,站脚背书,怎样重装win7系统
有时候有些 sql 语句有些不太记得了,谨以此文备忘。
设置主键以及自增长可分两种情况:
创建表 sql:
create table [dbo].[testtable]( [id] bigint primary key identity(1,1), [extra] nvarchar(max), [createdat] datetime not null default(getdate()), [updatedat] datetime not null default(getdate()) );
其中 primary key
用来表明 id
字段是主键,而 identity(1,1)
则为 id
字段设置自增长,且从1开始,每次自增1
如果需要设置自增长的字段已经存在,则需要先删除,可参考以下 sql 语句
alter table dbo.testtable drop column id
然后再新增,新增的时候设置 identity
设置自增,可参考以下 sql
alter table dbo.testtable add id bigint identity(1,1) not null
最后设置主键
alter table dbo.testtable add constraint prim_id primary key(id)
contact me:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (上)
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (下)
网友评论