- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What will happen if we have set UNIQUE and multiple insertion with duplicate values
152 Lectures 16 hours
87 Lectures 5.5 hours
An error will arise and nothing will get inserted in the table Let us see an example and create a table −
mysql> create table DemoTable1585 -> ( -> StudentId int, -> StudentMarks int, -> UNIQUE(StudentId) -> ); Query OK, 0 rows affected (1.02 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1585 values(1,87),(2,98),(3,91),(3,48); ERROR 1062 (23000): Duplicate entry '3' for key 'StudentId'
Display all records from the table using select statement −
mysql> select * from DemoTable1585;
This will produce the following output. Nothing gets inserted:
Empty set (0.00 sec)
- What will happen if we directly call the run() method in Java?
- What would happen if we insert empty values in a table with a column set as type TIMESTAMP CURRENT_TIMESTAMP?
- What happen if we concatenate two string literals in C++?
- What do you think will happen if prostitution is made legal in India?
- What happens if I will add a UNIQUE constraint on the same column for multiple times?
- What will happen when we try to override final method of the superclass in Java?
- What would happen if we run SELECT WHERE columnName = zero in MySQL?
- MySQL UNIQUE declaration to avoid inserting duplicate values?
- What will happen if the MySQL AUTO_INCREMENT column reaches the upper limit of the data type?