Code: Alles auswählen
mysql> describe kunden;
+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | | |
| vorname | varchar(20) | NO | | | |
+---------+-------------+------+-----+---------+----------------+
3 rows in set (0.02 sec)
mysql> describe konten;
+----------+-------------+------+-----+-------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+-------------+-------+
| ID | int(11) | NO | MUL | | |
| ktn_ID | bigint(20) | NO | PRI | | |
| guthaben | float | NO | | 0 | |
| dispo | float | NO | | 0 | |
| datum | date | NO | | | |
| comment | varchar(50) | NO | | neues konto | |
+----------+-------------+------+-----+-------------+-------+
6 rows in set (0.01 sec)
mysql>create table transaktionen
(t_ID int not null auto_increment primary key,
ID int not null, foreign_key fk_ID(ID) references kunden(ID),
ktn_ID int not null, foreign key fk_trans_ktn_ID(ktn_ID) references konten(ktn_ID),
trans_rec int not null, foreign key fk_trans_rec(trans_rec) references konten(ktn_ID),
trans_value float not null default 0,
trans_date datetime not null,
trans_comment var_char(50) not null,
trans_status boolean not null default false);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fk_ID(ID) references kunden(ID),
ktn_ID int not null, foreign key fk_trans_ktn_' at line 3