We are Web Technology Experts Team who provide you Important information on Web Development, Interview Questions and Answers, live project problem and their solution and online free tutorials.
Friday, 9 January 2015
Thursday, 8 January 2015
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 2269548 for key PRIMARY
Following are few reasons with solutions:
Reason 1:
ID is auto-increment and primary key. id is auto filed when an record is insert.
When we try to insert record with same id which is already exist in table, then such type of error comes.
SOLUTION:
So, write SQL in following ways.
Reason 2:
When table is used to frequent insertion of records, like we are storing db logs for each action. Sometimes, it have thousand of thousands records, and field(like id) limit cross the limit. SOLUTION: Increase the limit of id field.
Reason 1:
ID is auto-increment and primary key. id is auto filed when an record is insert.
When we try to insert record with same id which is already exist in table, then such type of error comes.
SOLUTION:
So, write SQL in following ways.
INSERT INTO users (name) VALUES ('name1'); //skip the id field which is auto-increment
Reason 2:
When table is used to frequent insertion of records, like we are storing db logs for each action. Sometimes, it have thousand of thousands records, and field(like id) limit cross the limit. SOLUTION: Increase the limit of id field.
ALTER TABLE `users` CHANGE `id` `id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
Reason 3:
When table is used to frequent insertion of records, like we are storing db logs for each action.Sometimes, it have thousand of thousands records, and table goes to overhead. SOLUTION: Execute following queryOPTIMIZE TABLE `users`
Best Related Posts are Following:
- DBMS Interview Questions and Answers for Freshers.
- MySQL Interview Questions and Answers for Experienced.
- Difference between inner join and outer join in MySQL.
- How to get a list of MySQL user accounts?.
- How to delete MySQL Binary logs Files in Wamp Server?.
- SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 2269548 for key PRIMARY.
- Multiple column ordering in Zend Framework.
- Mysql Privileges - Types of privileages in MySql - How do I grant privileges in MySQL.
- Difference Between Primary Key And Unique Key And Foreign Key And Composite Key.
- Difference Between MyISAM and innoDB - MySQL.
- MySQL Functions - MySQL tutorial for beginners.
- mysqlsubqueries examples Scalar Subqueries Row Subqueries Column Subqueries Table Subqueries.
- Mysql FullText Search Examples.
- MySQL Constraint Example.
- MySQL Cascade Example.
- Mysql-Group-Concat.
- MySQL Expressions.
- MySQL Delete Table Example.
- Replace Table - Update Field, Move Records to another table MySQL.
- mysql insert syntax - Add records from another table - Copy Table from one table to another.
- Mysql Update Syntax - Update Multiple Records.
- What is Mysql.
- Mysql Console Commands - Export and Import database from command line.
- MySQL interview Questions and Answers For Experienced.
Subscribe to:
Posts
(
Atom
)