The TINYINT
data type is an integer value from 0 to 255.
TINYINT
is the smallest integer data type and only uses 1 byte of storage.
An example usage of TINYINT
is a person's age since no person reaches the age of 255.
A table with a TINYINT
column.
CREATE TABLE DemoTable
(
Id INT IDENTITY,
Name VARCHAR(100),
Age TINYINT
);
GO
INSERT INTO DemoTable VALUES ('Anna', 32);
INSERT INTO DemoTable VALUES ('Carlos', 19);
INSERT INTO DemoTable VALUES ('Marlon', 55);
INSERT INTO DemoTable VALUES ('Kelly', 41);
INSERT INTO DemoTable VALUES ('Martha', NULL);
GO
SELECT * FROM DemoTable;
GO
DROP TABLE DemoTable;
GO
Id | Name | Age |
---|---|---|
1 | Anna | 32 |
2 | Carlos | 19 |
3 | Marlon | 55 |
4 | Kelly | 41 |
5 | Martha | NULL |
CREATE TABLE DemoTable
(
MyBigInt BIGINT,
MyInt INT,
MySmallInt SMALLINT,
MyTinyInt TINYINT
);
GO
INSERT INTO DemoTable VALUES (9223372036854775807, 2147483647, 32767, 255);
GO
SELECT * FROM DemoTable;
GO
DROP TABLE DemoTable;
GO
MyBigInt | MyInt | MySmallInt | MyTinyInt |
---|---|---|---|
9223372036854775807 | 2147483647 | 32767 | 255 |