Jump to content

create foreign key (MariaDB) - read manuals still not working


roberto68

Recommended Posts

I need to create a foregin key in table pictures that references id from table locations - locations.id - I chcek mariaDB manuals https://mariadb.com/kb/en/mariadb/foreign-keys/ but it says I have error in my syntax still here's my code

alter table pictures(add column location_id int not null, foreign key(location_id) references locations (id) on delete cascade on update restrict)

what am I doing wrong? and one more question : how to create index in MariaDB cause I haven't been successfull in that too, thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...