dolthub / dolthub/dolt

`REFERENCES` keyword does not work in a column definition

Open
#6,125 1 comment 0 reactions 1 assignee Claimed by @zachmu View on GitHub
bug customer issue sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

As part of a MySQL [column definition](https://dev.mysql.com/doc/refman/8.0/en/create-table.html), you can specify a foreign key reference, e.g.: `myFk int REFERENCES othertable(id)`, but this syntax doesn't currently work in Dolt. Dolt allows defining FK references, but they can't be in a column definition, they need to be listed at the end in a `CONSTRAINT FOREIGN KEY` clause.

Repro:
```
create table child (pk int primary key, fk int REFERENCES parent(id));
Error parsing SQL
syntax error at position 58 near 'REFERENCES'
create table child (pk int primary key, fk int REFERENCES parent(id))
```

In addition to testing this with `CREATE TABLE`, we also need to make sure to test this with `ALTER TABLE`, too.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.