Hi,
I am new to mysql.I have two questions.

1)why AUTO_INCREMENT Have primary keys.?
2)Why should we declare default in below example?
(ex)create table test (name varchar(15) not null default '');

Regards,
prem

Hello,

1) I am not sure what you are asking on question 1 unless it is why to you set a primary key to Auto Increment. The answer is so the system will assign the next available integer to the field when the other fields are populated.
Auto Increment (Number/Currency only)
The AUTO INCREMENT attribute can be used to generate a unique identity for new rows. To start with the AUTO INCREMENT value other than 1, you can set that value in Options.


2) You don't have to assign a default value and the user will be forced to put in a value in when adding data because of the 'not null'

TEXT(tinytext, text, mediumtext and longtext) and BLOB(tinyblob, blob, mediumblob and longblob) data type cannot have DEFAULT values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.