0

HI,
I am new to mysql i want to know why mysql have autoincrement with keys..

Is their possible to declare only auto increment to a column.

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by harry_watson
0

Good Question, Any sql will be having only one primary key for one table, if you want to make another keys, you can add unique keys to the columns and you can make it as a primary(with 2 or more columns).

If we use auto_increment in MySQL, it assumes the column as a Primary Key and asks us to add Primary Key to that column.

0

Hi,
Thanks for u r response.

when we declare a column as auto increment in a table. Sql requier to specify a primary key or any key for that column.If i not specify a key for auto increment an error message gets appeared.

Y this error happens in sql.Can u explain it.

Thanks once again.
prem..

0

The 'key' is there to 'unlock' all other fields in the table. It 'auto increments' with a 'unique id' so that records are kept separate and tidy and so that you can access and refer to and update specific records.

0

a key or primary key is required for anything that is 'auto incremented'
so you can 'unlock' the rest of the table. The field should be called
something like "table_id" and use "auto increment" and be "primary key"
or you will get errors for sure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.