首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关键字"references“出现sql错误

关键字"references“出现sql错误
EN

Stack Overflow用户
提问于 2018-02-28 03:48:14
回答 1查看 34关注 0票数 0

我希望你们能帮帮我。下面是我正在尝试执行的一些SQL代码。

代码语言:javascript
复制
create table Personne (
id_personne serial primary key, 
nom text not null, 
prenom text not null, 
email text not null);

create table Ressource (
id_ressource serial primary key, 
nom_r text not null, 
url text not null,  
id_personne int not null, foreign key references Personne(id_personne));

我得到一个类似于“语法错误附近的‘参考人员(Id_personne))’行5的错误。

我不知道它是从哪里来的。我去了W3school.com,据我所知,我写的是正确的。但它就是不起作用。

任何形式的帮助都将不胜感激!

PS :我在MySql和Postgresql上试过,结果是一样的。

EN

回答 1

Stack Overflow用户

发布于 2018-02-28 03:52:14

您忘了输入列名

代码语言:javascript
复制
create table Ressource (
id_ressource serial primary key, 
nom_r text not null, 
url text not null,  
id_personne int not null, 
foreign key(id_personne) references Personne(primary_key_from_personne));
            ^^^^^^^^^^^^^^^^ 
            (you missed it)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49016803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档