What does keyword CONSTRAINT do in this CREATE TABLE statement

后端 未结 2 1478
攒了一身酷
攒了一身酷 2021-02-06 02:41

I\'m learning how to use sqlite3 with python. The example in the text book I am following is a database where each Country record has a Region, Country, and Population.

2条回答
  •  孤独总比滥情好
    2021-02-06 03:09

    Country_key is simply giving a name to the constraint. If you do not do this the name will be generated for you. This is useful when there are several constraints on the table and you need to drop one of them.

    As an example for dropping the constraint:

    ALTER TABLE PopByCountry DROP CONSTRAINT Country_Key
    

提交回复
热议问题