I'm in the process of trying to get to grips with MySQL and actually use it.
I have been supplied some code to create some tables in a database. I understand most of it, but not all...
First table:
Second table:
Third table:
In the second and third table it has CONSTRAINT before PRIMARY KEY, what is the purpose of this? What does it do?
Thanks for any help
I have been supplied some code to create some tables in a database. I understand most of it, but not all...
First table:
Code:
CREATE TABLE IF NOT EXISTS `players` (
`pid` varchar(32) NOT NULL,
`firstname` varchar(32) NOT NULL,
`lastname` varchar(32) NOT NULL,
`lastip` varchar(32) NOT NULL,
`connections` int(11) NOT NULL default 1,
`lastconnect` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
Second table:
Code:
CREATE TABLE IF NOT EXISTS `playernames` (
`pid` varchar(32) NOT NULL,
`name` varchar(32) NOT NULL,
`last` timestamp NOT NULL default CURRENT_TIMESTAMP,
CONSTRAINT PRIMARY KEY (`pid`, `name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Third table:
Code:
CREATE TABLE IF NOT EXISTS `playerips` (
`pid` varchar(32) NOT NULL,
`ip` varchar(32) NOT NULL,
`last` timestamp NOT NULL default CURRENT_TIMESTAMP,
CONSTRAINT PRIMARY KEY (`pid`, `ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
In the second and third table it has CONSTRAINT before PRIMARY KEY, what is the purpose of this? What does it do?
Thanks for any help
