MySQL phpmyadmin question about INT
#1

Guys what does this mean? I know when I have VARCHAR I use lenght what I need (example name is 24...)
But why when I am looking some tuts here is INT like adminlevel, money etc.. here is some number
Reply
#2

Why this guy used in tutorial to create this table but id with 10 length why? CREATE TABLE IF NOT EXISTS `players`(\ `ID` int(10) NOT NULL AUTO_INCREMENT
Reply
#3

If you use a program like Navicat, which allows you to connect to your databases and view your tables, you'll see that MySQL needs these values.
When designing the tables, you can input the column-name and datatype stored.
If you choose "integer", the column is created with size 11.

My MySQL package also has MySQL Workbench installed and I can ask that program to send the creation-query for any table to the output window.
This query is similar to the one you posted.

My guess is that integers are stored as text in the database-file and MySQL needs the size of that field to be able to index the tables properly.
Any unsigned integer is stored using 10 characters.
Those can go from 0 to little over 4 billion, and 4 billion written as text is 10 characters.

Unsigned integers range from little over -2 billion to little over 2 billion.
The negative sign also needs a character slot, so signed integers take 11 characters to be stored.

My scripts use "int(11)" in those queries.
Reply
#4

My god, no! Integers are saved as integers.
http://stackoverflow.com/questions/5...fter-int-int11
Reply
#5

If i understand correctly, I can leave INT length empty?
Reply
#6

Yeah, when I left it empty it automaticaly set INT(11)
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
My god, no! Integers are saved as integers.
http://stackoverflow.com/questions/5...fter-int-int11
Ah, nice info here.

I just took the 11 as default and didn't question why it was 11.
After thinking about it, 11 characters are needed to display a signed integer properly.

I never knew this was meant for programs that process the result to use this value to read the data.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)