Jump to content

Tiny Int


otuatail

Recommended Posts

Still having problems with the int data types

 

The Mysql server states the value in brackets is optional but can be larger tha n required. int() can be int(4) ant tinyint can be tinyint(1), but when I add the field through phpmyadmin it gives me tinyint(4). Also leaving the number out creates an error.

 

Desmond.

 

Link to comment
Share on other sites

My table and page work fine. I am just confused over the values in brackets

 

DROP TABLE IF EXISTS `thread2`;
CREATE TABLE IF NOT EXISTS `thread2` 
(
  `id` int(11) NOT NULL auto_increment,
  `owner_id`  smallint(2) UNSIGNED,
  `CreateDate` int(4) UNSIGNED,
  `UpdateDate` int(4) UNSIGNED,
  `Cat` tinyint(1) UNSIGNED,
  `Visible` tinyint(1) UNSIGNED,
  `Writable` tinyint(1) UNSIGNED,
  `Pinable` tinyint(1) UNSIGNED,
  `View` smallint(2) UNSIGNED,
  `Reply` smallint(2) UNSIGNED,
  `subject` char(200),
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

If Ileave them out I get a table creation error. Also if I add a field tinyint using PHPmyadmin it apears as tinyint(4) not tinyint(1)

 

 

Link to comment
Share on other sites

Confusion! what is the size of a tinyint mysql.com manual states one byte. and can be

tinyint() or tinyint(1). I have used the latter.

PHPmyadmin [Add field to end of table] reveals a structure tinyint(4) //tiny int 4 bytes?

 

And to add more confusion to this. The manual states that not only can you have

smalint(2) but you can have smallint(3). The explanation is not clear but asumes you can exceed the maximum.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.