cannot CREATE UNIQUE INDEX; duplicate keys found [duplicate] - oracle

This question already has answers here:
How do I find duplicate values in a table in Oracle?
(13 answers)
Closed 6 months ago.
I have a problem when I tried to create a unique index
CREATE UNIQUE INDEX "PITEST000002_500"."IX_BBF3E90F" ON
"PITEST000002_500"."FRIENDLYURLENTRYLOCALIZATION"
("FRIENDLYURLENTRYID","LANGUAGEID","CTCOLLECTIONID");
I get the following error :
Error report -
ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
01452. 00000 - "cannot CREATE UNIQUE INDEX; duplicate keys found"
*Cause:
*Action:
The reason as I understood is I have some duplicated values.
The question is, how do I know what are the values that cause the issue ?
Anyone can help please ?

Just run a query that shows the values that appear in multiple rows
select "FRIENDLYURLENTRYID","LANGUAGEID","CTCOLLECTIONID", count(*)
from "PITEST000002_500"."FRIENDLYURLENTRYLOCALIZATION"
group by "FRIENDLYURLENTRYID","LANGUAGEID","CTCOLLECTIONID"
having count(*) > 1

Related

How to display page wise records in Oracle Database? [duplicate]

This question already has answers here:
How do I limit the number of rows returned by an Oracle query after ordering?
(14 answers)
Paging with Oracle
(7 answers)
Closed 7 months ago.
I have one table with name emp with columns id, name, address. I want SELECT records first 10 and then next 10 and so on depends on the variable. Please let me know how can I achieve this?
You can use below SELECT statement:
SELECT * FROM EMP where rownum between 1 and 10;
You can use 1 and 10 as two variables and replace it dynamically.

Sequence associated with an Oracle table [duplicate]

This question already has answers here:
Sequence number in table
(2 answers)
Closed 5 years ago.
I would like to know if there is a way to find out which sequences are associated with a given Oracle table.
There is no way in general, short of searching the source code or v$sql or finding common dependencies in all_dependencies, because sequences created with create sequence are independent objects that you can use however you like.
From Oracle 12.1, if you define an identity column this will generate a system-defined sequence with a name like ISEQ$$_1744544. You can find these in all_tab_identity_cols together with the table and column they were created for.

ORA-00904: Invalid identifier - Creating a simple table [duplicate]

This question already has an answer here:
Create table error - invalid identifier
(1 answer)
Closed 9 years ago.
I'm trying to create a simple table, but I'm receiving error:
ORA-00904 - invalid identifier
and I'm not sure why. I don't see anything that could be causing the issue (using Oracle 11g Express):
CREATE TABLE Measurements(
MeasureAmountID SMALLINT PRIMARY KEY,
MeasurementDescription VARCHAR(255),
);
Remove the comma at the end and try,
CREATE TABLE Measurements(
MeasureAmountID SMALLINT PRIMARY KEY,
MeasurementDescription VARCHAR(255)
);

Is there any alternate solution of IN Clause for more than 1000 values [duplicate]

This question already has answers here:
How to put more than 1000 values into an Oracle IN clause [duplicate]
(11 answers)
Closed 9 years ago.
I want to use more than 1000 value with IN Clause that is not supported by this clause. eg.
select prodCode from Products where prodId IN (1,2,3.....,1020);
Can someone suggest me for any alternate solution??
Where did the values for prodId that you are putting into your IN clause originate from?
If they originated from another query, then you should combine the two queries.
If they originated from some complicated process or an external data source, then you should store them in a temporary table. The temporary table can just contain a prodId column. Join to that table instead of using an IN list.

How to retrieve the last inserted record in Oracle [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to get the last row in a table - Oracle 11g?
I would like to know how we can get the last inserted record values back as I want to retrieve and see the details that are inserted at last in the table
insert into mytable (...) values (...)
returning id into v_id;
If you have a primary key:
select * from YOURTABLE
where primary_key=(select max(primary_key) from YOURTABLE)

Resources