python - What does keyword CONSTRAINT do in this CREATE TABLE statement -


I'm learning how to use sqlite3 with Python. Example of the text book I am following is a database Where there is a region, country and population in each country's records.

The book says:

The CONSTRAINT keyword has been used to specify the following snippet that any two entries created in the table should never be field and country Do not have the same values ​​for:

  & gt; & Gt; & Gt; Cur.execute ('' Make Table PopupCountry '' (field text is not faucet, country text is not faucet, population is not inconclusive, country country's primary key (region, country)) '' ')  

Please explain to you that CONSTRAINT Country_Key is here if I delete it, the primary key statement only seems to make sure that every country The area has unique name.

Country is just giving the name of the barrier if you do not do that, the name will be generated for you . This is useful when there are many obstacles on the table and you have to leave one of them.

As an example to leave the barrier:

  Optional table popbank drop drop country_key  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -