What's the difference between using INDEX vs KEY in MySQL?

后端 未结 5 1426
迷失自我
迷失自我 2020-11-28 01:54

I know how to use INDEX as in the following code. And I know how to use foreign key and primary key.

CREATE TABLE tasks ( 
  task_id INT UN         


        
5条回答
  •  温柔的废话
    2020-11-28 02:25

    A key is a set of columns or expressions on which we build an index.

    1. While an index is a structure that is stored in database, keys are strictly a logical concept.

    2. Index help us in fast accessing a record, whereas keys just identify the records uniquely.

    3. Every table will necessarily have a key, but having an index is not mandatory.

    Check on https://docs.oracle.com/cd/E11882_01/server.112/e40540/indexiot.htm#CNCPT721

提交回复
热议问题