创建表时指定PK名称
在 MSSQL 中,有一种方法可以指定 PK 约束的名称,这样 MSSQL 就不会提供随机生成的 PK 名称,如下所示:
PK__Addresse__3214EC074E88ABD4
我现在能看到的唯一方法是首先创建表,然后发出 ALTER命令重命名 PK。如果我能一次性完成的话会更容易。
In MSSQL is there a way to specify a name for a PK constraint so that MSSQL doesn't provide a randomly generated PK name like so:
PK__Addresse__3214EC074E88ABD4
The only way I can see to do it now is to first create the table and then issue an ALTER command to rename the PK. It would be easier if I could do it in one shot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。以下是 SSMS 生成的语法:
Yes. Here's the syntax which SSMS generates:
创建表时
如果您需要更改表并添加主要约束
希望这会有所帮助
At the time of table creation
If you need to alter the table and add a Primary Constraint
Hope this helps