Query to display all records count of all tables in a schema
Hi,
I need to count all the records of all my tables in a certain schema and display the max amount of the record count. Do you have a script for this one??
SQL> create function countrec(in_tab in varchar2) return number is
2 retval number;
3 begin
4 execute immediate 'select count(*) from '||in_tab into retval;
5 return retval;
6 end;
7 /
Function created.
SQL> select table_name, countrec(table_name)
2 from tabs;
TABLE_NAME COUNTREC(TABLE_NAME)
QUERY_TOOL_DATA_COLLECTION 5
TEST01 0
T1 14
EMP 14
SALGRADE 5
FILES 0
PROVA 0
TEST 0
T_MASTER 1
T_CHILD 3
TAB_ONE 30
TAB_TWO 10
A 3
B 4
C 3
D 3
BONUS 0
DEPT 4
18 rows selected.Max
Similar Messages
-
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 -
Need a query to list all table names
I have more than 500 tables in my database.
'insert_date' & 'update_date' columns are found in more than 100 tables with data type as date.
I need a query to list all table names and 'insert_date' , 'update_date' column's content.
Please Help
Lee1212
Message was edited by:
LEE1212I have more than 500 tables in my database.
'insert_date' & update_date column is found in more
than 100 tables with data type as date.
I need a query to list all table names and
'insert_date' column's content.What do you mean by "column's content". A table can have many rows. Do you want to display all the distinct value for these columns?
Below is the query to get the tables which has columns insert_Date and update_date
select table_name
from user_tab_columns
where column_name ='INSERT_DATE'
or column_name ='UPDATE_DATE'
/You can write a PL/SQL block to retrive the distinct values of INSERT_DATE for these tables
declare
TYPE ref_cur IS REF CURSOR;
insert_date_cur ref_cur;
lv_insert_date DATE;
cursor tables_list IS
select table_name
from user_tab_columns
where column_name ='INSERT_DATE';
begin
for cur_tables in tables_list
loop
OPEN insert_date_cur for 'SELECT DISTINCT insert_date from '||cur_tables.table_name;
DBMS_OUTPUT.PUT_LINE(cur_tables.table_name);
DBMS_OUTPUT.PUT_LINE('--------------------------------');
LOOP
FETCH insert_date_cur into lv_insert_date;
EXIT WHEN insert_date_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(lv_insert_date);
END LOOP;
CLOSE insert_date_cur;
end loop;
end;I haven't tested this code. There might be some errors. Just posted something to start with for you. -
How to display all tables residing in my database
i'm using 10g express edition.
i'm developing a .net application using oracle
i want display table infomation in a datagrid
for that i need to select tables fromthe database using the interface given by them
in that i found server name field.....what it actually means?
also how to create a new database in 10g and how to display all tables residing in the database?
pls help me
thanking u
chaitanyauser11359516 wrote:
i want display table infomation in a datagrid
select owner||'.'||table_name owner_table_name
from all_tables
user11359516 wrote:in that i found server name field.....what it actually means?i'm not sute what you mean by server name field? if you refer to table column name see this code below:
select owner||'.'||table_name||'.'||column_name table_column_name,
decode(data_type,'VARCHAR',data_type||'('||to_char(data_length)||')',
'VARCHAR2',data_type||'('||to_char(data_length)||')',
'NUMBER',decode(data_scale,0,data_type||'('||to_char(data_precision)||')',
null,data_type,
data_type||'('||to_char(data_precision)||','||to_char(data_scale)||')'),
data_type) type,
nullable
from all_tab_cols
order by table_name, column_id -
Program (PL/SQL) for count the registers of all tables in a schema
Hi...
I create a little program , for count the registers of all tables in the schema...
If you need , send me your email...
Atte
HectorHi,
You can create a script by yourself by executing the script mentioned below:
Connect as sys or system....
SQL> spool test.sql
SQL> select 'select count(*) from '||owner||'.'||table_name||';' from dba_tables;
SQL> spool off;
Hope this helps.
Regards,
-Praveen.
http://myracle.wordpress.com -
Can we export DATA from all tables in a schema?
Hi,
I have a question; Can we export all the DATA from all the tables present in the schema to any source (eigther CSV, TXT, DAt, etc..)?
Or
Can I have a PL/SQL procedure to display DATA from all Tables in a schema?
With Best Regards,
- NaveedHi,
This is pretty much what you need.
DECLARE
V_COUNT NUMBER;
v_sql varchar2(1000);
IN_OWNER_NAME VARCHAR2(100) := 'AP' ; -- SCHEMA NAME
TYPE T_COL_NAME is table of varchar2(1000) index by binary_integer;
v_col_tbl t_col_name;
BEGIN
FOR i in
(SELECT object_name
FROM dba_objects
WHERE owner = IN_OWNER_NAME
AND object_type ='TABLE'
and rownum < 2)
LOOP
v_sql := 'SELECT COUNT(*) FROM ' || i.object_name ;
EXECUTE IMMEDIATE v_sql INTO V_COUNT;
if v_count > 0 then
v_sql := 'SELECT * FROM ' || i.object_name ;
select column_name
bulk collect
into v_col_tbl
from DBA_TAB_COLUMNS
WHERE TABLE_NAME = I.OBJECT_NAME
AND OWNER = IN_OWNER_NAME;
-- start selecting the column and exporting using the column names selected.
end if;
if v_col_tbl.count > 0 then
for i in v_col_tbl.first .. v_col_tbl.last
loop
DBMS_OUTPUT.PUT_lINE(v_col_tbl(i));
end loop;
end if;
DBMS_OUTPUT.PUT_lINE( i.object_name || '-' || v_count);
END LOOP;
END;
- Ronel -
How to delete all rows in all tables of a schema in Oracle?
Hi all,
I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
may you help?
Edited by: user8105261 on Nov 25, 2009 11:06 PMuser8105261 wrote:
Hi all,
I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
may you help?
Edited by: user8105261 on Nov 25, 2009 11:06 PMA typical way to reset a schema (e.g. to recreate a schema on the test database) is totally different.
1) Drop the user
2) recreate the user including table scripts from
2a) your version control system
2b) from a export dumpfile using the "nodata" option while importing -
All columns of all table in one schema
Hi
All,
Oralce 10.2.0.3
I want to count all columns in all the table in one particular schema.
How can I do that?
which view i should use to count all cloumns of all tables in particular schema?
Thanksvishal patel wrote:
we needed for our data conversion project..I don't know how you'll use the number of columns in all a schema for data conversion. Some columns are duplicated (e.g. PK/FK), should they really count for two ?
A data conversion means you should actually know what are the columns used for, not how many they are.
one more question that count include hidden columns
what is hidden column used for ? I can not see those columns in actual table.See here an example :
Re: Difference btwn user_tab_cols & user_tab_columns
Nicolas. -
Droping all tables in a schema
how to drop all tables in a schema with out logging in that schema and having logged in as sys user?
Thanks in advance
Edited by: Prasanna.N on May 17, 2010 11:48 PMPrasanna.N wrote:
Hi,
i get this error
ERROR at line 5:
ORA-06550: line 5, column 9:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe
when giving
begin
for t in (select table_name from dba_tables where owner = 'SCOTT')
loop
execute immediate 'drop table SCOTT.' || t.table_name || 'purge';
end loop;
/I just wrote for loop, of course you have to write inside begin..end block:
begin
for t in (select table_name from dba_tables where owner = 'SCOTT')
loop
execute immediate 'drop table SCOTT.' || t.table_name || ' purge';
end loop;
end;
/ -
Need to grant DML privileges to all tables in few schemas
Hi,
I need to grant DML privileges to all tables in few schemas to a role. How can I achieve that?
I thought it's below syntax but it doesn't work. Please advice.
grant ALL ON ALL TABLES IN SCHEMA <Schema_name> TO <role_name>;Thanks,
GangadharGR wrote:
Hi,
I need to grant DML privileges to all tables in few schemas to a role. How can I achieve that?
I thought it's below syntax but it doesn't work. Please advice.
grant ALL ON ALL TABLES IN SCHEMA <Schema_name> TO <role_name>;
There is no single command to grant privileges at that level. There are either ANY privileges or privileges on an object.
You can write a bit of code to generate and execute what you want, but you would have to rerun it if any new tables were created. -
Grant select on all table of a schema to role
Hi , is it possible to grant select on all table on a schema to a role?
To grant SELECT on all tables of the current schema to particular role or user:
SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
FROM (
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER = (SELECT USER FROM DUAL)
Then copy and execute the result commands, eg:
GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
GRANT SELECT ON EMP TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE; -
What privilege is needed to browse all tables in a schema
I used SQLPlus to login to DB. When I clicked "table" in the left side window, no tables is shown. What privilege is needed to browse all tables in a schema?
Thanks.SQL*Plus is a command-line interface. There is no side window to click on. Perhaps you're talking about SQL Programmer? Or are you talking about some other tool?
What user are you logging in as? What user owns the objects? Do you just want to see that the tables exist? Or do you want to be able to see the data as well?
Justin -
Query not displaying all records when execute it first tme
Hello,
i have an issue with the WEBI report.when i run the report first time it's displaying only few records, but when i run the same report second time it's displaying the more records and it's correct.
Could any one tell me why it's not displaying all records when i execute first time.
Thanks in advance for your help.
Regards,
PrathapWhich BOBJ version do you use?
Which kind of data source are you retrieving data from?
Regards,
Stratos -
How do you have more than one parameterized Query to display "All"?
hi,
I am using:
Jdeveloper 9.0.5.2
Oracle Database 9.2.0.1
Toplink
Struts
I have been able to create a parameterized query to display an html read only table.
I populated a dropdown list with values from the database
and the values I select will be the parameters to my read only table.
The drop down list is on the same page as the read only table.
I have all this working but I also need to hard code an option in the Drop down to "All"
to represent all values of this parameter.
I was able to trick the jsp page using two read only tables
and displaying the one with the parameterized query when a parameter other than "All" was chosen
and then display the other only when "All" was chosen.
This does not seem the best way to do it.
What if I had more than one parameter and I wanted to show "All"
the values of one and a certain values for another.
I would then need at least 4 read only tables.
How do I accomplish this in an easier way?
Thanks in advance.I am not exactly sure what you are asking... Are you having trouble with TopLink, or another part of your application?
Peter Krogh -
Query to display all the documents
Hi
How to display all the document numbers (quotations, orders, invoices etc), posting dates in three columns i.e. Cust Code, Doc No , Posting Date?
Since all the tables storing this information having the same column names do you think it is possbile? then how to write a query?
thanks
SV ReddySV,
what Raja said is correct. The steps are to write the query the fields you want to display in the query, so it will be as follows:
select docnum, cardcode, doctotal, objtype from ORDR
then use UNION ALL, the union all is used to join the other tables e.g. purchase, good receipt or good issue to the above sales order query but must have same fields.
It will be as this follows:
select docnum, cardcode, doctotal, objtype from ORDR
union all
select docnum, cardcode, doctotal, objtype from OPOR
union all
select docnum, cardcode, doctotal, objtype from OIGN
union all
select docnum, cardcode, doctotal, objtype from OIGE
since the result objtype here is a value, I use "case when" to display objtype in the words and user can understand the document name.
It could be mixed in all the 4th queries and will not give error result.
Rgds,
Maybe you are looking for
-
Need help with provide statement in pnp progrm
hi experts, i need to select all the records that : 1. pa00014-sunty in so_subty. base on the records that he found' i need to select from pa0001: p0014-endda = > p0001-begda and p0014-begda = < p0001-endda and p0001-persk ne so_persk. what i did: pr
-
Why does this websites not work on our Mac products?
http://www.gordonbennett2012.ch/ We are working on the above website: We cannot get it to work on the following Mac devises. Would you please advise the reason for this and how we can fix it? From: FLY GAS Subject: Fwd: Website of Gordon Bennett 2012
-
HELP!!!! Up-To-Date updated wrong photo and now i cant change it?
When i sent my request away i just notice i did upload the right photo and now when i go to do a new claim it keeps saying a claim has already been made, what do i do?
-
Network Adapter randomly disconnects
I have a Thinkpad T60p with a 3945abg network adapter. The adapter works fine when I'm connected to a non-secured router, but randomly disconnects when connected to a WPA-2 protected router. Is there an updated driver to prevent this from happening.
-
In upgrade 11.0-how to turn shuffle on/off for playback.
Just loaded the upgrade of iTunes 11.0 and learning my way around. At the top of playlists, I see a two shuffle icons, one near the name of the playlist and the other in the small box above which shows the song playing. Clicking either one seems to