|
Home >> FAQs/Tutorials >> MySQL Tutorials
MySQL Tutorial - Violation of Unique Value Constraint
By: FYIcenter.com
(Continued from previous topic...)
What Happens If Unique Value Constraints Are Violated?
If you are inserting a new record that has values violating a unique constraint,
you will get an error. Note that primary key column has a unique value constraint by default.
The following tutorial exercise gives you some good examples:
mysql> INSERT INTO fyi_links (url) VALUES ('www.other.com');
ERROR 1062 (23000): Duplicate entry '0' for key 1
mysql> INSERT INTO fyi_links VALUES (101,
'sql.fyicenter.com',
NULL,
0,
'2006-04-30');
ERROR 1062 (23000): Duplicate entry '101' for key 1
(Continued on next topic...)
- What Are DML Statements?
- How To Create a Testing Table?
- How To Insert a New Row into a Table?
- How To Specify Default Values in INSERT Statement?
- How To Omit Columns with Default Values in INSERT Statement?
- What Happens If Unique Value Constraints Are Violated?
- How To Insert Multiple Rows with One INSERT Statement?
- How To Update Values in a Table?
- How To Update Column Values on Multiple Rows?
- How To Use Existing Column Values in the SET Clause?
- Is the Order of Columns in the SET Clause Important?
- How To Use Values from Other Tables in UPDATE Statements?
- What Happens If the UPDATE Subquery Returns No Rows?
- What Happens If the UPDATE Subquery Returns Multiple Rows?
- How To Delete an Existing Row from a Table?
- How To Delete Multiple Rows from a Table?
- How To Delete All Rows in a Table?
|