开发者

Create table mysql

I'am new to mysql and i want to know what KEY (not primary key) means in the query below :

    CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `username` varchar(150) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `password` varchar(100) NOT NULL default '',
  `activation` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `idx_name` (`name`),
  KEY `username` (`username`),
  KEY `email` (`email`)
) ENG开发者_C百科INE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=65 ;

also this line ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=65 ;


A KEY is an index: it's just like a library index: quicker finding for the values of that colum. You want this for joining and searching.

ENGINE=MyISAM 

Means the engine you use (this is the default). If you need foreign keys for example, then you might want InnoDB.

DEFAULT CHARSET=utf8 

Is the default character set.

AUTO_INCREMENT=65 ;

Means that currently the auto-increment value is at 65.


KEY is a synonym for INDEX. See database index if you're not familiar with them.


KEY is normally a synonym for INDEX.

ENGINE=MyISAM  

It means the storage engine for your table. There are two types of storage engines in MySQL: transactional and non-transactional. The default engine is InnoDB as of MySQL 5.5.5 ( MyISAM before 5.5.5).

DEFAULT CHARSET=utf8 

Character set support that enables you to store data using a variety of character sets.

AUTO_INCREMENT=65

It means currently the value of auto_increment is 65 for primary key id.

More information:- https://dev.mysql.com/doc/refman/5.7/en/create-table.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜