简体   繁体   English

SQL:来自其他表列的列的唯一键和外键,该列本身既不是唯一键也不是主键

[英]SQL: Unique and Foreign key of a column from other table's column which itself is neither Unique nor Primary key

I have a column which in neither unique nor primary key in a table.我有一列既不是唯一的也不是表中的主键。 But i want that be be as a foreign key as well as unique in other table column但我希望它作为外键以及在其他表列中是唯一的

eg例如

Table_1 as below which has a column_whichIsNeitherUniqueNorPK Table_1 如下,其中有一个column_whichIsNeitherUniqueNorPK 在此处输入图像描述

Now i have Table_2 which has a column " FK_column_whichIsNeitherUniqueNorPK " in which i want this columns values as Foreign key of above table, and this column should be Unique.现在我有 Table_2,它有一个列“ FK_column_whichIsNeitherUniqueNorPK ”,我希望这些列值作为上表的外键,并且该列应该是唯一的。

在此处输入图像描述

so as per comments, it looks like it is not possible directly as it deviates from relational theory.因此,根据评论,它看起来不可能直接,因为它偏离了关系理论。 For a column to be Foreign key, the other column has to be unique对于要成为外键的列,另一列必须是唯一的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 主键或唯一列上的 SQL 外键 - SQL foreign key on primary key or unique column 使用TSQL如何确定哪一个化合物外键的列对应于化合物主/唯一键的哪一列? - Using tsql how to determine which column of a compound foreign key corresponds to which column of a compound primary/unique key? SQL - 如何从表中获取唯一键的列名 - SQL - How to get the Unique Key's Column Name from Table SQL - 唯一键,主键和外键 - SQL - Unique Key, Primary Key & Foreign Key 如何更新作为组合键的一部分的列,并充当一个表的主键,并作为oracle SQL中其他表的外键 - How to update a column which is part of a composite key and acting as primary key for one table and as a foreign key in other table in oracle SQL 具有外键的表将无法编译(此列列表没有匹配的唯一键或主键) - Table with foreign key won't compile (no matching unique or primary key for this column-list) 此列列表没有唯一键或主键? - No unique or primary key for this column list? 使用另一个表的主键更新外键列 - Update foreign key column with another table's primary key 更改其他表中外键引用的表的主键列 - Changing a table's primary key column referenced by foreign key in other tables 此列列表没有匹配的唯一键或主键:SQL - No matching unique or primary key for this column-list: SQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM