[ic] autonumber with mySQL
racke at linuxia.de
Thu Jan 15 13:44:30 EST 2004
On Thu, 15 Jan 2004 14:16:30 +0000 (UTC)
Jon Jensen <jon at endpoint.com> wrote:
> On Thu, 15 Jan 2004, Stefan Hornburg wrote:
> > > > > Do I have another shot in the dark <g> ? I think you missing NOT NULL for
> > > > > the code column.
> > > >
> > > > Thank you very much for your help Racke and Rene. The NOT NULL was missing.
> > >
> > > I don't see how that can be the case. The MySQL documentation says (and a
> > > quick test creating a table in MySQL verifies):
> > >
> > > > A PRIMARY KEY is a unique KEY where all key columns must be defined as NOT
> > > > NULL. If they are not explicitly declared as NOT NULL, it will be done
> > > > implicitly (and quietly).
> > >
> > > http://www.mysql.com/doc/en/CREATE_TABLE.html
> > mysql> create table foo (bar int, primary key(bar));
> > ERROR 1171: All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
> > MySQL 3.
> But that syntax is not what he used. He was using the normal single-column
> primary key syntax:
> create table foo (bar int primary key);
> The more verbose syntax is mostly intended for multi-column keys, where
> some columns are allowed to be nullable, so IMO it makes sense there that
> it requires explicit NOT NULL designation.
Yes, you are right. Thanks for coaching :-)
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team
More information about the interchange-users