View Full Version : mysql primary key
02-28-2007, 10:04 AM
A primary key in ORACLE implies unique and not null, implies u cannot leave the column empty during an insert. In mysql, a column defined as a primary key accepts if nothing is inserting into that column during an insert, for the first time. The next time the same is performed(ie., leaving the primary key column empty), it is violation of primary key constraint.
That is, mysql's definition of primary key implies only unique but not NOT NULL. Wat do i do to have a column both unique and notnull?
02-28-2007, 03:16 PM
When you leave it out an empty string is entered. That is not the same thing at all as NULL. so even if you declared it as a NOT NULL column, you can still leave it empty on the first insertion.
03-05-2007, 10:30 PM
when I create a table in phpmyadmin I'd swear one of the choices in the pull down menu is "not null"
Maybe I'm thinking of something else
03-06-2007, 12:42 AM
there is a choice of NOT NULL because you can make a column NOT NULL. and you can create the column as UNIQUE.
An empty string can still be entered in the table once because an empty string isn't NULL. On the second insertion of an empty string though you won't be able to do it because an empty string exists.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.