- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Which MySQL Data Type can be used to store Negative Number?
You can use TINYINT data type in MySQL to store negative number. Following is the syntax −
CREATE TABLE yourTableName ( yourColumnName TINYINT . . . . N );
Let us first create a table with a column set as type TINYINT −
mysql> create table DemoTable ( Number tinyint ); Query OK, 0 rows affected (0.69 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(-10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(-128); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(128); ERROR 1264 (22003): Out of range value for column 'Number' at row 1 mysql> insert into DemoTable values(127); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(-1); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(14); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Number | +--------+ | -10 | | -128 | | 127 | | -1 | | 14 | +--------+ 5 rows in set (0.00 sec)
- Related Articles
- Which MySQL data type is used for long decimal?
- What is to be used to store floats in MySQL?
- Which MySQL datatype to used to store an IP address?
- How can column data be used within MySQL CASE statement?
- What is the best data type to store money values in MySQL?
- The best data type to store 0, 1, null values in MySQL?
- Can a number be used to name a MySQL table column?
- How MySQL use YEAR data type to store year value in a table?
- MySQL isn’t inserting binary data properly? Which datatype should be used?
- Which MySQL query can be used with the help of which we can see the list of MySQL databases?
- If The Ratiinal Number Is An Negative Number So Which Is Its Type
- How can Tensorflow text be used to preprocess text data?
- How can Matplotlib be used to generate time-series data?
- Which MySQL function can be used to append values of a column with single quotes?
- Which punctuation character can be used as the delimiter between MySQL date parts?

Advertisements