Jul 25, 2008

Mysql Datatype Int() Question - Not sure what value to use inside int()

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Database

free web hosting

Mysql Datatype Int() Question - Not sure what value to use inside int()

sonesay
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'

Reply

acantocephala
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.

Notice from rvalkass:

Linking to your source is not enough - you need to put any copied material inside QUOTE tags.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. mysql tinyint mediumint int difference - 69.01 hr back. (1)
  2. mysql int - 70.04 hr back. (1)
Similar Topics

Keywords : mysql, datatype, int, inside, int,

  1. How Do I Find My Mysql Password? [resolved]
    Cannot access my MySQL (5)
  2. Please Explain Me Mysql
    How do i insert information into this config: (4)
    Hi, I wanted to try just to test how can i connect my website to another mysql server, but i have no
    idea how to insert the other mysql information such as port and host etc.... so here is the config
    file please give me an example CODE <?php // mySQL information $server =
    'FRESHSQL.COM:3306';                   // MySql server $username =
    'vasilevich';                      // MySql Username $password =
    '*******';                         // MySql Password $database =
    'vasilevich';                  // MySql Da....
  3. Remote Access Mysql
    (8)
    Is it possible to directly access my local database from my website? For example, if somebody
    submits info on my website, the info they submitted would be transferred to my local database
    directly. Is that possible? And if so, how do I set that up? The reason I don't want to upload
    my database to my subdomain is because it would be difficult to keep the website database and my
    local database in sync . . . or is there a way to do that? Thanks for any replies.....
  4. Create Table - Mysql Code - Help
    (1)
    I need your feedback about setting the database issues. Please, review them and correct some entries
    in the code if they got some mistakes. This is the code itself: SQL CREATE TABLE
    `news` ( `id` int(250) NOT NULL auto_increment, `title` varchar(255)
    NOT NULL default '', `text` text NOT NULL, `author` varchar(255) NOT
    NULL default '', `valid` varchar(255) NOT NULL default '',
    `date` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE = ....
  5. Mysql Error
    (3)
    ok i need some more help from the wonderful coders here at Trap. I'm almost done with my CMS
    script, but i'm having a problem with the installer.php file, when it trys to inseret the user
    data into the database i keep getting the following error: CODE mySQL Error: You have an
    error in your SQL syntax; check the manual that corresponds to your MySQL server version for the
    right syntax to use near ';INSERT INTO `members` (`id`, `name`,
    `username`, `password`, `email`, `title`) ' at lin....
  6. Cd Drive Eject Button Problem
    see inside for explanation (3)
    i have a old dvd burner that is very reliable. the only problem that i have is the eject button on
    that thing is a little busted. i know you can right click to eject it but how can i return it(after
    you put a cd you press that thing to let the cd go inside) it is an old one and you push the cd
    holder like the other one i have. my question is, is there a way to program it or such. because one
    burner program has an option like this and it works. but the program isnt free.....
  7. Mysql
    Several files in one field. (2)
    Hi guys. I want t know if it is posible to have so many entries for one object in a field in MySQL.
    I know my question may not be clear because I lack in terminology but pliz try and help. What I want
    to do is for axample have a database of my clients with the following fields for every client:
    fname, lname, more than one photos, contrubutions(comments, jokes, testimonials posted) etc. I want
    to have the things like the photos in the same field but they have to be unique so that my php code
    can deal with them individually llike they are coming from different fields.....
  8. Html Form!
    Using MySQL?! (4)
    Hey, I need your help again! I need some good working tutorial how I can update my SQL through
    HTML form. I did use some tutorials online found with the help of google; but they do not work
    properly; I mean there are still small mistakes. I need to have a good tutorial to follow. It
    should be based on security and more things. It has to be done in proper way.......
  9. Best Php And Mysql Editor For Noobs
    anyone any php or mysql editor that is good for noob (6)
    hi there guys, from my previous posting, i am a noob in php and mysql programming. I want to know
    if there are any php and mysql editors which are best for me as a noob. i appreciate your kindness
    ....
  10. Php And Mysql Programming
    anyone knows a code for mysql and php (2)
    hi everyone! I am making a program using php and mysql...I am a noob on this so i need your
    help guys...I want to make a simple program that will some values and then store them on a database
    and then retrieve them...uhmm let me give an example out put of what i need. This is the example
    say..: Enter First Name: Enter Last Name:
    Enter Age: Enter Address: ..those
    are the data needed for input values...my question now is how can I make a database....
  11. Mysql, Php, Apache Downloads And Setup Was A Nightmare
    Mysql, PHP, Apache (9)
    Mysql, PHP, Apache downloads were easy enough. Then came the setup process. This seemed to be an
    endless mess of going back and forth trying to get the programs to work together properly. Finaly I
    got them working after about 48 hours. There are great tutorials on the setup process, but only one
    or two actualy were easy enough for me to understand. I would like to see if I was the only one who
    had issues with this setup. Are there easier ways to setup the three?....
  12. The Best Free Php Mysql Blog
    any idea (5)
    Hi everyone Recently i tried to upload a personal blog. as I know a bit of PHP programming I was
    looking for a free open source PHP blog. first I tried Wordpress out but there was few problems
    that i needed to change php.ini or .htaccess file and also some other PHP settings. as i was trying
    it out on a free web host i didn't have access to php.ini. so i have changed it from Wordpress
    to bblog , i have installed it successfully and i followed it's safety instruction (deleting
    install folder and install.php and CHmod config.php )then i got another problem i ....
  13. Mysql-essential-5.0.51 Installion Problem
    please help me.(urgent) (2)
    Dear friend, please help me. Iam working on php project (matchmaking site). I have downloaded mysql
    essensial 5.0.51. When i was installing mysql 5.0.51, i got following error - Error 1901: Error
    attempting to read from the source installation database:
    c:\windows\installer\527ec6.msi What is solution of this problem ? Iam using
    windows xp professional version 2002 (service pack 2). Please post your reply. Iam waiting for your
    answer. ....
  14. Who's Fault Do You Think It Is?
    Story inside... (2)
    This conflict happened between me and my so called best friends. The day before our school's
    sports day, we had agree to wait for each other in front of the stadium's gate before entering.
    We've promised to each other that we won't enter the stadium unless we are all there. So the
    day came. We (me & my twin sis) were rushing to the stadium. But I had to wait for my father because
    he's the one driving me and my twin sis there. Without him, we can't go! Aina (one of my
    bff) called me on my cellie asking me where am I. I said I'm at home wait....
  15. Database With Mysql++
    getting mySQL++ to work with trap17 (7)
    Hi, I'm trying to build an online game and figured the easiest way to do the server list would
    be to make a mySQL database for it; however, I use the con() command on the IP i get from pinging my
    website and I always get an abnormal program termination; however, it will work with the mySQL on my
    own machine. The code is below: CODE #include <iostream> #include <iomanip>
    #include <mysql++> #include "pass.h"//holds my password (i program at
    school) int main(void) {     Connection con("t3jem3_test","....
  16. Tools Needed!
    PHP & MySQL (9)
    Hello, everyone! I need some tools for those two things to test PHP scripts coming together with
    database on my laptop, instead checking them on a web-server which takes time.....
  17. Pie Cakes (or, Pies Inside Of Cakes)
    (8)
    So one day, I imagined something truly amazing, and wonderful. "What," I asked myself, "would it
    taste like to have a pie inside a cake?" The more I thought about this wonderful possibility, the
    more I was convinced it would be mighty delicious and truly amazing. To this day, I have eaten two
    versions of the pie cake. Both have been truly incredible. The two versions I have devoured were:
    Cherry Pie in Chocolate Cake Lemon Pie in Angel Food Cake Believe me if you try these, you will be
    stunned and awe-struck..... So? How do you make these tantilizing deserts? I&#....
  18. Mysql + Php Question
    (5)
    Hi, I am creating a website in php and using a mysql database to store the data. I want to store
    time data in the database. My question is what is the best datatype I should use and how do I read
    the time from the database and format(display) it using php ?....
  19. Mysql Won't Update
    (4)
    Ok, so I'm making some arcade administration software so I don't have to add games the hard
    way, well anyway, one of the features I have is that on the homepage is a featured author and as
    such I just have it so it updates one line in the mySQL. Well, the page with the form passes on the
    varibles fine and the updating page recieves them because I echoed everything, then I build the
    query and I even echo the query and it comes out exactly how I want it to, but for some reason, the
    database itself won't update even though all the varibles are there. Here's....
  20. Watch Star Wars Inside Cmd
    Watch Star Wars inside CMD (13)
    Watch Star Wars inside CMD, Title is pretty self-explanitory. 1. Open Windows CMD 2. type: telnet
    towel.blinkenlights.nl 3. Press Enter 4. Enjoy....
  21. Qupis : Free Hosting With Php, Mysql, Cpanel. (one Line Text Ad At Bottom)
    a member of Xisto (41)
    Hello Members, We are proud to introduce a new member to Xisto group of sites.
    Qupis : Free Web Hosting 150 MB space, 5000 MB Bandwidth, php,
    mysql, CPanel (Latest). Emails, FTP, Addon domains, Parked Domains etc.
    http://www.Qupis.com
    Feel free to add your reviews and comments about it. -Trap17
    Management ....
  22. Is It Possible To Access The Mysql Remotely?
    (10)
    I like to experiment with a lot of things and I was thinking of making a sort of instant messenger
    in Python, but I want to let people have actual accounts so I need to be able to access the mySQL
    remotely. If that's not possible, are we allowed to run Python scripts on the server?....
  23. Check Referrer To Prevent Linking Yours From Other Sites
    Check referrer with Php and Mysql (8)
    Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites Ever
    find that found some people are listing items, images and tuts and linking directly to the download
    url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of
    downloads. To prevent this, you can add a piece of code to the download pages that checks which page
    referred them to the download page: if it's my domain, it downloads the file normally, if
    it's not, it will redirect to my home page instead. Important : Not all browser....
  24. Creating Profiles In Php/mysql ?
    (7)
    i've started to learn php..im familiar to basics of php and mysql now.Now for example i want
    that some user can register to my website , and after that he can Login and log out , and he can see
    his profile.is there any tutorial about this ? or any helping url .. or any helping answer please
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  25. Can You Add Images Into A Mysql Database?
    Using Php? (20)
    I'm learning php in class right now, but I'm still not that good at it, what I'm
    wondering is when I write the php so that it can connect with a database, can I at the same time
    have it that it is able to display back images that I choose. Like, I want a search feature, where
    you can search for a keyword, and it will bring back a list of all the possible entries with that
    keyword, but each of these entries will have a photo associated with it. Now, do I put these image
    files directly into the database, or do I write the code to link them from my files to th....
  26. Installing Apache, Mysql, Phpmyadmin Locally
    Solving the "php_mbstring.dll missing" (5)
    Since Trap17's CP provide the individual site's owner with goodies like MySql and
    PhpMyAdmin, chances are some will want to make use of them. Well, it's fine enough to get that
    on one's host (Gee! Thanks a lot, Trap17...) Knowing how the usual geek react, it might be
    expected that most people considering to make use of a database on their site will want to do most
    of the tedious job of developing and testing on their own local system before sending the wrapped-up
    result on their domain/subdomain. This involves four basic steps (sorry for the compuwi....
  27. Mysql Database Size
    related to the free database space (6)
    hi all! this is my first post /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> and i have a doubt, how much mysql space i am allowed to use... i mean how
    much is available for my free account....
  28. Import From Excel File Into Mysql Database
    (7)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  29. Learning Mysql
    pls guide (3)
    hello out there, i have already looked through on this tutorial forum.. and still can find any
    topics which related to MySql basic.. i wanna learn about how to create MySql table and its
    concept!! just basic.. i've no knowledge on MySql before nor any other database server
    software.. but i do have littol konwledge on programming,scripting,html basic in concept.. pls dun
    gave me so many links so as i can be blur for none about how to get start!! /laugh.gif'
    border='0' style='vertical-align:middle' alt='laugh.gif' /> i can thou find from Googles sear....
  30. Complete Login System
    With PHP + MYSQL (56)
    Its an complete login sistem made and tested by me and I think itwill be very usefull for people who
    are tryn to learn PHP. First, let's make register.php: CODE <?
    include("conn.php"); // create a file with all the database connections
    if($do_register){ // if the submit button were clicked if((!$name)
    || (!$email) || (!$age) || (!$login) ||
    (!$password) || (!$password2)){ print "You can't let
    any fields in blank....

    1. Looking for mysql, datatype, int, inside, int,

Searching Video's for mysql, datatype, int, inside, int,
Similar
How Do I
Find My
Mysql
Password?
[resolved] -
Cannot
access my
MySQL
Please
Explain Me
Mysql - How
do i insert
information
into this
config:
Remote
Access Mysql
Create Table
- Mysql Code
- Help
Mysql Error
Cd Drive
Eject Button
Problem -
see inside
for
explanation
Mysql -
Several
files in one
field.
Html
Form! -
Using
MySQL?!
Best Php And
Mysql Editor
For Noobs -
anyone any
php or mysql
editor that
is good for
noob
Php And
Mysql
Programming
- anyone
knows a code
for mysql
and php
Mysql, Php,
Apache
Downloads
And Setup
Was A
Nightmare -
Mysql, PHP,
Apache
The Best
Free Php
Mysql Blog -
any idea
Mysql-essent
ial-5.0.51
Installion
Problem -
please help
me.(urgent)
Who's
Fault Do You
Think It Is?
- Story
inside...
Database
With Mysql++
- getting
mySQL++ to
work with
trap17
Tools
Needed!
- PHP &
MySQL
Pie Cakes
(or, Pies
Inside Of
Cakes)
Mysql + Php
Question
Mysql
Won't
Update
Watch Star
Wars Inside
Cmd - Watch
Star Wars
inside CMD
Qupis : Free
Hosting With
Php, Mysql,
Cpanel. (one
Line Text Ad
At Bottom) -
a member of
Xisto
Is It
Possible To
Access The
Mysql
Remotely?
Check
Referrer To
Prevent
Linking
Yours From
Other Sites
- Check
referrer
with Php and
Mysql
Creating
Profiles In
Php/mysql ?
Can You Add
Images Into
A Mysql
Database? -
Using Php?
Installing
Apache,
Mysql,
Phpmyadmin
Locally -
Solving the
"php_mb
string.dll
missing"
;
Mysql
Database
Size -
related to
the free
database
space
Import From
Excel File
Into Mysql
Database
Learning
Mysql - pls
guide
Complete
Login System
- With PHP +
MYSQL
advertisement



Mysql Datatype Int() Question - Not sure what value to use inside int()



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE