更改主键的名称,该主键是另一个表的外键 [英] change name of the primary key which is a foreign key for another table

查看:293
本文介绍了更改主键的名称,该主键是另一个表的外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我有一个列名称StudentId.它是某些表的主键和外键.现在,我想更改主键的名称,例如AdmissionNumber.可以更改这个名字吗?
谢谢

Hi friends
I have a column name StudentId. Its a primary key and foreign key for some tables. Now I want to change the name of the Primary key like AdmissionNumber. Is it possible to change this name?
Thank you

推荐答案

我不建议更改现有表的列名.

要更改列名,您将必须删除外键,删除主键约束,更不用说所有索引都建立在主键上了.然后,您将更改列名并重建删除的所有内容.

问题,为什么您需要更改列名,并且可以使用别名来更改列名?
I do not recommend changing an existing table column name.

To change the column name you would have to drop the foreign key, drop the primary key constraint, not to mention all indexes as they are built on the primary key. You would then change the column name and rebuild everything you dropped.

Question, why do you need to change the column name and access to the column can change the name using alias?


删除现有键并在更改列名后重新创建,但是我不会
推荐.

谢谢,
Ambesha
Drop the existing key and recreate after changing the column name , but i will not
recommend.

Thanks,
Ambesha


这篇关于更改主键的名称,该主键是另一个表的外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆