SQL Server中的主键——定义、语法、示例
A primary key is a unique identifier for each record within a table that prevents duplicate values and allows for efficient data retrieval and manipulation. As such, a primary key is one of the...
主键是数据库表中每个记录的唯一标识符,防止重复值并允许高效检索和操作数据。每个表只允许一个主键,主键名称格式为PK_<TableName>,最大长度为900字节,值必须唯一且不允许重复,所有列必须设置为NOT NULL。创建主键还会创建唯一的聚集索引。可以使用ALTER TABLE命令创建、删除和修改主键。主键与唯一键的区别在于主键不允许NULL值,而唯一键可以接受NULL值。
