Home > Database > Mysql Tutorial > body text

sql server创建复合主键的2种方法

WBOY
Release: 2016-06-07 17:55:00
Original
1399 people have browsed it

sql server创建复合主键的2种方法,需要的朋友可以参考一下

创建复合主键:

方法一:创建表之后,alter table table_name add primary key(字段1,字段2)

方法二:CREATE TABLE 表名 (字段名1 Int Not Null,
字段名2 nvarchar(13) Not Null
字段名3…………
字段名N…………)
GO

ALTER TABLE 表名 WITH NOCHECK ADD
CONSTRAINT [PK_表名] PRIMARY KEY NONCLUSTERED
(
[字段名1],
[字段名2]
)
GO
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!