|
|
|
|
![]() ![]() |
Nov 22 2007, 05:43 AM
Post
#1
|
|
|
|||[ n00b King ]||| ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 592 Joined: 20-June 07 From: Auckland Member No.: 45,102 |
Can anyone clarify what the value in int() actually does?
CODE CREATE TABLE job_class ( jc_id int(1) NOT NULL AUTO_INCREMENT PRIMARY KEY, jc_index int(2) NOT NULL, jc_name varchar(20) NOT NULL, jc_type varchar(20) NOT NULL ); I was under the impression that any integer value used inside a () was the limit that data-type would have. In the PRIMARY KEY column I was able to add integer values 1-18. I'm kinda confused now If I can add 2 digit integers there then what is the point of assigning values inside brackets() For the varchar() any number put in there does limit the character allowed. e.g 'test' inserted into varchar(2) would result in 'te' This post has been edited by sonesay: Nov 22 2007, 06:01 AM |
|
|
|
Dec 10 2007, 08:35 PM
Post
#2
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 22 Joined: 1-April 07 From: Spain Member No.: 40,913 |
Check this out:
QUOTE As an extension to the SQL standard, MySQL also supports the integer types TINYINT, MEDIUMINT, and BIGINT. The following table shows the required storage and range for each of the integer types. Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). This optional display width is used to display integer values having a width less than the width specified for the column by left-padding them with spaces. The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters. When used in conjunction with the optional extension attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004. Note that if you store larger values than the display width in an integer column, you may experience problems when MySQL generates temporary tables for some complicated joins, because in these cases MySQL assumes that the data fits into the original column width. Source: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html Note: SQL INT supports -2147483648 to 2147483647 range. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 14th May 2008 - 12:15 AM |