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
121
votes
6 answers

What is the difference between BIT and TINYINT in MySQL?

In which cases would you use which? Is there much of a difference? Which I typically used by persistence engines to store booleans?
carrier
  • 32,209
  • 23
  • 76
  • 99
103
votes
5 answers

BOOLEAN or TINYINT confusion

I was designing a database for a site where I need to use a boolean datetype to store only 2 states, true or false. I am using MySQL. While designing the database using phpMyAdmin, I found that I have both the BOOLEAN datatype and the TINYINT…
Bipin Chandra Tripathi
  • 2,550
  • 4
  • 28
  • 45
40
votes
4 answers

MySQL Boolean "tinyint(1)" holds values up to 127?

I wanted to make a true/false field for if an item is in stock. I wanted to set it to Boolean ( which gets converted to tinyint(1) ), 1 for in stock, 0 for not in stock. I am getting feeds from vendors, so I thought to myself, "What if they pass how…
JD Isaacks
  • 56,088
  • 93
  • 276
  • 422
33
votes
8 answers

Which is faster: char(1) or tinyint(1) ? Why?

MY PLATFORM: PHP & mySQL MY SITUATION: I came across a situation where I need to store a value for user selection in one of my columns of a table. Now my options would be to: Either declare the Column as char(1) and store the value as 'y' or 'n' Or…
Devner
  • 6,825
  • 11
  • 63
  • 104
31
votes
5 answers

TINYINT vs ENUM(0, 1) for boolean values in MySQL

Which one is better, Tinyint with 0 and 1 values or ENUM 0,1 in MyISAM tables and MySQL 5.1?
Wiliam
  • 3,714
  • 7
  • 36
  • 56
18
votes
3 answers

enum('yes', 'no') vs tinyint -- which one to use?

What's the best practice for fields that hold true/false values? Such columns can be defined as enum('yes','no') or as tinyint(1). Is one better/faster than the other? Is it better to use enum('1','0') vs. enum('yes','no') (i.e., does it write 'yes'…
Yasin Ergul
  • 452
  • 1
  • 5
  • 13
17
votes
4 answers

How to create a column of type tinyint(2) or tinyint(3) in Ruby on Rails?

In Ruby on Rails, the following code in a migration creates a column of type tinyint(4) in MySQL: create_table :great_table do |t| t.integer :step_position, :limit => 1 #tinyint end How would I create a column of type tinyint(2) or tinyint(3)?
maxedison
  • 17,243
  • 14
  • 67
  • 114
12
votes
4 answers

SQL: Is it efficient to use tinyint instead of Integer if my max value is 255?

Lets assume I want to save the count of datagrid rows which can be max. 24 because each row is 1 hour. To save the row index in the database a tinyint field would be totally enough. But back in my mind I remember slightly that databases are…
msfanboy
  • 5,273
  • 13
  • 69
  • 120
12
votes
5 answers

Change tinyint default value into 1 mysql

I have a status column in my database table. Type : tinyint(4) and the Default value is 0. I want to change the default value to 1. How to do that? May be this is a very simple question, but I don't know.
Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80
10
votes
3 answers

How do I retrieve a data type of tinyint from MySQL in C#?

So in C# whenever I retrieved a tinyint from my MSSQL database I used the following cast. (int)(byte)reader["MyField"]; However, that cast doesn't seem to work in MySQL. What I have tried (byte)reader["MyField"]; and just…
Steven Combs
  • 1,890
  • 6
  • 29
  • 54
8
votes
2 answers

What does tinyint(3) mean in (SQLite) SQL?

I realize that tinyint is a single byte integer (by the way, is it signed or unsigned?). What does the argument (3) signify? I've searched and couldn't find the answer.
mk12
  • 25,873
  • 32
  • 98
  • 137
7
votes
1 answer

Limit the value of a MySQL datatype to a specific range (preferably not ENUM)

I want to limit the datatype value that can be stored within a field to a specific range of integer values: [0,10]. On user input within a PHP script I validate and sanitise the data to make sure it is within the range 0 to 10. However, is there a…
leokennedy
  • 583
  • 1
  • 8
  • 17
7
votes
1 answer

Incorrect mapping of mysql tinyint(2) as boolean with doctrine

I reverse engineered my database with symfony2 and doctrine with commands : php app/console doctrine:mapping:convert php app/console doctrine:mapping:import php app/console doctrine:generate:entities But my field was mapped as boolean instead of…
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
6
votes
0 answers

How do I convert a MySQL function result to tinyint(1)

Here's the problem. In MySQL's Connector/NET a TINYINT(1) field properly translates back and forth into a .NET bool value. If I select from a table with a TINYINT(1) column, everything is golden. However, when you use built-in MySQL v5.0 functions…
Kasey Speakman
  • 4,511
  • 2
  • 32
  • 41
5
votes
1 answer

"Treat Tiny As Boolean" and Entity Framework 4

I have a situation where I need to treat TINYINT in a MySQL database as a numeric value and not as TRUE / FALSE. From what I understand, the MySQL .Net Connector use to map TINYINT as Byte. Unfortunately for me it seems that this is no longer the…
mlindegarde
  • 395
  • 5
  • 19
1
2 3 4 5 6 7