i am a newbie and am a bit concerned about the effici开发者_运维百科ency of mysql table. what are the pros and cons of making a field in mysql table as
- index
- primary
what is the followed practise in deciding on the attributes of a field in a mysql table? please share your insights, thanks.
You can only have one primary key in a table. It should be a column that uniquely identifies each record in your table. A primary key is not a requirement; for example, you may have a table to implement a many-to-many relationship and a unique id is not needed for those records.
Indexes should be used whenever you must query a table and specify some criteria to filter records based on a column's value (e.g. WHERE clause). There is a lot to learn about indexes, for example: when to create an index on one column vs. multiple columns in the same index. Read the documentation on the MySQL website about indexes to learn more.
精彩评论