COunt no of rows of all the tables
hai
Pls tell me COunt no of rows of all the tables in the user SOP
Output like this
Tablename rows
sen 31
van 45
etc
pls help
S
set serveroutput on size 100000 feedback off
declare
rs integer;
cur integer;
rp integer;
trs integer;
n integer;
un varchar2(30);
begin
dbms_output.put_line(rpad('Table Name',40)||' Number of Rows Created Date');
dbms_output.put_line(rpad('-',73,'-'));
cur:= dbms_sql.open_cursor;
for t in (select object_name, created from dba_objects where object_type='TABLE' and OWNER='SOP') loop
dbms_sql.parse(cur,'select count(*) from SOP.' || t.object_name, dbms_sql.v7);
dbms_sql.define_column(cur, 1, rs);
rp:= dbms_sql.execute(cur);
n:=dbms_sql.fetch_rows(cur);
dbms_sql.column_value(cur, 1, rs);
dbms_output.put_line(rpad(t.object_name,48,'.')||rpad(rs,15,'.')||t.created);
end loop;
dbms_sql.close_cursor(cur);
dbms_output.put_line(rpad('-',73,'-'));
end;
set serveroutput off feedback on feedback 6
Anyway or...
set serveroutput on size 100000 feedback off
declare
rs integer;
cur integer;
rp integer;
trs integer;
n integer;
un varchar2(30);
v_user varchar2(20);
begin
v_user := '&user';
dbms_output.put_line(rpad('Table Name',40)||' Number of Rows Created Date');
dbms_output.put_line(rpad('-',73,'-'));
cur:= dbms_sql.open_cursor;
for t in (select object_name, created from dba_objects where object_type='TABLE' and OWNER=v_user) loop
dbms_sql.parse(cur,'select count(*) from '|| v_user ||'.' || t.object_name, dbms_sql.v7);
dbms_sql.define_column(cur, 1, rs);
rp:= dbms_sql.execute(cur);
n:=dbms_sql.fetch_rows(cur);
dbms_sql.column_value(cur, 1, rs);
dbms_output.put_line(rpad(t.object_name,48,'.')||rpad(rs,15,'.')||t.created);
end loop;
dbms_sql.close_cursor(cur);
dbms_output.put_line(rpad('-',73,'-'));
end;
Enter value for user: TEST
old 11: v_user := '&user';
new 11: v_user := 'TEST';
Table Name Number of Rows Created Date
TEST_UPDATE2....................................1..............21-JAN-09
TEST_UPDATE.....................................1..............20-JAN-09
Similar Messages
-
How to find accurate number of Rows, and size of all the tables of a Schema
HI,
How to find the accurate number of Rows, and size of all the tables of a Schema ????
Thanks.SELECT t.table_name AS "Table Name",
t.num_rows AS "Rows",
t.avg_row_len AS "Avg Row Len",
Trunc((t.blocks * p.value)/1024) AS "Size KB",
t.last_analyzed AS "Last Analyzed"
FROM dba_tables t,
v$parameter p
WHERE t.owner = Decode(Upper('&1'), 'ALL', t.owner, Upper('&1'))
AND p.name = 'db_block_size'
ORDER by 4 desc nulls last;
## Gather schema stats
begin
dbms_stats.gather_schema_stats(ownname=>'SYSLOG');
end;
## Gather a particular table stats of a schema
begin
DBMS_STATS.gather_table_stats(ownname=>'syslog',tabname=>'logs');
end;
http://www.oradev.com/create_statistics.jsp
Hope this will work.
Regards
Asif Kabir
-- Mark the answer as correct/helpful -
Recordcount for all the tables in my user
How I will get recordcount for all the tables in my user
with a single query??
Plz help.
Thanx in advance.Not possible. As there can be any number of tables with any names, this requires dynamic SQL.
SQL given to the Oracle SQL Engine cannot be dynamic ito scope and references - it must be static. For example, one cannot do this:
SELECT count(*) FROM :table
For the SQL Engine to parse the SQL, determine if it is valid, determine the scope and security, determine an execution plan, it needs to know the actual object names. Objects like tables and columns and functions cannot be variable.
You will therefore need to write a user function (in PL/SQL) that dynamically creates a [SELECT COUNT] SQL for a table, execute that SQL and return the row count - and then use SQL to iterate through USER_TABLES for example and sum the results of this function.
Note that object tables are not listed in USER_TABLES - thus a more comprehensive list of all table objects in your schema can be found in USER_OBJECTS. -
How can I make all the Tables in my spreadsheet to work as one?
I made a spreadsheet for work in Numbers '09 but do to the computers that we have at work, I have to have it exported to Windows Excel, but when I try to export the spreadsheet since I used more than 1 table to create this spreadsheet, each table is converted to an Excel worksheet, and all other objects are placed on separate worksheets since there's more than one table. and I want to know is there anything I can do, to export everything in one spreadsheet, for all the tables to work as one spreadsheet. PLEASE HELP!!
You may be able to easily consolidate all your tables into one big table to make it equivalent to an Excel worksheet. You can copy/paste from one table to another and you can drag columns or rows from one table and insert them into another. Note that formulas that use column letters or row numbers instead of specific ranges (i.e., B instead of B2:B10) will now refer to the entire column/row in the destination table.
Without doing this, all the tables, when exported to Excel into separate worksheets, should still work together just like they did in Numbers. Are you saying that they do not?
Not much you can do about objects. -
The row structure of the table BANFTAB is incorrect
Dear Experts,
I get right here the error message
The row structure of the table BANFTAB is incorrect
ZBANFN is a table type and has the line tab BANFN.
Can you pls tell me what is wrong here ?
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data lt_eban type table of eban.
data ls_eban type eban.
SELECT * FROM eban into table lt_eban where BANFN IN BANFTAB AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.Hello,
You have to use a ranges table in this case.
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data:lt_eban type table of eban.
data:ls_eban type eban.
data:
l_r_banfn type range of banfn,
l_wa_banfn like line of l_r_banfn,
l_wa_banftab like likne of BANFTAB.
loop at banftab into l_wa_banftab.
l_wa_banfn-sign = 'I'.
l_wa_banfn-option = 'EQ'.
l_wa_banfn-low = l_wa_banftab-banfn.
append l_wa_banfn into l_r_banfn.
clear l_wa_banfn.
endloop.
SELECT * FROM eban into table lt_eban
where
BANFN IN L_R_BANFN "BANFN IN BANFTAB
AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.
or you can use FOR ALL ENTRIES :
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data lt_eban type table of eban.
data ls_eban type eban.
SELECT * FROM eban into table lt_eban
FOR ALL ENTRIES IN BANFTAB "--> Add this
where BANFN = BANFTAB-BANFN
AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.
Try this & let me know in case of any issues.
BR,
Suhas
Edited by: Suhas Saha on Feb 10, 2009 5:43 PM -
How to generate test data for all the tables in oracle
I am planning to use plsql to generate the test data in all the tables in schema, schema name is given as input parameters, min records in master table, min records in child table. data should be consistent in the columns which are used for constraints i.e. using same column value..
planning to implement something like
execute sp_schema_data_gen (schemaname, minrecinmstrtbl, minrecsforchildtable);
schemaname = owner,
minrecinmstrtbl= minimum records to insert into each parent table,
minrecsforchildtable = minimum records to enter into each child table of a each master table;
all_tables where owner= schemaname;
all_tab_columns and all_constrains - where owner =schemaname;
using dbms_random pkg.
is anyone have better idea to do this.. is this functionality already there in oracle db?Ah, damorgan, data, test data, metadata and table-driven processes. Love the stuff!
There are two approaches you can take with this. I'll mention both and then ask which
one you think you would find most useful for your requirements.
One approach I would call the generic bottom-up approach which is the one I think you
are referring to.
This system is a generic test data generator. It isn't designed to generate data for any
particular existing table or application but is the general case solution.
Building on damorgan's advice define the basic hierarchy: table collection, tables, data; so start at the data level.
1. Identify/document the data types that you need to support. Start small (NUMBER, VARCHAR2, DATE) and add as you go along
2. For each data type identify the functionality and attributes that you need. For instance for VARCHAR2
a. min length - the minimum length to generate
b. max length - the maximum length
c. prefix - a prefix for the generated data; e.g. for an address field you might want a 'add1' prefix
d. suffix - a suffix for the generated data; see prefix
e. whether to generate NULLs
3. For NUMBER you will probably want at least precision and scale but might want minimum and maximum values or even min/max precision,
min/max scale.
4. store the attribute combinations in Oracle tables
5. build functionality for each data type that can create the range and type of data that you need. These functions should take parameters that can be used to control the attributes and the amount of data generated.
6. At the table level you will need business rules that control how the different columns of the table relate to each other. For example, for ADDRESS information your business rule might be that ADDRESS1, CITY, STATE, ZIP are required and ADDRESS2 is optional.
7. Add table-level processes, driven by the saved metadata, that can generate data at the record level by leveraging the data type functionality you have built previously.
8. Then add the metadata, business rules and functionality to control the TABLE-TO-TABLE relationships; that is, the data model. You need the same DETPNO values in the SCOTT.EMP table that exist in the SCOTT.DEPT table.
The second approach I have used more often. I would it call the top-down approach and I use
it when test data is needed for an existing system. The main use case here is to avoid
having to copy production data to QA, TEST or DEV environments.
QA people want to test with data that they are familiar with: names, companies, code values.
I've found they aren't often fond of random character strings for names of things.
The second approach I use for mature systems where there is already plenty of data to choose from.
It involves selecting subsets of data from each of the existing tables and saving that data in a
set of test tables. This data can then be used for regression testing and for automated unit testing of
existing functionality and functionality that is being developed.
QA can use data they are already familiar with and can test the application (GUI?) interface on that
data to see if they get the expected changes.
For each table to be tested (e.g. DEPT) I create two test system tables. A BEFORE table and an EXPECTED table.
1. DEPT_TEST_BEFORE
This table has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look BEFORE the
test for that test case is performed.
CREATE TABLE DEPT_TEST_BEFORE
TESTCASE NUMBER,
DEPTNO NUMBER(2),
DNAME VARCHAR2(14 BYTE),
LOC VARCHAR2(13 BYTE)
2. DEPT_TEST_EXPECTED
This table also has all EMP table columns and a TEST_CASE column.
It holds EMP-image rows for each test case that show the row as it should look AFTER the
test for that test case is performed.
Each of these tables are a mirror image of the actual application table with one new column
added that contains a value representing the TESTCASE_NUMBER.
To create test case #3 identify or create the DEPT records you want to use for test case #3.
Insert these records into DEPT_TEST_BEFORE:
INSERT INTO DEPT_TEST_BEFORE
SELECT 3, D.* FROM DEPT D where DEPNO = 20
Insert records for test case #3 into DEPT_TEST_EXPECTED that show the rows as they should
look after test #3 is run. For example, if test #3 creates one new record add all the
records fro the BEFORE data set and add a new one for the new record.
When you want to run TESTCASE_ONE the process is basically (ignore for this illustration that
there is a foreign key betwee DEPT and EMP):
1. delete the records from SCOTT.DEPT that correspond to test case #3 DEPT records.
DELETE FROM DEPT
WHERE DEPTNO IN (SELECT DEPTNO FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3);
2. insert the test data set records for SCOTT.DEPT for test case #3.
INSERT INTO DEPT
SELECT DEPTNO, DNAME, LOC FROM DEPT_TEST_BEFORE WHERE TESTCASE = 3;
3 perform the test.
4. compare the actual results with the expected results.
This is done by a function that compares the records in DEPT with the records
in DEPT_TEST_EXPECTED for test #3.
I usually store these results in yet another table or just report them out.
5. Report out the differences.
This second approach uses data the users (QA) are already familiar with, is scaleable and
is easy to add new data that meets business requirements.
It is also easy to automatically generate the necessary tables and test setup/breakdown
using a table-driven metadata approach. Adding a new test table is as easy as calling
a stored procedure; the procedure can generate the DDL or create the actual tables needed
for the BEFORE and AFTER snapshots.
The main disadvantage is that existing data will almost never cover the corner cases.
But you can add data for these. By corner cases I mean data that defines the limits
for a data type: a VARCHAR2(30) name field should have at least one test record that
has a name that is 30 characters long.
Which of these approaches makes the most sense for you? -
Cannot display all the tables of the schema!!!
Hi:
I use the oracle sql developer on the windows xp, I found that the tables tab cannot display all the tables of the schema owner, I use the sql "select count(*) from user_tables" I found the result is more than the tab can be display, and I also press the "show more" already.... does anyone can help me ???Similarly, I have 852 tables owned by the connected user (selected count from user_tables and checked the user tables report which has this many records returned), but when I double-click on the "Show More" and select Show All, I only get approximately 375 tables listed.
It doesn't help that the sorting is different - ie ASF_ comes before ASFB in the connection pane but the other way around in the report.
However, it looks as though the problem is that tables that are not analysed (based on the report data in DATE_LAST_ANALYZED) are not being displayed under the Table node. -
Hi All
I have nearly 70 procedures in my database.
I want to get all the distinct table names used in the 70 procedures.
Is it possible?
Note:
All the table names are prefixed by schema name like DEVSRC.table_name.
Please advice
Thanks
JoJohney wrote:
Hi VT
One doubt.
This query will give the table names of only select stmt used in the procedure
or
List of table names that are with in any DML operations inside the procedure?
Thanks
JoIt will give all the table either used in select or in any DML..
You can also check by creating a temp proc
SQL> drop procedure proc_test;
Procedure dropped.
SQL> select name, referenced_name, dependency_type from user_dependencies
2 where type = 'PROCEDURE' and referenced_type = 'TABLE' and name='PROC_TEST';
no rows selected
SQL> create or replace
2 PROCEDURE proc_test
3 IS
4 v_ID number;
5 v_PRID number;
6 v_PRLID number;
7 v_DATERECEIVED date;
8 Cursor C1 is
9 select * from table_c;
10 BEGIN
11 open c1;
12 LOOP
13 FETCH c1 INTO v_ID,v_PRID,v_PRLID,v_DATERECEIVED;
14 EXIT WHEN c1%NOTFOUND;
15 insert into table_b values(v_ID,v_PRID,v_PRLID,v_DATERECEIVED);
16 Commit;
17 END LOOP;
18 CLOSE C1;
19 END;
20 /
Procedure created.
SQL> select name, referenced_name, dependency_type from user_dependencies
2 where type = 'PROCEDURE' and referenced_type = 'TABLE' and name='PROC_TEST';
NAME
REFERENCED_NAME DEPE
PROC_TEST
TABLE_B HARD
PROC_TEST
TABLE_C HARD
SQL> Regards
Umesh -
How to delete/drop all the tables from SQL Server Database without using Enterprise Manager?
I tried using DROP Tables, Truncate Database, Delete and many more but it is not working. I want to delete all tables using Query Analyzer, i.e. through SQL Query.
Please help me out in this concern.
Nishith ShahInformative thread indeed. Wish I saw it early enough. Managed to come up with the code below before I saw this thread.
declare @TTName Table
(TableSchemaTableName
varchar
(500),
[status] int
default 0);
with AvailableTables
(TableSchemaTableName)
as
(select
QUOTENAME(TABLE_SCHEMA)
+
+
QUOTENAME(TABLE_NAME)
from
INFORMATION_SCHEMA.TABLES)
insert into @TTName
(TableSchemaTableName)
select *
from AvailableTables
declare @TableSchemaTableName varchar
(500)
declare @sqlstatement nvarchar
(1000)
while 1=1
begin
set @sqlstatement
=
'DROP TABLE '
+ @TableSchemaTableName
exec
sp_executeSQL
@sqlstatement
print
'Dropped Table : '
+ @TableSchemaTableName
update @TTName
set [status]
= 1
where TableSchemaTableName
= @TableSchemaTableName
if
(select
count([Status])
from @TTName
where [Status]
= 0)
= 0
break
end -
What are all the tables used for this report:
hi
what are all the tables used for this report:
report:
<b>Stock Report, which will give opening balance, receipt, issue, and closing balance for any given Duration for any material.</b>
thanks in advanceTables: MSEG, MKPF, MARD.
FOR REFERENCE SEE TRANSACTION : MB5B.
Message was edited by: Sharath kumar R -
How to increase the row height of the table in the smartform
Hi,
Can any one say,
How to increase the row height of the table in the smartform.
It is presently show the row width very small, i want to increase the row with of the table in the smartform.
Plase say how can we increase the row height in the smartform.Hi Ravi,
In Smartforms , Select the Table and you can adjust the cell hieghts in OUTPUT OPTIONs TAB.
Reward points if that Helps.
Manish -
Is there a way to view all the table names in a certain schema?
Is there a way to view all the table names in a certain schema?
SELECT table_name FROM user_tablesThat won't do much good given this piece of information:
i am trying to finish a lab for school but i don't know what tables are in my
professor's schema. The appropriate solution is
SELECT table_name
FROM all_tables
WHERE owner = 'PROFESSOR_YAFFLE'
/This will show the names of the tables which Prof. Yaffle has granted to us.
Cheers, APC -
How to find all the tables associated for a particular transaction
Hi-
May I know how to find all the tables, related(foreign key) tables for a transaction within SAP GUI?
Up to my technical knowledge, this can be achieved by looking database diagrams from DB level. But that would be for entire database as a whole. What I'm expecting is to see transaction level relative tables that too from SAP GUI. Please share the possibilities if any.
Regards
SekharDear Micky Oestreich
May be we possess expertise or high level experience, it should not show up in our way of communication. Every professional starts with the basic stuff to learn. When the question is raised in such minimum polite way, the same level of courtesy is expected in return. If you felt my question was basic, you might have refused it gently. If you are in good mood or bad mood it doesn't matters.
Hi Vengal Rao
Thanks for your response. It helped me.
Regards
Sekhar -
How to find all the table used in a report
Hi Expert ,
Is there is any program to find out all the tables which are used in a perticular report .
Thanks in advance
TarakWell, so far Viquar Iqbal has given the only really correct answer - use SQL trace. The reason the others are incomplete, is because they don't consider that a report might call a function module or a class method that accesses a table. In fact, for many applications this is exactly what happens - db accesses are abstracted away from the main program.
The other alternative to SQL trace is to use Run Time Analysis. The advantage of SQL trace is that it shows the tables hit in order.
matt -
How will get the source code of all the tables in a given schema using SQL?
Hi All,
How can we get the source code of all the tables in a given schema using SQL?
Thanks in Adv.
JunuTry something like...
set heading off
set pagesize 0
col meta_data for a96 word_wrapped
set long 100000
SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner) ||';' AS meta_data
FROM dba_objects
WHERE owner = '<SCHEMA NAME>'
AND object_type not in (<list of stuff you do not want>);
Maybe you are looking for
-
Table.rows.find() returns null in a table where the row exists.
Hi... I am working in a Project in Visual Studio 2013 where I have to read an Excel report related with a list of business opportunities. Some of the Fields that are involved in it are: Opportunity ID, BU, Account, close date, Account Manager, Total
-
Why does the cursor jump from the Name box to the password box when logging in to Gmail?
When logging in to Gmail, I often (8/10) times find that while I am still typing the username, the cursor has jumped to the password box. The result is that part of the username is typed into the password box. I then have to click back onto the usern
-
Does Map Builder require a local install of the Oracle database? Ever since I uninstalled the Oracle database from my machine, Map Builder has been unable to load connections (connections that work on my colleague's machines) My machine has Oracle Cl
-
ASM Software pack on oracle 10.2
Hi all, an oracle consultant from germany trying to push us to install an ASM 11.1 ( Oracle Home ) Software for using an Oracle 10.2g database. Does anyone can confirm that is a good way ? Are any issues known with this configuration ? $ORACLE_BASE/p
-
My Ipod 4th generation is almost unresponsive to my touch, and will not allow lockscreen access, and also is stuck on the "Not enough Storage" button. When I try to get rid of it, it does nothing. My ipod's power button, volume buttons, and home scre