Comments on: The difference between a unique index and primary key in MySQL http://www.xaprb.com/blog/2009/09/12/the-difference-between-a-unique-index-and-primary-key-in-mysql/ Stay curious! Thu, 02 May 2013 12:36:53 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Pankaj http://www.xaprb.com/blog/2009/09/12/the-difference-between-a-unique-index-and-primary-key-in-mysql/#comment-19387 Pankaj Tue, 24 May 2011 07:51:13 +0000 http://www.xaprb.com/blog/?p=1276#comment-19387 what will happen if I will give only KEY while creating the table, in that case there won’t be any primary key?

]]>
By: Rob Wultsch http://www.xaprb.com/blog/2009/09/12/the-difference-between-a-unique-index-and-primary-key-in-mysql/#comment-16966 Rob Wultsch Sun, 13 Sep 2009 07:26:17 +0000 http://www.xaprb.com/blog/?p=1276#comment-16966 I (unfortunately) have used 3.23 quite a bit. A primary key was UNIQUE NOT NULL back then as it is now. I think in early version that might not have been the case.

Given that null does not describe a value so much as an unknown value:
mysql> select ‘Null equals Null’ from dual where null=null;
Empty set (0.00 sec)

mysql> select ‘Null does not equals Null’ from dual where null!=null;
Empty set (0.00 sec)

I don’t have a problem with how unique is used in RDMS, but then again I am in the pro-null camp. Perhaps I should seek psychiatric evaluation?

]]>
By: Roland Bouman http://www.xaprb.com/blog/2009/09/12/the-difference-between-a-unique-index-and-primary-key-in-mysql/#comment-16963 Roland Bouman Sat, 12 Sep 2009 22:52:46 +0000 http://www.xaprb.com/blog/?p=1276#comment-16963 Hi!

It’s worth pointing out that although it seems counterintuitive, this conforms to the SQL standard. It works exactly like this in Oracle.

I am not sure about the 3.23 behaviour, but as long as i have been using MySQL, it allows DDL like this:

CREATE TABLE T (a int, b int, primary key(a,b))

Now the strange thing is that a and b appear nullable, but when you do a SHOW CREATE TABLE T, they turn out to be not nullable – this is automatic smarts that one may or may not like (it actually occurs even if you explcitly declare the columns as NULL)

kind regards,

Roland

]]>