Table Names & Record's Count
hi all,
i need the all the table names and their records count of a schema as output in a single SQL Query.
Is it possible ... ?
o/p should be like:
TABLE_NAME CNT
AMS_ACCOUNT 100
AMS_USER_DETAILS 200
thank's in advance.
Regards,
sri ram.
SQL> CREATE TYPE TabRowsType AS OBJECT (
table_name varchar2(100),
num_rows number
2 3 4 5
Type created.
SQL> CREATE TYPE TabRowsTab IS TABLE OF TabRowsType
2
Type created.
SQL> CREATE OR REPLACE FUNCTION CountRows
2 (p_table_name varchar2 default 'ALL',p_owner varchar2 default user)
3 RETURN TabRowsTab PIPELINED AS
4 CURSOR c1 is select owner,table_name from dba_tables where owner=p_owner and (table_name=p_table_name or p_table_name='ALL');
5 rec c1%rowtype;
6 v_cnt number:=0;
7 BEGIN
8 open c1;
9
10 loop
11 fetch c1 into rec;
12 v_cnt:=-1;
13 execute immediate 'select count(*) from '||rec.owner||'.'||rec.table_name into v_cnt;
14 exit when c1%notfound;
15 PIPE ROW(TabRowsType(rec.table_name,v_cnt));
16 END LOOP;
17
18 RETURN;
19 END;
20 /
Function created.
SQL> select * from table(CountRows);
TABLE_NAME NUM_ROWS
A 568
B 568
EMP 16
PS_FAS_PRODUCTTEMP 7407896
TEST 672173
TEST1 672173
TEST3 672173
7 rows selected.
Similar Messages
-
Get Target table name and its count
Hi Experts,
I have created a Procedure where I want to get the Target table name and its count of the previous Interface in a Package and insert these values into the Audit table.
I am able to get the number of Inserts in previous step using getPrevStepLog() API, but I also want the Target table name and its total count of the previous Interface. Is there any generic way or code to bring these Information without hardcoding the table name. Kindly help to sort this issue.Thanks!
Warm Regards,
VBVHi VBV,
Please follow the below steps to audit ur execution.
Please note i coded in such a way that u can use ur existing procedure to capture the table name no need to query ur repository as its not advisable to query the repository as Oracle may change the structure in future which i personally feel right.
I created a Audit table with the below structure.
CREATE TABLE AUDIT_TABLE
INSERT_COUNT VARCHAR2(100 BYTE),
TABLE_NAME VARCHAR2(4000 BYTE)
Step 1 :
This step needs to be added in ur existing IKM after Commit step where i am using API to capture the target table name.
Step Name: Get Table Name
Command On Source
Technology: Oracle
Schema: Any Oracle related Schema
Command:
SELECT '<%=odiRef.getTargetTable("RES_NAME")%>' AS TGT_NAME FROM DUAL
Command On Target
Technology: Jython
Command:
TargetTable='#TGT_NAME'
Step 2:
In ur existing procedure add the below or add a new procedure.
Step Name: Audit Log
Command on Source
Technology : Oracle
Schema: Whichever schema holds the audit table
Command on Target
Technology : Jython
Command:
import java.sql as sql
import java.lang as lang
myCon =odiRef.getJDBCConnection("SRC")
MyStmt=myCon.createStatement()
myRs = MyStmt.executeQuery("INSERT INTO ODITGT.AUDIT_TABLE (INSERT_COUNT,TABLE_NAME) VALUES (<%=odiRef.getPrevStepLog("INSERT_COUNT")%>,'"+TargetTable+"')")
Thats it.
OTN doesnt allow me to put + sign in front of any word ( its assume its a Italic) so please add + (plus) sign before and after TargetTable in the above script.
This way u can capture the table name, insert count in to ur audit table.
Please note u need to call this Procedure after the successful completion of the interface in a package and make sure u selected the right IKM which capture the table name as in Step 1.
I tested in my local and its working fine. Let me know if u find any difficulties in implementation.
Thanks,
Guru -
plz tell me the table names of sample count.
Hi,
Check tables;
IKPF Header: Physical Inventory Document
ISEG Physical Inventory Document Items -
Querying the schema for table name with column value!
In my schema i have 500+ tables and other objects.
i have a column with the name BO_PRODUCT_CODE.
I wants to know in what tables the value of BO_PRODUCT_CODE='FX03'.
i have query the user_tab_columns which gives me the result with 90 tables having the column BO_PRODUCT_CODE.
What is query which will give me the exact number/name of the table whose column value is FX03. ie, BO_PRODUCT_CODE='FX03'.Hi you can use this approach:
BEGIN
v_str VARCHAR2(250);
v_count NUMBER :=0;
DECLARE
FOR loop_tbl IN ( SELECT DISTINCT table_name FROM USER_TAB_COLUMNS
WHERE column_name ='BO_PRODUCT_CODE' )
LOOP
v_str := 'SELECT COUNT(*) FROM ' || loop_tbl.table_name || ' WHERE BO_PRODUCT_CODE=||'''' ||'FX03' || '''' '
EXECUTE IMMEDIATE v_str INTO v_count ;
IF v_count > 0 THEN
DBMS_OUTPUT.PUT_LINE ('Table Name :'|| loop_tbl.table_name || ' Count :'||v_count);
END IF;
v_count :=0;
END LOOP;
EXCEPTION
WHEN others THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
Please remove if any syntax error.
Regards -
Unknown table name:PERSON
Hi,
I created a table in dbmcli :
C:\>dbmcli.exe -d MAXDB2 -u DBADMIN,pwd -c sql_execute CREATE TABLE person (pno FIXED(6), name CHAR(20), city
CHAR(20))
OK
C:\>dbmcli.exe -d MAXDB2 -u DBADMIN,pwd -c sql_execute select count(*) from person
OK
END
0
But when query in SQL STUDIO, I receive :
--- Error -
Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
Base table not found;-4004 POS(23) Unknown table name:PERSON
select count( *) from person
What is wrong ?
Thank you.Hi BIG136,
if you run a command like
dbmcli -u dbadmin,<pw> -d <db name> -c sql_execute <any command>
the command is executed as user dbm. This is the reason why you do not see the table in SQL Studio as dbadmin. Run instead
dbmcli -u dbadmin,<pw> -d <db name> -uSQL dbadmin,<pw> -c sql_execute <any command>
and the table will be also found in SQL Studio as user dbadmin. To execute an SQL command with dbmcli you normally first open a session, execute the command and then release the session. Because this is hardly possible with a single command line you should use -uSQL option which does all this for you at once.
Regards,
Steffen -
How to display table name in the Record history
Hi,
I have developed a new custom form. When I click on the record history, it displays details like updated_by , update_Date.
But it doesnt show the table name ( of the data block ). Is there any coding to be done to display the table name ?
Regards,
SureshSounds like some custom form for the eBusines-suite. Maybe you get an answer in an eBusiness-suite related forum, maybe here OA Framework
-
Table name for asset deletion record
Hi,
Please tell me the table name for asset deletion record.
Thanks...Hi,
Find Asset deletion tables below.
CDHDR Table for find the list of Retired / deleted assets (use SE16 for the same and put T. Code ABAVN / AS06)
CDPOS
Regards,
JA
Edited by: javeed ahmed on Jan 14, 2010 12:10 PM -
Table Name for Condtion Record
Hi,
What is the table name for condition records which are maintained through VK11.
regards
RajeshHi Rajesh,
The condition records are stored in different tables based on the condition tables given for an access sequence. First find out the access sequence and then the condition tables used for a particular condition type.
Lets says for PR00 the access sequence is PR02 and the condition tables are 651, 652 & 653. Now the records would be stored tables A651, A652 & A653.
Regards
Nadarajah Pratheb -
Table Name for Rebates Condition Records in Rebate Agreements
Hello All,
I want to know the table name which stores the condition records for Rebate Condition Types?
fast responses are appreciated.
Regards,
Rags.Hi,
Try KONA table.
KONM KONW
Regards,
Chandra -
Hello every body,
I am trying to create a procedure in pl/sql which can takes in input a record and its output is the table name of the record....i don't know how to do this in pl/sql...can u help me?
Thanks.Can you be more specific as to what you need? From what I understood is, you are bulding a procedure that takes input and when it matches record in any table, you want to display that table name. Am I right?
-
Last 10 records of a table with out using count
How can i get last 10 records of a table with out using count() method? if there is some page size(eg 10) , and if we want last page. is it posible without ount()? if posible how?
Message was edited by:
user480375"is there any other way without nesting?"
Not correctly, no. What is your problem with nesting? Nested queries are not inherently slower than unnested queries. In some cases, such as this, they are the only correct way to do the query. Even an analytic version of the Top N needs to be nested because:
SQL> SELECT object_name
2 FROM t
3 WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
4 /
WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
ERROR at line 3:
ORA-30483: window functions are not allowed hereTTFN
John -
Restrictions in Oracle Server (table size, record count ...)
Hello,
can somebody tell me if there are any restrictions of table size, record count, file size (apart from operation system restrictions) in Oracle 8.1.7 and 7.3.4?
Or where can i find information? I couldn4t find anything in the generic documentation.
Thank you in advance,
Hubert Gilch
SEP Logistik AG
Ziegelstra_e 2, D-83629 Weyarn
Tel. +49 8020 905-214, Fax +49 8020 905-100
EMail: [email protected]Hello,
if you are executing a DBMS_AQ.DEQUEUE and then perform a rollback in your code the counter RETRY_COUNT will not go up by 1.
You are only reversing your own AQ action. This counter will be used only internally to log unsuccessful dequeue actions.
Kind regards,
WoG -
Sql Except query to Display mismatched records along with Table names
Hi
I am using below query to display mismatch records between two tables
SELECT * FROM table1
EXCEPT
SELECT * FROM table2
UNION
SELECT * FROM table2
EXCEPT
SELECT * FROM table1
This displays mismatched records like below
Sunil 1000 india
Sunil 1500 india
I would like to display even the table names in the result For ex;
Sunil 1000 india Table1
Sunil 1500 india Table2
Can you please help us in this regard.cnk_gr's query should work for you.
One change that I would make is to use UNION ALL, not UNION. UNION eliminates duplicate rows, which means SQL has to do additional work (sort the result and then check for duplicates).
So if you can have duplicates and don't want them in your result, then you would use UNION. And if you can have duplicates and you want the duplicates in the result, you would use UNION ALL. But in cases like this, where you know you cannot have
duplicates (because column 1 contains 'TABLE1' for every row in the first half and column 1 contains 'TABLE2' for every row returned from the second half of the query), you should always use UNION ALL. It will be more efficient.
Tom -
The table name or tcode to count the number of Dimensions and Key Figures
Hi all,
Do you have an idea about the table name or tcode to count the number of Dimensions and Key Figures of an Infocube WITHOUT installing the cube from Business Content?
Thanks in adv.
AjayHi,
You can't do that because there's no active table in the system for the Business Content since it hasn't been installed yet...
One thing you could do is go to the Business Content Tab, select "Infoproviders by InfoArea" on the left side, look for the Cube or DSO you want to check, right click on it and select "Display Description".
On the window that opens you'll have a list of all InfoObjects and Key Figures. You also have the option to Display it as Start Schema, where you can see the Dimensions, etc.
Hope this helps.
Luis -
SQL/PLSQL Help - Table Name and Count on same line
Hello,
I need the following information returned:
Table_Name, Current Table Count, Num_Rows.
The table_name and num_rows are pulled from dba_tables where owner = 'XXXX'
I can't figure out how to return this info.
Sample of desired output and format
Table_name Num_Rows Current Count
AAAA 15 400
ABBB 8000 8120
Any help would be appreciated.
Thanks - ChrisMay be this one helps you:
declare
cursor cur_cnt is
select 'select ''' || table_name || ''', (select count(*) from ' || table_name || ') from dual' l_sql from user_tables;
l_table_name varchar2(30);
l_cnt number;
begin
dbms_output.put_line(rpad('Table Name',40)||rpad('RowCount',40));
dbms_output.put_line('------------------------------------------------');
for l_cur_cnt in cur_cnt
loop
execute immediate l_cur_cnt.l_sql into l_table_name, l_cnt;
dbms_output.put_line(rpad(l_table_name,40)
||rpad(l_cnt,40));
end loop;
end;
-Hari
Hello,
I need the following information returned:
Table_Name, Current Table Count, Num_Rows.
The table_name and num_rows are pulled from dba_tables where owner = 'XXXX'
I can't figure out how to return this info.
Sample of desired output and format
Table_name Num_Rows Current Count
AAAA 15 400
ABBB 8000 8120
Any help would be appreciated.
Thanks - Chris
Maybe you are looking for
-
Where are the latest files that be downloaded in the computer?
a problem confused me recently.i cannot find the files which be downloaded by adobe application manager. so, who can help me? thanks.
-
Can a variable be used like this? If not does anyone have any idea how I might be able to control a movie clip which comes from a variable? var itsMe = "movie1_mc"; itsMe.gotoAndStop(horVal);
-
"Add to bookmarks - button" for application with application alias
How to make "add to bookmarks - button" to login page of the application with the application alias? The idea is to ensure that end-users are storing the application alias to bookmarks rather than the direct link to application id which might change.
-
Hi all, I am trying to generate line chart dynamically. I just want to know that is it possible? If yes then how to create chart and passing the chart series dynamically. Regards, Vinaya.
-
Hi I'm developing an j2me application which should interact with our application server. The application server checks for version when mobile devices connect to retrieve data. If the application version running on the mobile device is not compatible