- 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
What is the Java equivalent to MySQL's smallint?
The short is equivalent to MySQL’s small int. The Java short takes 2 bytes that has the range -32768 to 32767 while MySQL smallint also take 2 bytes with same range.
Here is the demo code of short in Java −
public class SmallIntAsShortDemo { public static void main(String[] args) { short value = 32767; System.out.println(value); value = -32768; System.out.println(value); // value = 32768; // System.out.println(value); } }
The snapshot is as follows −
This will produce the following output −
32767 -32768
Here is the snapshot of the output we ran in EclipseIDE −
The MySQL smallint takes 2 bytes with same range.
Advertisements