PDA

View Full Version : Who knows MySQL?



Xotuako
11-05-2007, 12:43 PM
Hi, I'm learning to code in PHP - and I'm doing very good!

But, something that I don't know is making a mysql database... I don't understand all the pieces, for example:


CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`email` varchar(40) NOT NULL default '',
`msn` varchar(250) NOT NULL default 'Not Specified',
`aim` varchar(250) NOT NULL default 'Not Specified',
`location` varchar(36) NOT NULL default 'Not Specified',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
So, the first part makes a table, called users. I understand that. The id is the users id, it isn't null, so it has to be something, and goes up everytime. What is the int(11)?
Next we have username... not null, so user has to have something, default isn't anything... again, whats this? varchar(30)? I saw somewhere int means you can't have things like - @ etc, and varchar you can have letters numbers - @ etc...

But what are the numbers? On email it's (40) on aim it's (250)... what do they mean, thats all I need to know tbh!

- Thanks and +rep if you can help me! :)

Xotuako

Xotuako
11-05-2007, 01:04 PM
OO, just missed editing it! Sorry for double post, cannot edit :(

I think I understand... the numbers are the max characters the value can have? Please correct me if wrong :P And explain a little more!

Want to hide these adverts? Register an account for free!