Results 1 to 10 of 10

What is a PRIMARY KEY ?

This is a discussion on What is a PRIMARY KEY ? within the Programming forums, part of the Web Designing & Development category; ...

  1. #1
    Senior Member chinmay.sahoo's Avatar
    Join Date
    Dec 2013
    Location
    Banglore
    Posts
    266

    Thumbs up What is a PRIMARY KEY ?

    A PRIMARY KEY constraint is a unique identifier for a row within a database table. A primary key prevents,duplicates , and ensures that all records have their own distinct values. Primary keys donít allow nulls, so you are guaranteed that each record has its own unique populated value

  2. #2
    Senior Member
    Join Date
    Aug 2015
    Posts
    302

    Default Re: What is a PRIMARY KEY ?

    In the database various types of keys used.Primary key is a one of the key that is used in database.It is a unique Identifier for rows within a table.

  3. #3
    Junior Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    13

    Default Re: What is a PRIMARY KEY ?

    Primary keys must contain UNIQUE values.
    Primary key column cannot contain NULL values.

    CREATE TABLE Persons
    (
    P_Id int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255),
    PRIMARY KEY (P_Id)
    )

  4. #4
    Member tarunap's Avatar
    Join Date
    Jun 2015
    Posts
    62

    Default Re: What is a PRIMARY KEY ?

    A primary key is a unique identifier for a database record. When a table is created, one of the fields is typically assigned as the primary key. While the primary key is often a number, it may also be a text field or other data type.

    Quote Originally Posted by Miss Figa View Post
    Primary keys must contain UNIQUE values.
    Primary key column cannot contain NULL values.

    CREATE TABLE Persons
    (
    P_Id int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255),
    PRIMARY KEY (P_Id)
    )

    To create a PRIMARY KEY constraint on the "ID" column when Persons table already exists, use the following SQL syntax:


    ALTER TABLE CUSTOMER ADD PRIMARY KEY (ID);

  5. #5
    Member
    Join Date
    Oct 2015
    Posts
    44

    Default Re: What is a PRIMARY KEY ?

    Quote Originally Posted by chinmay.sahoo View Post
    A PRIMARY KEY constraint is a unique identifier for a row within a database table. A primary key prevents,duplicates , and ensures that all records have their own distinct values. Primary keys don’t allow nulls, so you are guaranteed that each record has its own unique populated value
    In database relation modeling and implementation, a unique key is a set of zero , one, or more attributes. The value(s) of these atrributes are required to be unique for each tuple ( row) in a relation. The value , or combination of values, of unique key attributes for any tuple should not be repeated for any other tuple in that relation.

  6. #6
    Senior Member
    Join Date
    Aug 2015
    Posts
    302

    Default Re: What is a PRIMARY KEY ?

    Primary key is a database key.Primary key is a unique key that is used in database for unique value etc.

  7. #7
    Junior Member
    Join Date
    Dec 2015
    Posts
    22

    Default Re: What is a PRIMARY KEY ?

    The PRIMARY KEY constraint uniquely identifies each record in a database table.
    Primary keys must contain UNIQUE values.
    A primary key column cannot contain NULL values.
    Most tables should have a primary key, and each table can have only ONE primary key.

  8. #8
    Senior Member
    Join Date
    Jan 2016
    Posts
    145

    Default Re: What is a PRIMARY KEY ?

    Hey,
    -A primary key is a field in a table which uniquely identifies each row/record in a database table.
    -It must contain unique values.
    -It's column cannot have NULL values.
    To clear the primary key constraints from the table,
    Use Syntax:

    ALTER TABLE CUSTOMERS DROP PRIMARY KEY ;

  9. #9
    Member
    Join Date
    Jan 2016
    Posts
    88

    Default Re: What is a PRIMARY KEY ?

    Primary key a key that uniquely identify a row within a table , primary key is unique and not null

  10. #10
    Senior Member
    Join Date
    Jan 2012
    Posts
    2,044

    Default Re: What is a PRIMARY KEY ?

    A primary key, also called a primary keyword, is a key in a relational database that is unique for each record. It is a unique identifier, such as a driver license number, telephone number (including area code), or vehicle identification number (VIN). A relational database must always have one and only one primary key.

Tags for this Thread