MySQL Forums
Forum List  »  Newbie

error 1075
Posted by: Davide Davide
Date: January 18, 2017 06:18PM

good morning everybody.
i'm a real newbie in mysql.

I was just playing with it and I was making some tests and I faced an error I can't solve by myself

CREATE TABLE table1
(
id int auto_increment not null,
caption varchar(255),
primary key (id)
);


create table table2
(
id int,
value_id int auto_increment not null,
value decimal(7,4),
rif_ora TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
primary key (id,value_id),
FOREIGN KEY (id)
REFERENCES table1(id)
ON UPDATE CASCADE ON DELETE RESTRICT
);

well, the error I get is:
Error Code: 1075. Incorrect table definition; there can be only one auto column and it must be defined as a key

Maybe I'm violating some rule, but what I need is exactly what I've written: I need to auto increment on the first table the id and making it as a primary key, then in the second table, refer to that table1.id and make it primary key with another value (value_id), that it has to be auto increment.

I can't understand why that and how to solve it.

If I'm in the right place where to ask this, thank you to the ones will help me

Options: ReplyQuote


Subject
Written By
Posted
error 1075
January 18, 2017 06:18PM
January 18, 2017 08:30PM
January 19, 2017 04:41PM
January 19, 2017 04:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.