Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / May 2004

Tip: Looking for answers? Try searching our database.

MySQL SQL Syntax

Thread view: 
Graham Kendall - 07 May 2004 16:46 GMT
Hi,

I am trying to alter the columns within an existing table to change them so
they do not accept NULL values.

I have tried using the sql statement:    ALTER TABLE tbltwptcsvehicle MODIFY
Vehicle_ID NOT NULL;

but that generates error 1064, I don't know what is the correct SQL.

Help much appreciated

Graham Kendall
Murray - 07 May 2004 18:25 GMT
> Hi,
>
[quoted text clipped - 9 lines]
>
> Graham Kendall

You have to specify the type as well, e.g.

ALTER TABLE tbltwptcsvehicle MODIFY Vehicle_ID int NOT NULL;
Bill Karwin - 07 May 2004 19:08 GMT
> I am trying to alter the columns within an existing table to change them so
> they do not accept NULL values.
> I have tried using the sql statement:
> ALTER TABLE tbltwptcsvehicle MODIFY Vehicle_ID NOT NULL;

In reading http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html, it
appears that the alter table syntax doesn't support changing solely the
nullability of a column.  You must supply a column definition, including
the datatype and any other attributes.

For example:
ALTER TABLE tbltwptcsvehicle MODIFY Vehicle_ID VARCHAR(20) NOT NULL
PRIMARY KEY;

The datatype and other attributes can be identical to their previous
definition (I'm guessing at the datatype in your case).

Regards,
Bill K.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.