vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, Please help in the following problem: I have successfully created a table 'directions': CREATE TABLE directions ( normalized_pattern varchar(12) primary key, name varchar(40) ); CREATE UNIQUE INDEX PRIMARY ON directions (normalized_pattern); Then I want to create a table 'calls' using the first table: CREATE TABLE calls ( call_unique_id int primary key, normalized_number varchar(17), normalized_pattern varchar(12) CONSTRAINT fk_directions FOREIGN KEY directions (normalized_pattern) REFERENCES directions (normalized_pattern), call_type tinyint, from_gg bool, .... ); The problem is that I receive the following message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synatx to use near 'CONSTRAINT fk_directions FOREIGN KEY directions (normalized_pattern) REFE' at line 6 I have little experience but I think I used syntax for CREATE TABLE from MySQL Reference. Could you tell me please what's wrong. Thank you! RAM |
| |||
| On 2 Aug, 10:34, RAM <r_ahims...@poczta.onet.pl> wrote: > Hello, > Please help in the following problem: > I have successfully created a table 'directions': > > CREATE TABLE directions > ( > normalized_pattern varchar(12) primary key, > name varchar(40) > ); > CREATE UNIQUE INDEX PRIMARY ON directions (normalized_pattern); > > Then I want to create a table 'calls' using the first table: > > CREATE TABLE calls > ( > call_unique_id int primary key, > normalized_number varchar(17), > normalized_pattern varchar(12) > CONSTRAINT fk_directions > FOREIGN KEY directions (normalized_pattern) > REFERENCES directions (normalized_pattern), > call_type tinyint, > from_gg bool, > ... > ); > > The problem is that I receive the following message: > > You have an error in your SQL syntax; check the manual that corresponds > to your MySQL server version for the right synatx to use near > 'CONSTRAINT fk_directions FOREIGN KEY directions (normalized_pattern) > REFE' at line 6 > > I have little experience but I think I used syntax for CREATE TABLE from > MySQL Reference. Could you tell me please what's wrong. > Thank you! > RAM The SYNTAX doesn't have a table name after FOREIGN KEY See: http://dev.mysql.com/doc/refman/5.0/...nstraints.html |
| ||||
| > The SYNTAX doesn't have a table name after FOREIGN KEY > See: > http://dev.mysql.com/doc/refman/5.0/...nstraints.html > Thank you! |