|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Mysql Syntax
I have a single table and trying to get the hang of building tables in dia and them exporting them to mysql. I can't get a single table to go over and am not sure what I am doing wrong. It comes down to sql syntax that is created by tedia2sql (based on what I put in the uml model). Here is what I get:
tiadia2sql output: create table contacts ( id int default 10 not null, firstname varchar default 40 NULL, lastname varchar default 40, created datetime, modified datetime, constraint pk_Contacts primary key (id) ) ; When I try and run it I get: SQL query: CREATE TABLE contacts( id int default 10 NOT NULL , firstname varchar default 40 NULL , lastname varchar default 40, created datetime, modified datetime, CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); MySQL said: #1064 - 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 'default 40 NULL, lastname varchar default 40, created ' at line 3 Does anyone know how I can fix this? I know that I am not putting the info into the uml correctly but am not sure what and how to correct. Also I am using phpmyadmin is there a better tool for running the scripts that are created. Thanks |
|
|
Re: Mysql SyntaxThere is certainly an error in the tedia2sql output. As the error
message indicates, the NULL as part of the firstname column definition should not be there. Additionally the default clauses are definitely confusing. Do you really want those, or are they just artifacts of tedia2sql being confusing? What *should* the script look like? Mike Robert Fulcher wrote: > I have a single table and trying to get the hang of building tables in > dia and them exporting them to mysql. I can't get a single table to go > over and am not sure what I am doing wrong. It comes down to sql syntax > that is created by tedia2sql (based on what I put in the uml model). > Here is what I get: > > tiadia2sql output: > > create table contacts ( > id int default 10 not null, > firstname varchar default 40 NULL, > lastname varchar default 40, > created datetime, > modified datetime, > constraint pk_Contacts primary key (id) > ) ; > > When I try and run it I get: > > *SQL query:* > > CREATE TABLE contacts( > > id int default 10 NOT NULL , > firstname varchar default 40 NULL , > lastname varchar default 40, > created datetime, > modified datetime, > CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); > > > > *MySQL said: *Documentation > <http://dev.mysql.com/doc/refman/5.0/en/error-returns.html> > > #1064 - 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 'default 40 NULL, > lastname varchar default 40, > created ' at line 3 > > > Does anyone know how I can fix this? I know that I am not putting the > info into the uml correctly but am not sure what and how to correct. > Also I am using phpmyadmin is there a better tool for running the > scripts that are created. > > Thanks --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Mysql SyntaxRobert,
I created a very simple diagram that covers the basic schema you have shown below. I think you wanted to make the columns varchar(40) (variable character fields with a maximum length of 40). To do that you simply specify the length in parentheses as part of the datatype. Mike Robert Fulcher wrote: > I have a single table and trying to get the hang of building tables in > dia and them exporting them to mysql. I can't get a single table to go > over and am not sure what I am doing wrong. It comes down to sql syntax > that is created by tedia2sql (based on what I put in the uml model). > Here is what I get: > > tiadia2sql output: > > create table contacts ( > id int default 10 not null, > firstname varchar default 40 NULL, > lastname varchar default 40, > created datetime, > modified datetime, > constraint pk_Contacts primary key (id) > ) ; > > When I try and run it I get: > > *SQL query:* > > CREATE TABLE contacts( > > id int default 10 NOT NULL , > firstname varchar default 40 NULL , > lastname varchar default 40, > created datetime, > modified datetime, > CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); > > > > *MySQL said: *Documentation > <http://dev.mysql.com/doc/refman/5.0/en/error-returns.html> > > #1064 - 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 'default 40 NULL, > lastname varchar default 40, > created ' at line 3 > > > Does anyone know how I can fix this? I know that I am not putting the > info into the uml correctly but am not sure what and how to correct. > Also I am using phpmyadmin is there a better tool for running the > scripts that are created. > > Thanks --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Mysql SyntaxIn MySQL you can't just declare a column "varchar" it must have a max length. Try "varchar(64)" or whatever length you think is maximal.
-- timeless(ness) |
|
|
Re: Mysql Syntax
Mike,
Thanks I will give it a try tonight. I did not put in the default key word and am not sure how I got them in there. Thanks for the help. On Fri, 2007-03-09 at 11:37 -0500, Mike Ginou wrote: Robert, I created a very simple diagram that covers the basic schema you have shown below. I think you wanted to make the columns varchar(40) (variable character fields with a maximum length of 40). To do that you simply specify the length in parentheses as part of the datatype. Mike Robert Fulcher wrote: > I have a single table and trying to get the hang of building tables in > dia and them exporting them to mysql. I can't get a single table to go > over and am not sure what I am doing wrong. It comes down to sql syntax > that is created by tedia2sql (based on what I put in the uml model). > Here is what I get: > > tiadia2sql output: > > create table contacts ( > id int default 10 not null, > firstname varchar default 40 NULL, > lastname varchar default 40, > created datetime, > modified datetime, > constraint pk_Contacts primary key (id) > ) ; > > When I try and run it I get: > > *SQL query:* > > CREATE TABLE contacts( > > id int default 10 NOT NULL , > firstname varchar default 40 NULL , > lastname varchar default 40, > created datetime, > modified datetime, > CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); > > > > *MySQL said: *Documentation > <http://dev.mysql.com/doc/refman/5.0/en/error-returns.html> > > #1064 - 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 'default 40 NULL, > lastname varchar default 40, > created ' at line 3 > > > Does anyone know how I can fix this? I know that I am not putting the > info into the uml correctly but am not sure what and how to correct. > Also I am using phpmyadmin is there a better tool for running the > scripts that are created. > > Thanks --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Mysql Syntax> I did not put in the default key word and am not sure how I got them in there.
tedia2sql puts it there automatically when you place unrecognized values in the value field. Examples of recognized values are "not null" and "auto_increment". Anything that tedia2sql doesn't recognize as a valid keyword for a column is interpreted as being the column's default value. > > Thanks for the help. > > > On Fri, 2007-03-09 at 11:37 -0500, Mike Ginou wrote: >> Robert, >> >> I created a very simple diagram that covers the basic schema you have >> shown below. >> >> I think you wanted to make the columns varchar(40) (variable character >> fields with a maximum length of 40). To do that you simply specify the >> length in parentheses as part of the datatype. >> >> Mike >> >> Robert Fulcher wrote: >> > I have a single table and trying to get the hang of building tables in >> > dia and them exporting them to mysql. I can't get a single table to go >> > over and am not sure what I am doing wrong. It comes down to sql syntax >> > that is created by tedia2sql (based on what I put in the uml model). >> > Here is what I get: >> > >> > tiadia2sql output: >> > >> > create table contacts ( >> > id int default 10 not null, >> > firstname varchar default 40 NULL, >> > lastname varchar default 40, >> > created datetime, >> > modified datetime, >> > constraint pk_Contacts primary key (id) >> > ) ; >> > >> > When I try and run it I get: >> > >> > *SQL query:* >> > >> > CREATE TABLE contacts( >> > >> > id int default 10 NOT NULL , >> > firstname varchar default 40 NULL , >> > lastname varchar default 40, >> > created datetime, >> > modified datetime, >> > CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); >> > >> > >> > >> > *MySQL said: *Documentation >> > <http://dev.mysql.com/doc/refman/5.0/en/error-returns.html> >> > >> > #1064 - 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 'default 40 NULL, >> > lastname varchar default 40, >> > created ' at line 3 >> > >> > >> > Does anyone know how I can fix this? I know that I am not putting the >> > info into the uml correctly but am not sure what and how to correct. >> > Also I am using phpmyadmin is there a better tool for running the >> > scripts that are created. >> > >> > Thanks >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... <mailto:users-unsubscribe@...> >> For additional commands, e-mail: users-help@... <mailto:users-help@...> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Mysql Syntax
Mike,
Thanks for the info. Everything is working fine now. The tool works really well. Thanks On Fri, 2007-03-09 at 14:55 -0500, Mike Ginou wrote: > I did not put in the default key word and am not sure how I got them in there. tedia2sql puts it there automatically when you place unrecognized values in the value field. Examples of recognized values are "not null" and "auto_increment". Anything that tedia2sql doesn't recognize as a valid keyword for a column is interpreted as being the column's default value. > > Thanks for the help. > > > On Fri, 2007-03-09 at 11:37 -0500, Mike Ginou wrote: >> Robert, >> >> I created a very simple diagram that covers the basic schema you have >> shown below. >> >> I think you wanted to make the columns varchar(40) (variable character >> fields with a maximum length of 40). To do that you simply specify the >> length in parentheses as part of the datatype. >> >> Mike >> >> Robert Fulcher wrote: >> > I have a single table and trying to get the hang of building tables in >> > dia and them exporting them to mysql. I can't get a single table to go >> > over and am not sure what I am doing wrong. It comes down to sql syntax >> > that is created by tedia2sql (based on what I put in the uml model). >> > Here is what I get: >> > >> > tiadia2sql output: >> > >> > create table contacts ( >> > id int default 10 not null, >> > firstname varchar default 40 NULL, >> > lastname varchar default 40, >> > created datetime, >> > modified datetime, >> > constraint pk_Contacts primary key (id) >> > ) ; >> > >> > When I try and run it I get: >> > >> > *SQL query:* >> > >> > CREATE TABLE contacts( >> > >> > id int default 10 NOT NULL , >> > firstname varchar default 40 NULL , >> > lastname varchar default 40, >> > created datetime, >> > modified datetime, >> > CONSTRAINT pk_Contacts PRIMARY KEY ( id ) ); >> > >> > >> > >> > *MySQL said: *Documentation >> > <http://dev.mysql.com/doc/refman/5.0/en/error-returns.html> >> > >> > #1064 - 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 'default 40 NULL, >> > lastname varchar default 40, >> > created ' at line 3 >> > >> > >> > Does anyone know how I can fix this? I know that I am not putting the >> > info into the uml correctly but am not sure what and how to correct. >> > Also I am using phpmyadmin is there a better tool for running the >> > scripts that are created. >> > >> > Thanks >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... <mailto:users-unsubscribe@...> >> For additional commands, e-mail: users-help@... <mailto:users-help@...> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |