Answered Questions

  • What is difference between varchar and varchar2

    shaik shamsheer

    • Dec 28th, 2011

    In case of varchar it store upto 2000 bytes and in case of varchar2 it stores 4000 bytes
    varchar is occupies space for the null value and varchar2 does not occupy space for null values.

    venkat

    • Dec 4th, 2011

    "varchar" allocates memory in dynamic fashion where as "varchar2" also allocates memory in dynamic fashion but it also supports garbage collection.
    "varchar" is developed along with SQL where as "varchar2" is developed by Oracle.

  • what is the difference between primary key, unique key, surrogate key?

    Star Read Best Answer

    Editorial / Best Answer

    Kolta Sam  

    • Member Since Jul-2011 | Jul 10th, 2011


    Primary Key:

    It is a visible key
    It generated by user or application.
    It could be changed by the user or application.
    It could be queried
    It used to form a relation between tables
    It shouldn’t contain null value
    It resemble table row
    It is a unique identifier for a table object.
    It contains only one key
    It could contain numeric and strings characters.
    It is an unique key which each row contain a distinct different key.
    Example for it is a customer_Id.
    It always starts by number one and second is two and so on but can starts with a different number.
    Could created on one or more columns
    No duplicate records

    Secondary Key:

    It used to form a relation between tables.
    It is alternate table key.
    It used to search data with primary key
    It could contains null value
    It could contains more than one secondary key for each table
    Created only on one columns
    No duplicate records
    It creates index clustered by default


    Surrogate Key:

    It is invisible key for the user or the application.
    It resembles database entity.
    It generated by the system so it is invisible for user and application.
    It shouldn’t contain null values
    Only one surrogate key for each data entity
    Its value is unique system wide.
    Its value is never manipulated by the user or the application.
    It never reused
    It is frequently sequential number
    It called synthetic key, an entity identifier, a system-generated key, a database sequence number, a factless key, a technical key, or an arbitrary unique identifier
    No duplicate records

    gopi

    • May 18th, 2018

    Primary key not allow null values where as unique allows but both are alternates.
    surrogate key serve as primery key in type 2 dimension tables

    Sukdya

    • Nov 27th, 2017

    Primary key doest not allow null values but unique key allows only one null value.