You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL REFERENCES关键字语法错误求助(MySQL/PostgreSQL均复现)

Troubleshooting the Syntax Error Near references Personne(id_personne))

Hey there! Let's work through this syntax error you're hitting in both MySQL and PostgreSQL—since it's popping up across two databases, the issue is almost certainly a universal syntax mistake rather than a DB-specific quirk.

Common Causes to Check

  • Extra closing parenthesis
    The error points directly to )) at the end of that line, which means you’ve probably added an extra ) where it doesn’t belong. For example, when defining a foreign key in a CREATE TABLE statement, the correct syntax only needs one closing parenthesis after the referenced column:

    -- Correct
    CREATE TABLE YourTable (
        id INT PRIMARY KEY,
        personne_id INT,
        FOREIGN KEY (personne_id) REFERENCES Personne(id_personne)
    );
    

    A super common slip-up is tacking on an extra ) like this:

    -- Incorrect (extra closing parenthesis)
    CREATE TABLE YourTable (
        id INT PRIMARY KEY,
        personne_id INT,
        FOREIGN KEY (personne_id) REFERENCES Personne(id_personne)) -- Extra ) here
    );
    
  • Misplaced foreign key definition
    Double-check that your foreign key clause is properly nested inside the main table definition parentheses. If you accidentally close the table definition before adding the foreign key, or mix up the order of clauses, it’ll trigger a syntax error.

  • Typos in table/column names (less likely here)
    While this usually throws a "table/column not found" error instead of a syntax issue, it’s worth verifying that Personne and id_personne exactly match the actual names in your database (note PostgreSQL is case-sensitive if you used quoted identifiers when creating the table).

Next Step

If you can share the full SQL code you’re running, it’ll be even easier to pinpoint the exact issue—but based on the error message, that extra closing parenthesis is the most probable culprit.

内容的提问来源于stack exchange,提问作者user7732640

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:25:40