Questions tagged [tinyint]

tinyint is one of the Exact number data types that use integer data.

Integer data from 0 through 255. Storage size is 1 byte.

Type    Storage     Minimum Value   Maximum Value
        (Bytes)   (Signed/Unsigned) (Signed/Unsigned)

TINYINT   1          -128             127

Reference

101 questions
5
votes
1 answer

MySQL TINYINT(1) versus BIT(1)

Please enlighten me... Which data type consumes the smallest, TINYINT(1) or BIT(1)? I know that TINYINT(1) and BIT(1) is considered the same according to majority of answers here. Doesn't TINYINT(1) accepts 0-9 while BIT(1) can only 1 or 0. From the…
gptimajo
  • 139
  • 1
  • 13
5
votes
1 answer

Appropriate data field type for true/false value?

What's the most appropriate (read least data consuming) data field to store a true/false/1/0 value in a mySQL database? I have previously used a one character long tinyint, but I am not sure if it's the best solution? Thanks!
Industrial
  • 41,400
  • 69
  • 194
  • 289
5
votes
3 answers

Use TinyInt to hide/show controls?

I have 6 buttons on my GUI. The visibility of the buttons can be configured via checkboxes. Checking the checkbox and saving means the correpsonding button should be shown. I am wondering if it is somehow possible to have one TinyInt column in the…
grady
  • 12,281
  • 28
  • 71
  • 110
5
votes
2 answers

Why can't tinyint store more than the number 255 in MySQL?

If TINYINT can store three characters, for example, why can't it store up to the number 999?
Mohamad
  • 34,731
  • 32
  • 140
  • 219
4
votes
2 answers

Changing from tinyint to smallint with a database full of data

A peace of mind question really. I have a field in my database that uses tinyint(3) as the integer value. I've now realised that this is to low a value and want to change it to smallint. If I change this using phpMyAdmin, will any of the current…
Jay
  • 83
  • 2
  • 9
4
votes
1 answer

MySQL: Two digit 0...53 - use TINYINT(2) or another approach?

I need to store a field in a MySQL TABLE which will only have numbers from 0 to 53. The numbers will never be less than 0 or more than 53. What gives better performance and is the most efficient way to store these? TINYINT(2) TINYINT(2) UNSIGNED Or…
Edward
  • 9,430
  • 19
  • 48
  • 71
3
votes
3 answers

MySQL: storing several boolean values in one column. One tinyint(4) -vs- several tinyint(4)

I need to store 5 boolean values in 1 table. Each value could be stored as tinyint(4). So, there are 5 tinyint(4). I'm thinking of putting 5 boolean values in one tinyint(4). I believe, everybody knows even better than me, 5 bits could be saved in 1…
Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
3
votes
1 answer

MySQL tinyint to boolean

So I have a tinyint datatype column in my database where I store values from 0 to 2. It is my understanding that MySQL treats any non-zero number in a tinyint column as true (in this case 1 and 2) and the 0 as false. However, when I perform a query…
dmc4
  • 39
  • 1
  • 3
3
votes
4 answers

Does it make a difference in SQL Server whether to use a TinyInt or Bit? Both in size and query performance

I have a table that has 124,387,133 rows each row has 59 columns and of those 59, 18 of the columns are TinyInt data type and all row values are either 0 or 1. Some of the TinyInt columns are used in indexes and some are not. My question will it…
3
votes
1 answer

asp.net mvc linq sql problem

I am working on a project using asp.net mvc 2 and linq to sql. The problem occurs when trying to insert data into a table where the table has an identity column type of tinyint. When trying to insert the following error occurs: The primary key…
Suneesht
  • 33
  • 3
3
votes
1 answer

How can a javax.persistence.Column be defined as an Unsigned TINYINT?

I am creating a Java Persistence Entity Bean (with NetBeans IDE 8.0.1) based on an existing table in a MySQL database. I've come across a field in this table which is of type "Unsigned TINYINT(3)". I have found that the following can be done to…
PJvG
  • 1,310
  • 3
  • 16
  • 33
3
votes
4 answers

Is there an advantage on setting tinyint fields when I know that the value will not exceed 255?

Should I choose the smallest datatype possible, or if I am storing the value 1 for example, it doesn't matter what is the col datatype and the value will occupy the same memory size? The question is also, cuz I will always have to convert it and…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
2
votes
1 answer

What is the utility of tinyint(M) in MySQL?

This is more of an academic question. In a MySQL database, I know tinyint(M) and its differences from tinyint(1) have already been discussed on this site, but I'm wondering something else. Could a column "REVIEWED TINYINT(5) be used to store the…
agerber85
  • 63
  • 5
2
votes
1 answer

How to convert TINYINT(1) to BOOLEAN in express?

I have some columns (infected and absence) in my MySQL database that are stored as TINYINT(1). When I do a simple app.get("/users", (req, res) => { const sql = `SELECT * from users`; connection.query(sql, (err, results) => { if (err) { …
Nick Rick
  • 75
  • 6
2
votes
0 answers

MariaDB: Multiple joins and where clause searching for 1 in TINYINT Column not working

I have tables called person and book and image and bookhit. Person has id, name and Book has id, owner_id, info and Image has a column for id, owner_id, url and thumbnail which is a TINYINT (In the database half the rows are 0s and 1s.) By the way,…
gglasses
  • 826
  • 11
  • 30