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>
Similar Messages
-
Difference between unique constraint and unique index
1. What is the difference between unique constraint and unique index when unique constraint is always indexed ? Which one is better in this case for better performance ?
2. Is Composite index of 3 columns x,y,z better
or having independent/ seperate indexes on 3 columns x,y,z is better for better performance ?
3. It has been very confusing for me to decide which columns to index, I have indexed most foreignkey columns, is it a good idea ? We do lot of selects and DMLS on most of our tables. Is there any query that I can run and find out if indexes are really being used and if they are improving any performance. I have analyzed and computed my indexes using ANALYZE index index_name validate structure and COMPUTE STATISTICS;
null1. Unique index is part of unique constraint. Of course you can create standalone unique index. But is is no point to skip the logical view of business if you spend same effort to achive.
You create unique const. Oracle create the unique index for you. You may specify index characteristic in unique constraint.
2. Depends. You can't utilize the composite index if the searching condition is not whole or front part of the indexing key. You can't utilize your index if you query the table for y=2. That is.
3. As old words in database arena, Index may be good or bad for a table depending on the size of table, number of columns in the table... etc. It is very environmental dependent. In fact, It is part of database nomalization. Statistic is a way oracle use to determine the execution plan.
Steve
null -
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 -
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 lotA 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. -
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 -
Difference between Dimension Id and Dimension Key
I am reading the third chapter of Rittman's OBIEE book on design of Repository.
It says while building the BMM, don't drag the dimension Id columns from physical layer to logical layer as the BI Server takes care of the join for you but make sure you drag across the dimension key columns as you will need these later on to create your logical table keys.
Can someone enlighten me on what is the difference between a dimension id and dimension key (may be with an example).
Thanks.Besides the theory says that a fact table can reference any level of a dimension, I couldn't do it with OWB. I don't know if there is a specific way to do that, but I only could assign a dimension detail level to a fact table.
The ID's can have different values when I use a hierarchy in a dimension. OWB generates automatically negative ID's for the more summarized levels.
For example, a product dimension with 2 levels: category and detail. If the product has 4 categories and 20 products (detail level), the table has 4 rows for categories with negative id's. Each row has a category and the fields specific for detail level are empty. The table will have other 20 rows for the detail level, with all fields filled, and all id's positive. The table will have 24 rows in the end. -
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 -
Hi
When I am trying to define Update Key which is the other name for Alternate Key, then the primary key symbol (key) which is defined just beside my primary key column ( customer id) gets dissappeared and the new key symbol comes up besides the update key columns("marital status,salary and address")
Now why this happens and how to tackle.
In my project Customer id is a primary key which is responsible for insert of new records if not already presnt in the target table and the three other fields "marital status,salary and address" columns are responsible for update but these are not primary or composite keys.Can anyone tell me the difference in terms of how oracle update mechanism work in both the case.Not sure what you're asking.
Have you done an explain plan for each statement? -
Display the foreign keys and primary keys in hirarchy qeury please ?
Any sql query to get the following columns:
I should display all the master table names,it's primary key field and its foregin key field,the name of the foreignkey'table.
This should be displayed in hirarchy i.e. it should start from the top level table like upside down tree.
can we query the database like this
thanx in advance
prasanth a.s.hi there,
Please can any body help in this query!
Thanxs in advance
prasanth a.s. -
MM - Difference between Info Record and Price/Discounts/Others Conditions
Hi All,
In MM we use transactions like ME11 to maintain info record. In such transactions we can handle condition types PB00, RA00, FRB1, etc to specify price, discount and freight cost.
But we also can use transactions like MEK1 to create conditions, or use transactions like MEKE to create discount conditions by vendor.
What's the difference between ME11 and MEKE?
Thanks + Best Regards
JeromeHi Jerome,
ME11 is for vendor/material/purch org combination
whereas MEKE is for vendor/purch organisation only. So it will be applicable for all materials supplied by the vendor.
regards
Anand.C
Message was edited by:
Anand Chidambaram -
Difference between database, websheet and packaged applications
Hi,
Can any one explain the difference between database, websheet and packaged applications?
So far i have worked on database application and not aware of the other applications.
Regards
Narender BNarender wrote:
Can any one explain the difference between database, websheet and packaged applications?
So far i have worked on database application and not aware of the other applications.
This is fully covered in the documentation:
About Database Applications
About Websheet Applications
About Packaged Applications
There is little difference between packaged applications and database applications, other than that packaged applications are supplied by Oracle and database applications are created by you. -
column with unique constraint + not null constraint = primary key! (to some extent) Is it correct?
I invite your ideashttp://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) -
Primary Key and Chronological Key for Time Dimension
Could someone please shed light whether it's better to use normal PK or Calendar Date (which is a chronological key on the most detailed level). I tried both and haven't noticed any difference. But my understanding is that I still need to have the PK key on the most detailed level in time hierarchy.
ThanksMatt,
the PK of the Time Dimension is a regular sequence numeric key. I have it defined as a logical PK for the dimension. However, I guess I was talking about hierarchy key. I tested it either way and the query time is the same. So I guess it doesn't really matter.
--------Year
Year (chronological key and primary key)
------------------Quarter
Quarter (key)
Quarter+Year (primary key, chronological key)
---------------------------------Day Detail
PK (key)
Date (primary key , chronological key)
I hope it makes sense. -
Difference Between Unique Index vs Unique Constraint
Can you tell me
what is the Difference Between Unique Index vs Unique Constraint.
and
Difference Between Unique Index and bitmap index.
Edited by: Nilesh Hole,Pune, India on Aug 22, 2009 10:33 AMNilesh Hole,Pune, India wrote:
Can you tell me
what is the Difference Between Unique Index vs Unique Constraint.http://www.jlcomp.demon.co.uk/faq/uk_idx_con.html
and
Difference Between Unique Index and bitmap index.The documentation is your friend:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#CNCPT1157
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref1008
Regards,
Rob. -
What is difference between adobe photoshop and photoshop extended cs5
what is difference between adobe photoshop and photoshop extended cs5
Hi,
The biggest difference is the 3D feature set is only available in Ps Extended CS5. Exclusive to Extended CS5 also are timeline for video editing, Dicom format support, Stack mode blending, analysis measurement tools, and some 32-bit painting capabilities.
Some things have changed for the Photoshop Extended CS6 version, mainly enabling more of the video editing features for both products.
regards,
steve
Maybe you are looking for
-
How can I get the username displayed in BW Web-Report?
Hello all, I try to get the username displayed in BW-Report such as 'welcome <username>'. Maybe you can give me a suggestion how to do it. I appretiate your answer. Regards Vivian
-
How to add src, alt and title tags to a PS generated Web Photo Gallery
I do some web design and need to add some tags to a web photo gallery created by Photoshop. Maybe this question should be directed to the GoLive / Dreamweaver Forum but since the gallery was created in PS I thought I'd start here. I need to add src,
-
I received an Acrobat Pro update notification and started the update process. Update failed and the message said it needed to uninstall and reinstall Acrobat Pro. I followed Adobe’s advice. But I have not been able to get Acrobat Pro to finish instal
-
I evidently need to install Flash, according to everything animated I've tried to view, but efforts to do so have been unsuccessful (or it's installed but not in the right place? ) I see from forums I've visited that this is an ongoing issue with iM
-
Is a Screen protector necessary for N8?
Although I do have a good screen protector fitted (lcd adheres by vacuum), I was wondering if it's really necessary as it's fitted with Gorilla toughen glass? Do any of you N8 users use one?