roberto68 Posted February 7, 2015 Share Posted February 7, 2015 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 More sharing options...
justsomeguy Posted February 9, 2015 Share Posted February 9, 2015 You shouldn't have parentheses after the table name in ALTER TABLE. e.g.:alter table pictures add column... Link to comment Share on other sites More sharing options...
roberto68 Posted February 12, 2015 Author Share Posted February 12, 2015 thanks actually there should be parnenthesis but after add column, unlike I get an error alter table pictures add column (location_id int not null, foreign key(location_id) references locations (id) on delete cascade on update restrict); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now