Identity without Primary Key or with....which is the difference

Guys, one question: which is the main difference between using Identity and using either Identity and Primary_Key? It looks a stupid question (and maybe it is) but...maybe is not so stupid.

Primary Key is a logical implemention which creates behind the scene  unique clustered index (physical implementation)
BTW, if you use an INDENTITY property and do not have PK on this you may end up with duplicates , ans also someone my reseed the values...
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Using identity you may end up with duplicates??!!

Similar Messages

  • Does ADF Business Components  work well with tables without primary Key?

    We have tables using unique index without primary key. Can ADF Business Components relate business objects based on the unique index columns of the tables?

    Hi,
    Regarding my question about the XML syntax for custom properties:
    It turned out to be another problem in the Entity object definition that caused the JDeveloper error. Other entities let me add the custom property without problems. However should anybody ever need that XML syntax, here's how you add a custom property to an entity definition in the XML code:
      <Attribute
        Name="Id"
        IsNotNull="true"
        Precision="10"
        Scale="0"
        ColumnName="ID"
        Type="oracle.jbo.domain.Number"
        ColumnType="NUMBER"
        SQLType="NUMERIC"
        TableName="TABLE"
        PrimaryKey="true">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="22"/>
        </DesignTime>
        <Properties>
          <CustomProperties>
            <Property
              Name="SequenceName"
              Value="SEQ1"/>
          </CustomProperties>
        </Properties>   
      </Attribute>Best regards,
    Bart Kummel
    Edited by: Bart Kummel on Sep 8, 2009 1:14 PM

  • Hibernate without primary key?

    i need to use hibernate for the table which do not have primary key. I found many explanation about there should not any table without primary key.
    plz let me know for this case-
    user table with unique pk userId
    group table with unique pk groupId
    and one more mapping table for them group-user table which will contain both of the primary keys. there should not have pk for that group-user table. but, with userId and groupId, the rows from that tables are unique.
    I just wanna show a sample for this kind of case. plz let me know is there anyway to solve it?

    Read chapter 7.3 of the Hibernate Reference Documentation.
    For future Hibernate questions, please checkout http://forums.hibernate.org
    This has definitately nothing to do with JDBC, but with lack of effort to gently read documentations/manuals.

  • How to speed up fast refresh of materialized view without primary key

    Thought I'd share this info, as I couldn't find anything on here to help me diagnose the issue:
    I had a materialized view that was taking longer to perform a fast refresh than it took to perform a complete refresh. My mview had no primary key, as the base table had no primary key.
    I created a trace file for the session and saw references to a column M_ROW$$ in my mview. Nowhere in the data dictionary could I find a reference to the m_row$$ column in my mview, but apparently it exists and is created automatically. After creating the index below, the fast refresh took 6 minutes to add 500k rows to the materialized view. (versus 4+ hours without the index) When I looked in the trace file, I noticed that for each row in the mview log, it first tries to update the mview with an UPDATE statement, then it performs an insert of the new data. Seems like it should be able to determine whether to perform an update or insert based on the DMLTYPE$$ column of the mview log. What was killing my performance was the UPDATE phase. Since I had no primary key on the mview, and no index on the m_row$$ column, the UPDATE phase was performing a full table scan of my mview for every row in the mview log. I was expecting it to be smart enough to only perform inserts, as the only transactions against the base table were inserts.
    In summary: If you have a materialized view without a primary key, create an index on the m_row$$ column of the mview, even though no such column displays in the data dictionary.
    ex:
    CREATE MATERIALIZED VIEW mv_minidrr ...
    CREATE INDEX pk_mv_minidrr ON mv_minidrr(m_row$$) ...

    Well, there indeed is a column called M_ROW$$
    Your MLOG$_EMP is nothing but the materialized view log on the base table.
    SQL> create  materialized view log on emp with rowid ;
    Materialized view log created.
    SQL> create materialized view emp_mview refresh fast on demand with rowid as select * from emp ;
    Materialized view created.
    SQL> desc mlog$_emp
    Name                                                  Null?    Type
    M_ROW$$                                                        VARCHAR2(255)
    SNAPTIME$$                                                     DATE
    DMLTYPE$$                                                      VARCHAR2(1)
    OLD_NEW$$                                                      VARCHAR2(1)
    CHANGE_VECTOR$$                                                RAW(255)
    SQL> select table_name, column_name from user_tab_columns where column_name = 'M_ROW$$' ;
    TABLE_NAME                     COLUMN_NAME
    MLOG$_EMP                      M_ROW$$
    1 row selected.
    SQL>

  • Creating a New Row Using an ADF Iterator Binding without primary key value

    I dropped a Create action onto a DataAction which forwards to a UIX entry page which contains an enabled Commit button. Part of the primary key value is held in a session bean and it is also current in another view on the model side, but I am unable to access this value to set the EntityImpl primary key attribute.
    Upon submission the following error message is returned from the model:
    ORA-01400: cannot insert NULL into ("GTR"."EMPLOYMENT"."ACCOUNT")
    I would like to accomplish this with databinding and not create a custom create method on the application model. Is there a way to update the binding value for the new row in cache before the submission? Any advice would be welcome.

    I should add that I want the user to enter every attribute value, except for the account number. It must be possible to create a new row and have the account number supplied to the bindings another way.

  • Creating a snapshot without primary keys

    Hi,
    I would like to create a snapshot for a table that does not have a primary key. I've read the thread
    "Re: creating snapshots without a primary key??"
    from Mar 24, 2003, which seems to indicate that this is allowed if the snapshot is not updatable. However, even when I disable the "Updatable?" option, I still get the following error:
    WTG-20502 Packaging Wizard Failed. 500
    CONS-10032: Publication item: WTGPI_10012 cannot
    be updatable, primary keys for xyz.abc not found.
    BTW, the Oracle9i Lite Developer's Guide for Windows 32 is really thin in this area. In particular, the description of the Updatable feature is the following:
    This check box defines the snapshot to be created
    as updatable.
    That description has a lot of unmet potential.
    Thanks,
    Tim

    Hello,
    If you create a snapshot that has no primary key, you have to check the option "complete refresh".
    Oracle uses the primary key to track changes for the "partial refresh" option (only send changes back and forth).
    -Antti Virkkunen, www.vilant.com

  • How to Create primary key index with duplicate rows.

    Hi All,
    While rebuilding an index on a table , I am getting error that there are duplicate rows in a table.
    Searching out the reason led me to an interesting observation.
    Please follow.
    SELECT * FROM user_ind_columns WHERE table_name='SERVICE_STATUS';
    INDEX_NAME     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION     COLUMN_LENGTH     CHAR_LENGTH     DESCEND
    SERVICE_STATUS_PK     SERVICE_STATUS     SUBSCR_NO_RESETS     2     22     0      ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     STATUS_TYPE_ID     3     22     0     ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     ACTIVE_DT     4     7     0     ASC
    SERVICE_STATUS_PK     SERVICE_STATUS     SUBSCR_NO     1     22     0     ASC
    SELECT index_name,index_type,table_name,table_type,uniqueness, status,partitioned FROM user_indexes WHERE index_name='SERVICE_STATUS_PK';
    INDEX_NAME     INDEX_TYPE      TABLE_NAME     TABLE_TYPE     UNIQUENESS     STATUS     PARTITIONED
    SERVICE_STATUS_PK     NORMAL     SERVICE_STATUS     TABLE     UNIQUE     VALID     NO
    SELECT constraint_name ,constraint_type,table_name,status,DEFERRABLE,DEFERRED,validated,index_name
    FROM user_constraints WHERE constraint_name='SERVICE_STATUS_PK';
    CONSTRAINT_NAME     CONSTRAINT_TYPE     TABLE_NAME      STATUS     DEFERRABLE     DEFERRED     VALIDATED     INDEX_NAME
    SERVICE_STATUS_PK     P     SERVICE_STATUS     ENABLED     NOT DEFERRABLE     IMMEDIATE VALIDATED     SERVICE_STATUS_PK
    1. Using index scan:
    SELECT COUNT (*)
    FROM (SELECT subscr_no, active_dt, status_type_id, subscr_no_resets
    FROM service_status
    GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
    HAVING COUNT (*) > 1) ;
    no rows returned
    Explain plan:
    Operation     OBJECT Name     ROWS     Bytes     Cost     OBJECT Node     IN/OUT     PStart     PStop
    SELECT STATEMENT Optimizer MODE=CHOOSE          519 K          14756                     
    FILTER                                        
    SORT GROUP BY NOSORT          519 K     7 M     14756                     
    INDEX FULL SCAN     ARBOR.SERVICE_STATUS_PK     10 M     158 M     49184                     
    2. Using Full scan:
    SELECT COUNT (*)
    FROM (SELECT /*+ full(s) */ subscr_no, active_dt, status_type_id, subscr_no_resets
    FROM service_status s
    GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
    HAVING COUNT (*) > 1) ;
    71054 rows returned.
    Explain Plan:
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          1           24123                     
    SORT AGGREGATE          1                               
    VIEW          519 K          24123                     
    FILTER                                        
    SORT GROUP BY          519 K     7 M     24123                     
    TABLE ACCESS FULL     ARBOR.SERVICE_STATUS     10 M     158 M     4234                     
    Index SERVICE_STATUS_PK is a unique and composite primary key VALID index. And the constraint is ENABLED and VALIDATED still having duplicate rows in table.
    How it is possible?
    Is it an Oracle soft Bug??
    Regards,
    Saket Bansal

    saket bansal wrote:
    Values are inserted as single rows inserts through an GUI interface.And you still claim to have over 71K duplicate records, without the GUI getting any kind of errors?
    That does not add up and can only be explained by a "bug".
    I tried inserting a duplicate record but failed.
    SQL> insert into service_status (select * from service_status where rownum <2);
    insert into service_status (select * from service_status where rownum <2)
    ERROR at line 1:
    ORA-00001: unique constraint (ARBOR.SERVICE_STATUS_PK) violatedAre you really sure there is no other way data in this table is populated/manipulated in bulk?

  • In the case without primary key

    Hi experts,
    In the case without primary key, we can define a primary key?
    In the case
    Source: SQL Server 2000
    Target: Oracle 11.2.0.3
    When both the source and target does not have primary key.
    Thank you
    Edited by: 891982 on 21 ก.ค. 2555, 18:41 น.

    GGSCI (win-ms) 48> stats msdp
    Sending STATS request to EXTRACT MSDP ...
    Start of Statistics at 2012-07-21 12:40:28.
    Output to E:\destgg\dirdat\dt:
    Extracting from dbo.City to dbo.test:
    *** Total statistics since 2012-07-21 12:36:30 ***
    Total inserts 2.00
    Total updates 0.00
    Total deletes 0.00
    Total discards 0.00
    Total operations 2.00
    and
    GGSCI (win-ms) 48> stats msdp
    Sending STATS request to EXTRACT MSDP ...
    Start of Statistics at 2012-07-21 12:40:28.
    Output to E:\destgg\dirdat\dt:
    Extracting from dbo.City to example.test:
    *** Total statistics since 2012-07-21 12:36:30 ***
    Total inserts 2.00
    Total updates 0.00
    Total deletes 0.00
    Total discards 0.00
    Total operations 2.00
    Thank you

  • Primary key question with PHPmysql database

    I know that updating the primary key is taboo, but I have a a newsletter subscription form set up that works perfectly, but I can't figure out how to create the primary key.  I tried using the subscriber email address (because its unique, but in trying to add an update function I realize that the email address may need to be updated.
    My question is how do I get a primary key that will work when I'm relying on a form variable to create the record and therefore have no control over assigning one?
    Is there a way to have one automatically assigned when a subscriber hits the submit button?

    Bingo.
    I wrote:
    ALTER TABLE email_list  ADD (      id MEDIUMINT NOT NULL AUTO_INCREMENT,      name CHAR(30) NOT NULL,      PRIMARY KEY (id)  )
    I got my primary key column.  thank you so much!!!

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Which is the difference between Oracle RAC and Oracle Clusterware?

    Hi all, maybe this is a stupid question, but I've read the documentation, and still don't understand which is the difference between RAC and Clusterware.
    Can anybody explain it to me?
    Thanks in advance!

    RAC is database option part of Oracle Database software needed to have database running in cluster mode; see http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/glossary.htm#CNCPT2076.
    Clusterware is separate software needed to run Oracle Database in cluster mode: you can use Oracle Clusterware without Oracle Database but you cannot use Oracle Database with RAC option without Oracle Clusterware.
    See http://download.oracle.com/docs/cd/E11882_01/rac.112/e16794/intro.htm#BABCHEEE.
    Edited by: P. Forstmann on 19 nov. 2010 19:11
    Edited by: P. Forstmann on 19 nov. 2010 19:11

  • I would to know which is the difference ipad wifi versus ipad wifi   cellular

    I would to know which is the difference ipad wifi versus ipad wifi   cellular

    The one with cellular is able to connect to your cellular data service if it's part of your cell phone plan. This lets you download from the Internet whenever you are not able to use Wi-Fi.

  • IM: which's the difference between S_ALR_87012805 & S_ALR_87012806

    Hi All,
    in Investment management, could anyone tell me which's the difference between S_ALR_87012805 and S_ALR_87012806 t.code?
    Thanks a lot
    G.Rossi

    Hi All,
    in Investment management, could anyone tell me which's the difference between S_ALR_87012805 and S_ALR_87012806 t.code?
    Thanks a lot
    G.Rossi

  • Which is the difference between Windows server on IA64 and on x64?

    Hello,
    I want to download the last update of MaxDB 7.6 on servers 32bit and 64bit.
    For the version 32bit there exists only for Windows server IA32.
    For the version 64bit there exists for Window server IA64 and x64.
    Which is the difference between Windows server on IA64 and on x64?
    The version 32bits for Windows IA32bit functions for any type of server?.
    Best regards
    Frédéric Blaise
    e-Kenz S.A.

    For the version 32bit there exists only for Windows server IA32.
    IA32 is basically x86
    Which is the difference between Windows server on IA64 and on x64?
    IA64 is based on Itanium processors while x64 are x86 compatible.
    The version 32bits for Windows IA32bit functions for any type of server?.
    For any Windows 32bit server.
    Regards
    Juan

  • Which are the differences in the bookmarks organization?

    In Safari I can organize bookmarks in three group: Bookmarks Bar, Bookmarks Menu and the "Bookmarks" list under the first ones.
    I've understood only that the Bar shows bookmarks under the address bar, in spite of the Menu, but no more. So, why Safari separates two group of bookmarks? Just to let the first appear in the main page under the address bar?
    And, for example, which is the difference between the Menu and the list? Why are they separated? I can add a bookmarks in the menu but it doesn't appear in the list, and also if I add it in the list it won't appear in the Menu, so what kind of library is it? Shouldn't it have a main group in which having various folders (as Music and playlist in iTunes)? In Safari seems to be these separated groups, like the bookmarks of the list don't take part of the Bookmarks Menu...

Maybe you are looking for

  • Difference between IS and AS in procedure?

    difference between IS and AS in procedure?

  • Dynamic sort help needed

    I am trying to implement a dynamic sort using pl/sql procedure with two IN params, which tell what column to sort by and wich direction. smth. like this procedure getEmployees (p_dept_no in employee.dept_no%type, p_sortBy in varchar2, p_sortDir in va

  • SharePoint via VPN in a hosting environment

    Hello everybody, today I come across with a question regarding infrastructure design. Beforehand you have to know, I am not an architect, until now I was just an Sharepoint admin :) We have a scenario, that one of my customers want us to host a share

  • How Make A button point me to other window in Gui with java

    hello .i try to make a program,i creat button it's name Next, i wanna when user press Next go To other Panel Or another Window . plz help me for this problem try to code me the function or somthing help

  • Handling Asynchronous webservice - CRM WEBic

    Hi Experts, I have a scenario where i have to fetch details from a third party system via a webservice call. However the response from the third party system can only be asynchronous. The requirement is to display the data returned from the third par