主键: PRIMARY KEY 约束唯一标识数据库表中的每条记录。 主键必须包含唯一的值。 主键列不能包含 NULL 值。 每个表都应该有一个主键,并且每个表只能有一个主键 只增列: alter table talbeName Add ColumnName Int IDENTITY(1,1) 再插入数据时,不能插入自增列,有系统自动产生 如: create table test ( id int identity(1,1), name char(10) ) id就是自增列 插入数据时 只能 insert into test(name)values('小李') select *from test 的到得结果就是 id name 1 小李 下面就是错误的 insert into test(id,name)values('23','小李')