- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AUTO_INCREMENT in MySQL can be signed by default?
Yes, the AUTO_INCREMENT in MySQL will be signed (Positive and Negative Value both) by default.
Let us first create a table −
mysql> create table DemoTable -> ( -> MyNumber int AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.45 sec)
Insert some records in the table using insert command. Here, we have set negative values as well for AUTO_INCREMENT column −
mysql> insert into DemoTable values() ; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(-100); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(-300); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(0); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----------+ | MyNumber | +----------+ | -300 | | -100 | | 1 | | 2 | +----------+ 4 rows in set (0.00 sec)
Advertisements