|
| |||||||||
| Tags: key, primary, primary key, primary key concept, sql, sql primary key |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| what does primary key mean in SQL?
Hello friend, I just started to learn SQL. I have knowledge of java and C++, but SQL is entirely different from these language. I know how to create simple table in SQL. But I am quit confused about 'primary key'. I don't know what is 'primary key'. I want to know what is the need of using primary key. Do you have sound knowledge about 'primary key'? if yes then please let me know the same. I am waiting for your reply. |
|
#2
| ||||
| ||||
| Re: what does primary key mean in SQL?
Hi friend, The primary key helps to uniquely identify each row in a table. It can be a part of a permanent record, or be an artificial field (a field that has nothing to do with the actual recording). The primary key can represent one or more fields in a table. When the primary key represents several fields, it is called composite key. It is possible to to specify the primary key while creating the table (using CREATE TABLE) Or changing the structure of the existing table (through ALTER TABLE). |
|
#3
| ||||
| ||||
| Re: what does primary key mean in SQL?
In a relational database, a primary key is a unique constraint that can uniquely identify a record in a table. A primary key can consist of one or more fields of the table. Two separate lines of the table can have different values for the fields defined in the primary key. It is possible to define for a table several unique constraints, but at most one primary key. it is possible to have a primary key field1 (PK) of a table to point to the primary key field1 (pk) a table B. |
|
#4
| ||||
| ||||
| Re: what does primary key mean in SQL?
The primary key of a table should be placed on fields that identify each table row. It may therefore seem helpful to place a primary key on a social security number for example, but we prefer to use a completely independent primary key business data to ensure that the field is always filled (a stranger or a child may have no social security number) and does not change in time. All databases provide mechanisms that support numbering used for primary keys. |
|
#5
| ||||
| ||||
| Re: what does primary key mean in SQL?
It is not necessary to define an index on columns defining the primary key because an index is implicitly associated with the primary key. The set consists of a primary key and a foreign key used to establish Relations between tables. You can put a constraint preventing contain duplicates in a field but without necessarily being a primary key field. This constraint is implicit in a field primary key. |
|
#6
| ||||
| ||||
| Re: what does primary key mean in SQL?
The primary key can be defined in the following ways: Quote:
Quote:
http://msdn.microsoft.com/en-us/library/ms191236.aspx |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "what does primary key mean in SQL?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How many partitions will you do in your Primary HDD | Quintessa | Polls & Voting | 6 | 2 Weeks Ago 07:22 PM |
| VDI Primary on VirtualBox | Who is it | Software Development | 5 | 16-07-2010 04:49 AM |
| Set up Old harddrive as primary | TAKODA | Hardware Peripherals | 3 | 07-07-2009 10:08 AM |
| Cannot create new primary partition - only 2 primary partitions on disk | Vistanoob | Windows Vista Performance | 5 | 28-05-2009 10:43 PM |
| Vista Ultimate changed Primary partitions to Dynamic and created hidden partition with the primary "partitions" listed as Volumes | craigv | Operating Systems | 2 | 03-06-2008 04:16 PM |