Need Query for empty partitions
I am having nearly 700 partitions for a table.Now i want to find out only the empty partitions.I need query for that.
Thankx..
Not the most elegant solution, but it works:
declare
rc number;
str varchar2(200);
begin
for i in (select table_owner, table_name, partition_name from dba_tab_partitions) loop
str := 'select count(*) from ' || i.table_owner || '.' || i.table_name || ' partition (' || i.partition_name || ')';
execute immediate str into rc;
if rc = 0 then
dbms_output.put_line(i.table_owner || '.' || i.table_name);
end if;
end loop;
end;
Similar Messages
-
I am trying to execute the following SQl query, SELECT * FROM Failure WHERE ID = '123' AND RepairAction = ' ';, using the DB Tools Execute Query.vi. This query never finds the record in my database. My database contains a record where the ID filed contains the value of '123' and the RepairAction field is an empty string. If I remove the 'AND RepairAction ' ';' text from my query statement, the record is found. I believe my problem is that I am not using the correct syntax to describe and empty string. I have tried the following: '', ' ', "", " ", and NULL as empty string arguments, and none of these work.
I was hoping someone might be able to tell me what the correct syntax is for an empty string or if there is another approach I need to take.
Thank you in advance for your help,
Jim
Solved!
Go to Solution.Hi,
While creating your table "Failure", was the column "ID" delclared as intiger or varchar? If it is intiger and you use '123' , it wont return the results. You will have to try without the inverted comas ' '.
Regards,
Nitzz
(Giver Kudos to good Answers, Mark it as a solution if your problem is Solved) -
Query for Empty Tables.
Hi All,
Can someone tell me a Query to find out "EMPTY TABLES i.e. Tables having no Rows" in Oracle 8i ?
I tried on Google, but results are not satisfactory, may be due to 8i version.
Please guide me.
Regards.982164 wrote:
Hi Hoek,
Actually we upgraded our database to 11g.
We imported our data from 8i to 11gr2 by the utility IMP successfully.
It imported our data 100% i.e. when we import 8i dmp data into 11g, there is never problem.
Problem is arises now when we further use IMP/EXP utility in 11g.So everything in Oracle 8 is working the way you expect. The fact that you also have an Oracle 8 database has nothing to do with this problem. Is that what you're saying?
When we run EXP utlity in 11g, it doesn't export empty tables.If the problem is entirely in Oracle 11, then you should be able to use something like XMLQUERY to find the 0-row tables, if you really need to. (I think you don't.)
EXP can export tables with 0 rows. I just tried it in Oracle 11, and part of the feedback I got was:
. . exporting table ZIPCODES 0 rows exported
. . exporting table ZONEORDER_TBL 5 rows exported
. . exporting table ZONE_TBL 6 rows exported
. . exporting table ZOO 2 rows exported
. . exporting table Z_HIERARCHY 3 rows exported
. . exporting table Z_TEST 3 rows exported
. . exporting table Z_TEST4 0 rows exportedIf it's not exporting 0-row tables for you, find out why, and fix that problem. Post your exp control file.
Someone told me to insert atleast 1 row in the empty tables, then they will be exported.And then, after importing them, TRUNCATE those tables? That's a lot of work.
That's why I m searching of the Empty Tables.
Am I going right way ?I don't think so.
Find and fix the problem with exp.
If you can't get exp to work, then look into data pump. -
Need Query for Item Relationship of Oracle Apps
Hello Team,
I need the Query to select the Item Relationship.
In Oracle Apps we have different tyes of Structure
ItemA -> ItemB
ItemB -> ItemC
ItemC -> ItemD
ItemG -> ItemH
ItemK -> ItemL
ItemW -> ItemQ
and this also is possible (meand many to one relationship)
ItemA -> ItemB
ItemB -> ItemC
ItemC -> ItemD
ItemT -> ItemD
and in the Select Query i want the below result
ItemA -> ItemB 1
ItemB -> ItemC 2
ItemC -> ItemD 3
ItemG -> ItemH 1
ItemK -> ItemL 2
ItemW -> ItemQ 1
and this also is possible (means many to one relationship)
ItemA -> ItemB 1
ItemB -> ItemC 2
ItemC -> ItemD 3
ItemT -> ItemD 1
means i want the Hierarchy number also
Please help me to in order to get the relationship by sql query.
Kind Regards,thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today. i'll do that now though.
what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system. there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc? -
Need query for requistion and rfq numbers
Dear All,
I need a query to list all requisition number for which RFQ is created and RFQ is partially converted to PO, if RFQ is fully converted to PO, it should not fetch the details.please help me on this.
Thanks
DebendraAre you referring to sourcing RFQ or core quotations?
-
Report Builder Version:10g
Hi Guys Good Morning to one and all
I have a table Named Onlsuvdet which captures the answers from
an online survey front end which has multiple choice questions.
the table structure is as follows
create table onlsuvdet(shloid number,questno char(5),respo1 char(5),respo2 char(5));
and the sample data is as follows
SHLOID QUEST RESPO RESPO
9315 1 2
9315 2 3
9315 3 4
9315 3 5
9315 4 1
9315 5 2
9315 5 1
Now i want the result as follows
shlogid quest1 quest2 q3 q4 q5
9315 2 3 4,5 1 2,1
So my requirement is a query which displays this data as above.
Please helpppp
Any help will be appreciated :)
Thanks & RegardsHi,
user123 wrote:
Report Builder Version:10g
Hi Guys Good Morning to one and all
I have a table Named Onlsuvdet which captures the answers from
an online survey front end which has multiple choice questions.
the table structure is as follows
create table onlsuvdet(shloid number,questno char(5),respo1 char(5),respo2 char(5));Thanks for posting the CREATE TABLE statement. That helps.
Why are you using the CHAR datatype, rather than VARCHAR2? CHAR is nothing but trouble.
and the sample data is as follows
SHLOID QUEST RESPO RESPO
9315 1 2
9315 2 3
9315 3 4
9315 3 5
9315 4 1
9315 5 2
9315 5 1Always post your data in a form people can use to re-create the problem and test their solutions. for example:
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '1 ', '2 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '2 ', '3 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '3 ', '4 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '3 ', NULL, '5 ');
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '4 ', '1 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '5 ', '2 ', NULL);
INSERT INTO onlsuvdet (shloid, questno, respo1, respo2) VALUES (9315, '5 ', NULL, '1 ');I'm making a lot of guesses about the data. for example, I'm guessing there will never be more than 2 rows with the same shloid and questno.
Why do you have 2 columns, respo1 and respo2? Is exactlyly one of them always NULL? If respo1 is NULL, will there always be another row with the same shloid and questno, but with a NULL respo2?
Now i want the result as follows
shlogid quest1 quest2 q3 q4 q5
9315 2 3 4,5 1 2,1Be consistent with the column names; either call them all questn (like I did below) or call them all qn.
So my requirement is a query which displays this data as above.Perhaps something like this:
WITH joined_data AS
SELECT r1.shloid
, r1.questno
, RTRIM ( r1.respo1 || ',' || r2.respo2
) AS respo
FROM onlsuvdet r1
LEFT OUTER JOIN onlsuvdet r2 ON r1.shloid = r2.shloid
AND r1.questno = r2.questno
AND r1.respo1 IS NOT NULL
AND r2.respo2 IS NOT NULL
SELECT shloid
, MAX (CASE WHEN questno = '1 ' THEN respo END) AS quest1
, MAX (CASE WHEN questno = '2 ' THEN respo END) AS quest2
, MAX (CASE WHEN questno = '3 ' THEN respo END) AS quest3
, MAX (CASE WHEN questno = '4 ' THEN respo END) AS quest4
, MAX (CASE WHEN questno = '5 ' THEN respo END) AS quest5
FROM joined_data
GROUP BY shloid
I hope this answers your question.
If not, point out a few places where the query above gets the wrong results. Post the correct results (formatted, between \ tags, as explained in the FAQ
http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ
) and explain how you get the correct results from the given data. Correct or add to the sample data that I psoted, if necessary. -
Need query for below requirement
create table nsk_temp2 (num number,parent_num number,src_num number);
insert into nsk_temp2 values (1000,null,null);
insert into nsk_temp2 values (1001,1000,null);
insert into nsk_temp2 values (1002,1000,null);
insert into nsk_temp2 values (1010,null,1000);
insert into nsk_temp2 values (2001,1010,null);
insert into nsk_temp2 values (2002,1010,null);
num parent_num src_num
1000
1001 1000
1002 1000
1010 1000
2001 1010
2002 1010
Expected output
num parent_num src_num
1000
1001 1000
1002 1000
1010 1000
2001 1010 1001
2002 1010 1002
2001 -> parent is 1010 and 1010 src_num is 1000 and 1000 is parent for 1001 and 1002, so 1001 and 2001 are identical recordsHi,
This does what you requested:
WITH got_r_num AS
SELECT num, parent_num, src_num
, ROW_NUMBER () OVER ( PARTITION BY parent_num
ORDER BY num
) AS r_num
FROM nsk_temp2
SELECT d.num, d.parent_num
, NVL ( d.src_num
, s.num
) AS src_num
FROM got_r_num d
LEFT OUTER JOIN got_r_num m ON m.num = d.parent_num
LEFT OUTER JOIN got_r_num s ON s.parent_num = m.src_num
AND s.r_num = d.r_num
ORDER BY d.num
;Whether or not it gets the right results for the right reasons, I can't say, since I know so little about the reasons.
If 1001 and 2001 are identical, aren 1001 and 2002 identical, too? Can the parent_num/num hierarchy extend beyond 2 levels? What would happen if 1000 had more, or fewer, children than 2000? -
CREATE TABLE TEST_MATCH
MTCH1 NUMBER(9),
MTCH2 NUMBER(9),
UPDT_MTCH CHAR(2 BYTE),
UPDT_NBR NUMBER(10)
SET DEFINE OFF;
Insert into TEST_MATCH
(MTCH1, MTCH2, UPDT_MTCH)
Values
(2616131, 300137070, '02');
Insert into TEST_MATCH
(MTCH1, MTCH2, UPDT_MTCH)
Values
(2571056, 300129277, '02');
Insert into TEST_MATCH
(MTCH1, MTCH2)
Values
(2623529, 300175046);
COMMIT;
i need to update the column UPDT_NBR which is currently NULL
UPDATE TEST_MATCH
SET UPDT_NBR =
NVL(2616131, 300137070) FOR THESE TWO MATCHES-> (1234567),
(2571056, 300129277) FOR THESE TWO MATCHES -> (1111111),
(2623529, 300175046) FOR THESE TWO MATCHES ->(222222);
Thanks for all your help in my previous post. And thanks again for looking into my post.Hi,
If it is just three records it would be better if you fire individual update statement 3 times.
But if it is a sample data only and you have many updates to do then only way I think it is is possible is either by creating temporary table or using subfactoring(same as creating temporary table)
Regards
Anurag -
Need query for refresh test database.
Hi,
I want refresh production database to test database refresh using expdp dumpfile. Please provide steps this is the requirement
This request is to refresh the Tecnomatix test database MFEM which is
on the NATEST server wnmcdwtk.natest.gm.com. This database needs to
be refreshed using an Oracle full backup dump file from the Tecnomatix
production database MFEP which runs on the production NAENG server
wnmcdds8.naeng.gm.com. The MFEM and MFEP databases are both at Oracle
v10.2.0.4.Hi,
You have posted to the wrong section of the forum. This forum us for Berkeley DB.
Regards,
Alex Gorrod
Oracle Berkeley DB -
Need query for Item - Price Change History
I need help finding information around Price Change History by Price List.
Information of interest is Date of Update and By Whom. Also, if a Datasource is 'N-Unknown', what does this generally mean?
select
i.itemcode,
i.itemname,
iphist.price,
pl.listname,
pl.datasource as 'ChangeSource',
'' as 'PriceChangeUpdateDate',
'' as 'UpdateByUser'
from ait1 iphist, oitm i, opln pl
where 1=1
and iphist.pricelist = pl.listnum
and i.itemcode = iphist.itemcode
and iphist.itemcode in ('1234')
and pl.listnum in (6)
thanks in advance...thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today. i'll do that now though.
what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system. there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc? -
Need query for this logic..
Hi,
Need a SQL query to achieve this..
Ex:
Select object_name from user_objects where object_name in('EMP','DEPT')
You will get 2 table names.
DEPT
EMP
Now I want to count how many records are there in each table
Output should be like
DEPT 4
EMP 13
Please let me know how can we write it ?
Thanks in Advance
DevenderYou need to create a function to cout rows.
Here is an example
CREATE OR REPLACE
FUNCTION get_rows (
t_owner IN varchar2 default user,
t_name IN varchar2
RETURN integer
IS
outVal integer;
BEGIN
select null
into outVal
from dba_tables
where ( owner=t_owner )
and ( table_name=t_name );
execute immediate 'select count(*) from '||t_owner||'.'||t_name into outVal;
RETURN outVal;
EXCEPTION
WHEN no_data_found THEN
return null;
END;
/And here is the query.
Processing ...
select owner,object_name,get_rows(owner,object_name) n_rows
from dba_objects
where object_name in('EMP','DEPT')
Query finished, retrieving results...
OWNER OBJECT_NAME ROWS
SCOTT EMP 14
SCOTT DEPT 4
2 row(s) retrieved -
Need query for connecting flights
Hi all.
My requirement is as follows
suppose my itnery is AAA-BBB-CCC.And there are few flights between AAA-BBB and BBB-CCC.I need all the valid connecting flights everyday.My table data is as follows
orig dest fltno arrivaldate depdate legno itid
AAA BBB 121 23-05-2011 15:40:00(arrical ar BBB) 1 x
AAA BBB 123 23-05-2011 16:40:00(arrical ar BBB) 1 x
BBB CCC 212 24-05-2011 04:05:00(arrical ar CCC) 23-05-2011 19:50:00(depat from BBB) 2 x
BBB CCC 213 24-05-2011 13:05:00 (arrical ar CCC) 24-05-2011 04:50:00(depat from BBB) 2 x
now i need to get for legno 1 all the flights in leg 2, whose depdate is grater than arrival date in leg 1.
Thanks.Hi,
Whenever you have a problem, please post CREATE TABLE and INSERT statements for the sample data. Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using.
If I understand the problem, then you can use somehting like this:
SELECT l2.*
FROM table_x l1
JOIN table_x l2 ON l2.legeno = l1.legno + 1
AND l2.orig = l1.dest
AND l2.depdate > l1.arrivaldate
WHERE l1.legno = 1
;A self-join, like this, will work if you're looking for a specific leg. If you're interested in all legs (or all legs after a certain point), regardless of whether that's 1, 2, 3 or more, then use CONNECT BY instead of a self-join. -
Need query for..
Table A
ID Name Date Paid
1 A 5-Sep-11 10
1 A 6-Sep-11 12
1 A 7-Sep-11 15
2 B 6-Sep-11 13
2 B 7-Sep-11 16
2 B 8-Sep-11 5
3 C 8-Sep-11 12
3 C 9-Sep-11 11
Output Req
When passed ID and Name as filter conditions then output Latest Paid
e.g
for 1,A--->15
for 2,B--->5
for 3,C--->11
I blv this can be done using rank but I m looking for a way to do it without using a subquery.
Thanks in advance.Try this
"afiedt.buf" 17 lines, 699 characters
1 with t
2 as
3 (
4 select 1 id, 'A' name, to_date('05-Sep-11','dd-mon-rr') dt, 10 paid from dual union all
5 select 1, 'A', to_date('06-Sep-11','dd-mon-rr'), 12 from dual union all
6 select 1, 'A', to_date('07-Sep-11','dd-mon-rr'), 15 from dual union all
7 select 2, 'B', to_date('06-Sep-11','dd-mon-rr'), 13 from dual union all
8 select 2, 'B', to_date('07-Sep-11','dd-mon-rr'), 16 from dual union all
9 select 2, 'B', to_date('08-Sep-11','dd-mon-rr'), 05 from dual union all
10 select 3, 'C', to_date('08-Sep-11','dd-mon-rr'), 12 from dual union all
11 select 3, 'C', to_date('09-Sep-11','dd-mon-rr'), 11 from dual
12 )
13 select id, name, max(paid) keep(dense_rank last order by dt) paid
14 from t
15 group
16* by id, name
SQL> /
ID N PAID
1 A 15
2 B 5
3 C 11 -
Need query for email id replace
Hi All,
i have the input as a email like --'[email protected]'
need output only the --'arun' .
please give me the solution...try this..,
SQL> with tab as
2 (
3 select '[email protected]' email from dual)
4 select substr(email,1,instr(email,'@')-1) from tab;
SUBS
arunYou can use
update <tablename>
set email=substr(email,1,instr(email,'@')-1)
where=<condition>Twinkle
Edited by: Twinkle on Oct 21, 2009 11:03 AM -
Need query for software Last Used details
Hi All,
Is there any SCCM report which gives us details of software last used date, username, hostname etc. so that we can manage our licensing.
Regards,
PremYes: Software Metering in Configuration Manager
http://technet.microsoft.com/en-us/library/bb694169.aspx
Don
(Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)
Maybe you are looking for
-
Using Photosop Elements 11 to prepare an image to print, after I click "Print/ Page Setup/ Presets/ Show Presets", to choose a Preset, when I click either Cancel or OK to leave the page, it freezes and I have to Force Quit Photoshop to clear it. What
-
Delete Boot Camp Partition with Lion
To Delete boot camp partition with lion follow steps below : - • open finder and goto applications folder then open utilities folder ,select Boot Camp Assistance •now click on continue to go to next screen select "i have already downloaded the windo
-
PR05 - Fi DOcument Generate 2 open items (
Hi All, I am in an upgrade for version 4.6 to 6.0 In version 6.0 this is happening: I am using PR05 to generate a trip. The FI Document generates 2 open items in the vendor account instead of one open item. I supposed that this is happening because i
-
Add available taskflows without going into Edit Mode
Hi All, I am stuck with a client requirement. Let me tell you the problem. We are developing a WebCenter portal application for two types of users customer and partner. Suppose i have created 10 taskflows. Out of 10 TFs, 4 are mandatory (common) whic
-
Mapping Work Center to Internal activity
Dear All, I have ceated the work center 1000 and mapped it to the plant 0001, Cost Center and Activity type. But when I map it to the Internal activity, there is an error message "Work Center 1000 0001 not allowed (Check). I have checked the control