SQL: Where should the Primary Key be defined -


itemprop = "text">

I am creating a database with several SQL files 1 creates file tables 1 file combines obstacles 1 drops of file obstacles .

Primary is an obstacle, but I have been told to define my primary key in table definition, but there is no reason given.

Is it better to define the primary key as an obstacle that can be added and dropped or this table is better in definition.

My current thinking is to do this in table definition because it can be a removable obstacle potentially causing some horrible issues with duplicate keys, but leaving obstacles can lead to serious problems, Therefore, it is expected that if a primary key is left out, then they should take appropriate steps to avoid problems, because they should be for any other data entry. Primary key is a hindrance, but an obstacle is not a primary key in performing some major database surgeries. The lack should never be required to leave the primary key.

Defining the primary key with the table is a good practice - if you separate the table and the key definition, the key is lost in the key definition or the window is forgotten. Given that a decent database design relies solely on the consistent key, you will never want to have a slight chance that your primary key is not working properly.

Comments