Unique and primary key

column with unique constraint + not null constraint = primary key! (to some extent) Is it correct?
I invite your ideas

http://www.techonthenet.com/oracle/unique.php
http://www.allapplabs.com/interview_questions/db_interview_questions.htm#q13
Difference between Unique key and Primary key(other than normal difference)

Similar Messages

  • Difference between Unique key and Primary key(other than normal difference)

    Hello,
    1).Can any one tell me any other difference between Unique key and Primary key other than it having NULLs.
    2). What is the difference the words 'DISTINCT' and 'UNIQUE' in a sql query.
    Thanks in advance.

    Hi
    If you don't believe me than see the documentation in
    OTN.
    Ott Karesz
    http://www.trendo-kft.hu
    SQL> create table scott.tbl_clob
      2  (sss CLOB)
      3  /
    Tabelle wurde angelegt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> insert into scott.tbl_clob values('wrwrwrw')
      2  /
    1 Zeile wurde erstellt.
    SQL> select distinct sss from scott.tbl_clob
      2  /
    select distinct sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select unique sss from scott.tbl_clob
      2  /
    select unique sss from scott.tbl_clob
    FEHLER in Zeile 1:
    ORA-00932: nicht übereinstimmende Datentypen
    SQL> select distinct to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL> select unique to_char(sss) from scott.tbl_clob
      2  /
    TO_CHAR(SSS)
    wrwrwrw
    SQL>

  • No matching unique or primary key for this column-list --error

    CREATE TABLE CUSTOMER(CUS_NUM NUMBER(10) PRIMARY KEY,CUS_NAME VARCHAR2(50),ADDRESS VARCHAR2(50));
    CREATE TABLE ITEM(ITEM_NUM NUMBER(10),ITEM_DESC VARCHAR2(50),TYPE VARCHAR2(50),ITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE));
    CREATE TABLE ITEM_TYPE(TYPE VARCHAR2(50) PRIMARY KEY,TYPE_NAME VARCHAR2(50),SKU VARCHAR2(50),RATING VARCHAR2(50));
    CREATE TABLE ORDERS(ORDER_NUMBER NUMBER(10),CUS_NUM NUMBER(10),ITEM_NUM NUMBER(10),ORDER_POINT VARCHAR2(50),DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM));
    Hi,friends i created tables as above when i creating 'ORDERS' table the error will fir as "ORA-02270: no matching unique or primary key for this column-list".
    can any body solve this issue.
    Cheers,
    Sudhir reddy.

    For your own sanity, you should learn to format your code, or use a tool to do it for you. For the sanity of the forum members, you should preserve that code using the \ tagsCREATE TABLE CUSTOMER
    CUS_NUM NUMBER(10) PRIMARY KEY,
    CUS_NAME VARCHAR2(50),
    ADDRESS VARCHAR2(50)
    CREATE TABLE ITEM
    ITEM_NUM NUMBER(10),
    ITEM_DESC VARCHAR2(50),
    TYPE VARCHAR2(50),
    TYPE is a reserved word.  Call it ITEM_TYPEITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE)
    CREATE TABLE ITEM_TYPE
    TYPE VARCHAR2(50) PRIMARY KEY,
    again, with the reserved word.TYPE_NAME VARCHAR2(50),
    SKU VARCHAR2(50),
    RATING VARCHAR2(50)
    CREATE TABLE ORDERS
    ORDER_NUMBER NUMBER(10),
    be consistent.  NUM or NUMBER.  Pick one and stick with it.CUS_NUM NUMBER(10),
    ITEM_NUM NUMBER(10),
    ORDER_POINT VARCHAR2(50),
    DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),
    ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM)

  • Dynamic SQL Joining between tables and Primary keys being configured within master tables

    Team , Thanks for your help in advance !
    I'm looking out to code a dynamic SQL which should refer Master tables for table names and Primary keys and then Join for insertion into target tables .
    EG:
    INSERT INTO HUB.dbo.lp_order
    SELECT *
    FROM del.dbo.lp_order t1
    where not exists ( select *
    from hub.dbo.lp_order tw
    where t1.order_id = t2.order_id )
    SET @rows = @@ROWCOUNT
    PRINT 'Table: lp_order; Inserted Records: '+ Cast(@rows AS VARCHAR)
    -- Please note Databse names are going to remain the same but table names and join conditions on keys
    -- should vary for each table(s) being configured in master tables
    Sample of Master configuration tables with table info and PK Info :
    Table Info         
    Table_info_ID    Table_Name    
    1        lp_order    
    7        lp__transition_record    
    Table_PK_Info        
    Table_PK_Info_ID    Table_info_ID    PK_Column_Name
    2                1    order_id
    8                7    transition_record_id
    There can be more than one join condition for each table
    Thanks you !
    Rajkumar Yelugu

    Hi Rajkumar,
    It is glad to hear that you figured the question out by yourself.
    There's a flaw with your while loop in your sample code, just in case you hadn't noticed that, please see below.
    --In this case, it goes to infinite loop
    DECLARE @T TABLE(ID INT)
    INSERT INTO @T VALUES(1),(3),(2)
    DECLARE @ID INT
    SELECT @ID = MIN(ID) FROM @T
    WHILE @ID IS NOT NULL
    PRINT @ID
    SELECT @ID =ID FROM @T WHERE ID > @ID
    So a cursor would be the appropriate option in your case, please reference below.
    DECLARE @Table_Info TABLE
    Table_info_ID INT,
    Table_Name VARCHAR(99)
    INSERT INTO @Table_Info VALUES(1,'lp_order'),(7,'lp__transition_record');
    DECLARE @Table_PK_Info TABLE
    Table_PK_Info_ID INT,
    Table_info_ID INT,
    PK_Column_Name VARCHAR(99)
    INSERT INTO @Table_PK_Info VALUES(2,1,'order_id'),(8,7,'transition_record_id'),(3,1,'order_id2')
    DECLARE @SQL NVarchar(MAX),
    @ID INT,
    @Table_Name VARCHAR(20),
    @whereCondition VARCHAR(99)
    DECLARE cur_Tabel_Info CURSOR
    FOR SELECT Table_info_ID,Table_Name FROM @Table_Info
    OPEN cur_Tabel_Info
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    WHILE @@FETCH_STATUS = 0
    BEGIN
    SELECT @whereCondition =ISNULL(@whereCondition+' AND ','') +'t1.'+PK_Column_Name+'='+'t2.'+PK_Column_Name FROM @Table_PK_Info WHERE Table_info_ID=@ID
    SET @SQL = 'INSERT INTO hub.dbo.'+@Table_Name+'
    SELECT * FROM del.dbo.'+@Table_Name+' AS T1
    WHERE NOT EXISTS (
    SELECT *
    FROM hub.dbo.'+@Table_Name+' AS T2
    WHERE '+@whereCondition+')'
    SELECT @SQL
    --EXEC(@SQL)
    SET @whereCondition = NULL
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    END
    Supposing you had noticed and fixed the flaw, your answer sharing is always welcome.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Table and Primary Key Case Sensitive in Automated Row Fetch

    Why are the table and primary key fields case sensitive in the Automated Row Fetch process? I'm debugging an error in this process and I'm not sure what the case should be.

    Russ - It's a defect of sorts. Use upper case in the process definition. I don't think these processes will work with tables or columns whose names are not known to the database as upper-case values, i.e., defined using double-quoted non-upper case.
    Scott

  • UNIQUE INDEX and PRIMARY KEYS

    Hi Friends,
    I am confused about primary keys.
    What is the purpose of this key again? I know it is used for unique constraints.
    Supposing I have a table with two (2) columns which are each indexed as unique.
    Then they can me both candidate at primary key right?
    So why do I need a primary key again? when I have 2 columns which are uniquely index?
    Thanks a lot

    A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. This constraint does not apply to NULL values except for the BDB storage engine. For other engines, a UNIQUE index allows multiple NULL values for columns that can contain NULL
    The differences between the two are:
    1. Column(s) that make the Primary Key of a table cannot be NULL since by definition; the Primary Key cannot be NULL since it helps uniquely identify the record in the table. The column(s) that make up the unique index can be nullable. A note worth mentioning over here is that different RDBMS treat this differently –> while SQL Server and DB2 do not allow more than one NULL value in a unique index column, Oracle allows multiple NULL values. That is one of the things to look out for when designing/developing/porting applications across RDBMS.
    2. There can be only one Primary Key defined on the table where as you can have many unique indexes defined on the table (if needed).
    3. Also, in the case of SQL Server, if you go with the default options then a Primary Key is created as a clustered index while the unique index (constraint) is created as a non-clustered index. This is just the default behavior though and can be changed at creation time, if needed.
    So, if the unique index is defined on not null column(s), then it is essentially the same as the Primary Key and can be treated as an alternate key meaning it can also serve the purpose of identifying a record uniquely in the table.

  • Logical standby and Primary keys

    Hi All,
    Why primary keys are essential for creating logical standby database? I have created a logical standby database on testing basis without having primary keys on most of the tables and it's working fine. I have not event put my main DB in force logging mode.

    I have not event put my main DB in force logging mode. This is because, redo log files or standby redo logfiles transforms into set of sql statements to update logical standby.
    Have you done any DML operations with nologging options and do you notice any errors in the alert.log? I just curious to know.
    But I wanted to know that, while system tablespace in hot backup mode,In the absence of both a primary key and a nonnull unique constraint/index, all columns of bounded size are logged as part of the UPDATE statement to identify the modified row. In other words, all columns except those with the following types are logged: LONG, LOB, LONG RAW, object type, and collections.
    Jaffar

  • Null in Composite Primary Key and "Primary keys must not contain null"

    Hello all.
    I'm a newbie concerning to JPA/EJB3, but I was wondering if toplinks doesn't support composite primary keys with null in some field (something perfectly right in any RDBMS).
    I used JDeveloper (I'm using Oracle 10g database and JDeveloper 10.1.3.2.) wizards to generate JPA classes and I checked out generated files (with annotations), so they should be right (by the way, other O-R mappings for my model are working right, but this one).
    I'm getting the next error:
    Exception Description: The primary key read from the row [DatabaseRecord(
         TSUBGRUPOSLDI.CD_GRUP => 01
         TSUBGRUPOSLDI.CD_SUBGRUP => null
         TSUBGRUPOSLDI.CG_POBL => 058
         TSUBGRUPOSLDI.CG_PROV => 28
         TSUBGRUPOSLDI.DSCR => Sanidad)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Compound primary key is (CD_GRUP, CD_SUBGRUP). No foreign keys, no joins (only a NamedQuery: "select o from ..."). It's the simplest case!
    I checked out that everything runs ok if there's no "null" value in CD_SUBGRUP.
    After some research (this and other forums) I'm beginning to believe that it's not supported, but not sure.
    Am I doing sth wrong? If not, what is the reason to not support this? Will it be supported in the future?
    Thanks in advance.

    Null is a special value and in many databases is not comparable to another null value (hence the isNull operator) and may pose problems when used to uniquely identify an Entity. TopLink does not support null values within a composite PK. As the nullable column is most likely not designated as a PK within your database table (many databases do not allow this) I recommend updating the Entity PKs to match that of the database.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Diff b/w surragate keys and primary keys

    Can any one of u pls explain the difference between primary key and surragate keys,pls explain me with simple example

    Hi rajesh,
    surrogate key: For every master data record, system create a SID (Surrogate ID). If that particular master data record is used in infocube, system store the SID corresponding to that master data in dimension table and the dimension id of the dimension table is stored in infocube Fact 'F' table.
    Primary key: while creating a table we will select unique field and create as primary key..for eg empid acts as a unique key (primary key) for emp table. through this primary key we can identify the table to get the data from the table.
    i hope this helps u.
    regards
    anil

  • Problem with foreign and primary keys migration from SQL Server to Oracle

    Hi folks, i'm using SQL Developer to migrate from a SQL Server database to Oracle and i'm stuck with a couple issues:
    The worst of them so far is the fact that i can't migrate any of the PKs and FKs. After successfully capturing the SQL Server DB model and converting it to Oracle, when the tool generates the scripts, all ALTER TABLE queries that add the PKs and FKs have their target columns duplicated.
    for example: when i'm trying to migrate a simple table that contains an Id (PK) and Name columns, the tool generates the following scripts:
    PROMPT Creating Table TestTable...
    CREATE TABLE TestTable (
    Id NUMBER(10,0) NOT NULL,
    Name VARCHAR2 NOT NULL
    PROMPT Creating Primary Key Constraint PK_TestTable on table TestTable ...
    ALTER TABLE TestTable
    ADD CONSTRAINT PK_TestTable PRIMARY KEY
    Id,
    Id
    ENABLE
    As for the FKs, the tool duplicates the columns as well:
    ALTER TABLE SomeTable
    ADD CONSTRAINT FK_SomeTable_SomeTable2 FOREIGN KEY
    SomeTable2Id,
    SomeTable2Id
    REFERENCES SomeTable2
    Id,
    Id
    ENABLE
    Does anyone have a clue on how to solve these issues? I'd be greatly thankful for any answers!

    Hi Fernando,
    I was unable to replicate this issue. My primary / foreign keys where defined using unique columns.
    PROMPT Creating Primary Key Constraint PK_Suppliers on table Suppliers ...
    ALTER TABLE Suppliers
    ADD CONSTRAINT PK_Suppliers PRIMARY KEY
    SupplierID
    ENABLE
    I tried a few things like
    capturing twice and renaming both models the same
    renaming the converted models
    but with no luck.
    I think this issue is occuring either at the capture or convert phase.
    1) Are you performing the capture online or offline?
    2) Can you provide a the entire DDL for one of these tables and its indexes to see if I can replicate?
    3) Did the capture or convert fail or have to be redone at any stage ?
    I all else fails I would attempt a capture and convert again using a brand new repository (create a new schema in Oracle and associate the migration repository with it).
    Regards,
    Dermot
    SQL Developer Team
    Edited by: Dermot ONeill on Oct 22, 2009 12:18 PM

  • IOTs and primary keys

    hi,
    I am reading chapter 10 of expert oracle database architecture by tom kyte, and I am getting a little confused. It seems to me as if he is saying that an IOT should be built using the PK of that table. What if our table does not have a PK?
    thanks

    OracleGuy777 wrote:
    hi,
    I am reading chapter 10 of expert oracle database architecture by tom kyte, and I am getting a little confused. It seems to me as if he is saying that an IOT should be built using the PK of that table. What if our table does not have a PK? Then you can not create an IOT. It's a rule. http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#i23877
    One of the suggestions is 'try it'. So let us do exactly that - create 2 nearly idetical IOTs - one with and the second without a primary key
    SQL*Plus: Release 10.2.0.1.0 - Production on Sun Nov 1 11:07:37 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> CREATE TABLE countries_demo
      2      ( country_id      CHAR(2)
      3        CONSTRAINT country_id_nn_demo NOT NULL
      4      , country_name    VARCHAR2(40)
      5      , currency_name   VARCHAR2(25)
      6      , currency_symbol VARCHAR2(3)
      7      , region          VARCHAR2(15)
      8      , CONSTRAINT    country_c_id_pk_demo
      9                      PRIMARY KEY (country_id ) )
    10      ORGANIZATION INDEX
    11  /
    Table created.
    SQL> edit
    Wrote file afiedt.buf
      1  CREATE TABLE countries_demo2
      2      ( country_id      CHAR(2)
      3        CONSTRAINT country_id_nn_demo NOT NULL
      4      , country_name    VARCHAR2(40)
      5      , currency_name   VARCHAR2(25)
      6      , currency_symbol VARCHAR2(3)
      7      , region          VARCHAR2(15) )
      8*     ORGANIZATION INDEX
    SQL> /
        ORGANIZATION INDEX
    ERROR at line 8:
    ORA-25175: no PRIMARY KEY constraint found
    SQL>SO the conclusion is, whether it makes sense to us or not, we can not create a table without defining a primary key.
    It makes sense to me, since the IOT is actually stored as a unique index with nulls not allowed - for which a PK is a perfect fit. Note that a PK COULD be defined with multiple columns instead of the traditional single column (and often wrong surrogate key)

  • APEX and Primary Keys

    Hello:
    I ran into a situation where we have a table with no primary key set. When I tried to create a form, APEX told me that a primary key must be set in order to run reports. This makes complete sense. No issue here. For some of our tables, we can set the primary key.
    The issue we have is that some of our tables are using "natural primary keys". We have tables where more than one column is designated as a primary key. For example, if I have a table with patient_id, organization_id, insurance_id, and expiration date. In order for a record to be unique in this table both the organization_id and insurance_id are set as primary keys.
    If I attempt to create a form in APEX using these tables which have more than one primary key, how will APEX know that there are more than one primary key?
    Thanks for the input.

    In that case you could also use rowid and instead of views. I have an example showing how
    this can be done:
    http://apex.oracle.com/pls/otn/f?p=31517:157
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Unique or primary key on timestamp with timezone

    Hi,
    I have been experimenting with a date column in a primary key, or actually I tried using a timestamp with time zone in a primary key.
    While researching whether there was a way to avoid ORA-02329, I found the following:
    K15> create table dumdum
      2    (datum date not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> alter table dumdum
      2    add constraint d_pk
      3        primary key
      4          (datum, naamp)
      5    using index;
    Table altered.
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_PK';
    INDEX_TYPE
    NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select sysdate - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_pk validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
      4 
    K15> For the last select statement I get the following "explain plan":
    SELECT STATEMENT  CHOOSE
              Cost: 2  Bytes: 247  Cardinality: 13       
         1 INDEX RANGE SCAN UNIQUE D_PK
                    Cost: 3  Bytes: 247  Cardinality: 13  This behavior lived up to my expectations.
    Then, I tried this:
    K15> create table dumdum
      2    (datum date not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> alter table dumdum
      2    add constraint d_pk
      3        primary key
      4          (datum, naamp)
      5    using index;
    Table altered.
    K15>
    K15> alter table dumdum
      2        modify datum timestamp(6) with time zone;
    Table altered.
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_PK';
    INDEX_TYPE
    NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select sysdate - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_pk validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.46.16', 'dd-mm-yyyy hh24.mi.ss' )
      4
    K15> So, at first glance, the alter table statement to change the datatype from DATE to TIMESTAMP seems like a way of fooling Oracle. But the explain plan reveals a different story:
    SELECT STATEMENT  CHOOSE
              Cost: 4  Bytes: 1,25  Cardinality: 50       
         1 TABLE ACCESS FULL DUMDUM
                    Cost: 4  Bytes: 1,25  Cardinality: 50  I was only fooling myself. :-0
    But I wasn't done with my research:
    K15> create table dumdum
      2    (datum timestamp(6) with time zone not null
      3    ,naamp varchar2( 30 ) not null);
    Table created.
    K15>
    K15> create unique index d_ind
      2      on dumdum
      3           (datum, naamp);
    Index created.
    K15>
    K15>
    K15> select ind.index_type
      2  from   user_indexes ind
      3  where  ind.index_name = 'D_IND';
    INDEX_TYPE
    FUNCTION-BASED NORMAL
    1 row selected.
    K15>
    K15> insert into dumdum
      2    (datum
      3    ,naamp )
      4  select systimestamp - (level/1440)
      5  ,      'nomen nescio'
      6  from   dual
      7  connect by level < 1000
      8  ;
    999 rows created.
    K15>
    K15> analyze index d_ind validate structure;
    Index analyzed.
    K15> analyze table dumdum compute statistics;
    Table analyzed.
    K15>
    K15> select naamp
      2  from   dumdum
      3  where  datum > to_date('16-06-2011 15.56.16', 'dd-mm-yyyy hh24.mi.ss' )
      4
    K15>Now, my explain plan looks fine:
    SELECT STATEMENT  CHOOSE
              Cost: 2  Bytes: 1,25  Cardinality: 50       
         1 INDEX RANGE SCAN UNIQUE D_IND
              Cost: 3  Bytes: 1,25  Cardinality: 50  Why is Oracle so adamant about not allowing a timestamp with time zone in a unique key? And, given their position on the matter, where does their tolerance for a unique index come from?
    By the way, if I had a say in it, I would not allow anything that even remotely looks like a date to be part of a primary key, but that's another discussion.
    Thanks,
    Remco
    P.S. All this is on Oracle9i Enterprise Edition Release 9.2.0.8.0. Is it different on 10g or 11g?

    See if this helps. You can create primary key for TIMESTAMP WITH LOCAL TIME ZONE datatype.
    SQL>CREATE TABLE Mytimezone(Localtimezone TIMESTAMP WITH LOCAL TIME ZONE primary key, Location varchar2(20) );
    Table created.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006169
    TIMESTAMP WITH LOCAL TIME ZONE Datatype
    TIMESTAMP WITH LOCAL TIME ZONE is another variant of TIMESTAMP. It differs from TIMESTAMP WITH TIME ZONE as follows: data stored in the database is normalized to the database time zone, and the time zone offset is not stored as part of the column data. When users retrieve the data, Oracle returns it in the users' local session time zone. The time zone offset is the difference (in hours and minutes) between local time and UTC (Coordinated Universal Time, formerly Greenwich Mean Time).
    Thanks
    http://swervedba.wordpress.com/

  • What is the diffrence between Row id and primary key ?

    dear all
    my question is about creating materialized views parameters (With Rowid and
    With Primary kry)
    my master table contains a primary key
    and i created my materialized view as follow:
    CREATE MATERIALIZED VIEW LV_BULLETIN_MV
    TABLESPACE USERS
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    SELECT
    BCODE ID, BTYPE BTYPE_ID,
    BDATE THE_DATE,SYMBOL_CODE STOCK_CODE,
    BHEAD DESC_E, BHEADARB DESC_A,
    BMSG TEXT_E, BMSGARB TEXT_A,
    BURL URL, BTIME THE_TIME
    FROM BULLETIN@egid_sefit;
    I need to know is there a diffrence between using (with row id) and (with primary key) on the performance of the query?

    Hi again,
    fast refreshing complex views based on rowids, according to the previous subject.
    (You're example shows that) are not possible.
    Complex remote (replication) snapshots cannot be based on Rowid too.
    for 10.1
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm#sthref5054
    for 10.2
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6002.htm#sthref6873
    So I guess (didn't check it) that this applies ONLY to replication snapshots.
    This is not documented clearly though (documentation bug ?!)
    Documentation states that the following is generally not possible with Rowid MVIEWS:
    Distinct or aggregate functions
    GROUP BY or CONNECT BY clauses
    Subqueries
    Joins
    Set operations
    Rowid materialized views are not eligible for fast refresh after a master table reorganization until a complete refresh has been performed.
    The main purpose of my statements was to try to give a few tips how to avoid common problems with this complex subject, like for example: being able to CREATE an MVIEW with fast refresh clause does not really guarantee that it will refresh fast in the long run (reorganisation, partition changes) if ROWID based, further the rowid mviews have limitations according to the documentation (no group by, no connect by, link see above) plus fast refresh means only to use filter columnns of the mview logs, plus for aggregates you need additional count (*) pseudo columns.
    kind regards
    Karsten

  • Problem with type conversion and primary key during row fetch

    [Note, this error occurs in Oracle XE, APEX 2.1.0.00.39]
    I have been having a problem with Automatic Row Fetch:
    ORA-01460: unimplemented or unreasonable conversion requested
    So in an effort to resolve this, I created a PL/SQL process with the query below and was able to isolate the same error. The problem seems to come from one of the primary keys being a "number" type (APP_ID). The error occurs on the line:
    where u.app_id=:P5_APP_ID
    I have tried the following variations on this line in an effort to resolve this, but all generate the same error:
    1) where to_char(u.app_id) = :P5_APP_ID
    2) where u.app_id = to_number(:P5_APP_ID)
    3) where to_char(u.app_id) = to_char(:P5_APP_ID)
    I've also tried the laternate syntax "&__." and "#__#", but these don't function in the Source field and show up as syntax errors.
    Any suggestions are welcome.
    begin
    for r in (
    select app_name, apptype, appcreator, appurl
    from application_users u, application_info i
    where u.app_id=:P5_APP_ID
    and i.app_id=u.app_id
    and u.username=:P5_USERNAME)
    loop
    begin
    :P5_APP_NAME := r.app_name;
    :P5_APPURL := r.appurl;
    exception
    when others then
    raise_application_error(-20000,'In Loop Failure',true);
    end;
    end loop;
    exception
    when others then
    raise_application_error(-20000,'Out of Loop Failure',true);
    end;
    Thanks in advance,
    Barney

    I found a prior post referencing a similar issue and it was solved by using the "v(__)" syntax. This did resolve my issue, however, I have a quick follow-on which I'm hoping someone can answer quickly...
    Since the "v(__)" syntax won't work for the Automatic Row Fetch (at least to the best of my knowledge), I have to do a manual process. However, the manual query as shown above doesn't actually populate any of the form values through the bind variables. They all remain at their cached values from prior data entry on the form.
    Is using the bind variables for assignment incorrect, or is there something that must be done to get the updates to show up in the form (ordering of processes, etc.).
    My manual process is running in the Load: Before Header state so I would have expected it to update all of the fields.
    Thanks in advance,
    Barney

Maybe you are looking for