Unique columns

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
taldos
Forum Commoner
Posts: 39
Joined: Mon Aug 23, 2004 8:47 am
Location: Philadelphia

Unique columns

Post by taldos »

Quick question regarding 'unique' in mysql.

By Declaring a column unique, does this translate to mean that no given data can ever be duplicated even if that data is removed.

The reason I ask is because I was looking to mysql to make sure an email column was never duplicated (laziness on my part). However after a couple hours of error messages, I have come to the previous tentative conclusion.

if I enter 'noname@hello.com' into an column labeled unique. I later decide to delete this row and enter the name again. Given that the column is unique, should this work or not. If not Guess will have to do a manual verification.

Thx. :wink:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not test it?

From what I remember, the data in the column is unique within the given instance of time the record was added. So a deleted record will not affect the creation of a new record.
taldos
Forum Commoner
Posts: 39
Joined: Mon Aug 23, 2004 8:47 am
Location: Philadelphia

Post by taldos »

I tried and failed which is the reason I thought I'd ask here. Probably an error somewhere else then.

thx. :)
Post Reply