简体   繁体   English

如何命名SQL FOREIGN KEY约束,将两个表列创建为关系表

[英]How to name SQL FOREIGN KEY Constraint on CREATE two tables columns into a relationship TABLE

i was just wondering if there is a way to name a foreign key on create table 我只是想知道是否有一种方法可以在创建表上命名外键

FOREIGN KEY (uuid) REFERENCES employee(uuid));

i tried to do this and name my foreign key as fk1 but i've got syntax errors 我试图这样做,并将我的外键命名为fk1,但是语法错误

FOREIGN KEY fk1 (uuid) REFERENCES employee(uuid));

error 错误

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is com.jda.cloudsql.common.MigrationException: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException:

  FOREIGN KEY FK1[*] (UUID) REFERENCES EMPLOYEE(UUID)) "; expected "("; SQL statement:

你可以写:

ADD CONSTRAINT `customized_foreign_key_name` FOREIGN KEY (`uuid`) REFERENCES `employee` (`uuid`)

暂无
暂无

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

相关问题 如何在 SQL 的一个表中使用两个相同的外键命名连接表中的两列? - How to name two columns in join tables with two same foreign key at one table in SQL? 在不知道 Informix 中的外键名称的情况下删除两个表的列之间的外键约束? - Drop a foreign key constraint between columns of two tables without knowing the foreign key name in Informix? 是否可以在Laravel的String / varchar类型的列的两个表之间创建外键关系? - Is it possible to create a foreign key relationship between two tables on String/varchar type columns in Laravel? 如何修复“java.sql.SQLException:无法添加外键约束”。 创建具有双主/外键关系的表时 - How to fix "java.sql.SQLException: Cannot add foreign key constraint." when creating table with double primary/foreign key relationship 如何在两个表中建立外键关系 - how to make FOREIGN KEY Relationship in Two table 如何在与外键和主键没有相同字段的两个表之间创建关系 - How to create relationship between two tables which have no same field as foreign key and primary key 一个表中两列之间的外键关系 - Foreign Key relationship between two columns in one table 创建两个具有相同主键的子类型(或子)表,该主键也是父表的外键 sql - Create Two Subtype (or child) tables with same primary key which is also a foreign key to the parent table sql 如何创建两个与外键链接的表 - How to create two tables linked with foreign key 无法创建表“外键约束格式不正确” SQL - Can't create table “Foreign Key constraint is incorrectly formed” SQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM