Query to find tables whcih are renamed
Hi,
Can anyone help me with a query to list the tables which are renamed or a ttribute of a specific table which will give the result.
Example: If database is renamed then create_date from sys.databases gives the database renamed.
Similar I want for tables
Thanks
Hi cnk_gr,
Actually I dont want to rename tables want to list the tables whicha re renamed comaring the time.
Can you suggest how could this be achievedusing sp_rename?
Thanks.
Hi Priyanka,
As for as i know, there is no way to track the changes done by sp_rename, unless if you already plan this case as
cnk_gr mentioned with adding extendedproperty, or you can write your version of SP_rename like SP_rename1 which internally calling SP_rename and track the changes on a table
below is the code the changes the object name, i dont know what %% the statement is doing, but i think it may be updating the objectname in physical location where the objectname is saved(just the reference is changed from old name to new name)
-- update the object name
EXEC %%Object(ID = @objid).SetName(Name = @newname)
May be you can compare the schema between similar other server like reporting server or restore a backup, which doesn't have the rename applyed and find out the differnence.
Note: when you rename a table in SSMS, it internally calling sp_rename to change the table name
Thanks
Saravana Kumar C
Similar Messages
-
Need a query to find Table Dependancy
Hi Experts,
I am in a need to find out which are all tables refer to particular table 'ABC' and / or it's column 'column_1', since I am new to environment and have about 500 + tables.
Please tell me what are the various ways, I can achieve above requirement?
Regards,
MSuser_cons_columns
Information about accessible columns in constraint definitions
OWNER
Owner of the constraint definition
CONSTRAINT_NAME
Name associated with the constraint definition
TABLE_NAME
Name associated with table with constraint definition
COLUMN_NAME
Name associated with column or attribute of object column specified in the constraint definition
POSITION
Original position of column or attribute in definition
Also try this, DBMS_METADATA
set long 9999
select dbms_metadata.get_ddl('TABLE','ABC') FROM DUAL;
Edited by: rajeysh on Jun 21, 2011 2:44 AM
Edited by: rajeysh on Jun 21, 2011 2:44 AM -
Query to Find Table and Column Name by using a value
Dear Legends,
I hope and surfed in our forums and google to find the Table Name and Column Name by having a value(Number/String). And my where clauses are
where owner NOT IN ('SYS','SYSTEM') and
data_type IN ('CHAR','VARCHAR2','NUMBER')
May I have your help for building the query. and my query as follows
select a.owner, c.column_name, c.data_type, c.owner, c.table_name
from dba_objects a, all_tab_cols c
where a.owner NOT IN ('SYS','SYSTEM') and
where c.owner NOT IN ('SYS','SYSTEM') and
where c.data_type IN ('CHAR','VARCHAR2')
order by a.owner
Thanks,
KarthikYou can use
select * from user_tab_columns a, user_tables b
where a.table_name = b.table_name
and a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR');
Or if you want to user DBA_* tables, you can use.
select * from dba_tab_columns a, dba_tables b
where a.table_name = b.table_name
and a.owner = b.owner
and a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR')
and b.owner not in ('SYS', 'SYSTEM');
And now when I look a bit more closely, you don't need DBA_TABLES there. dba_tab_columns alone is sufficient. And requirement is still not clear yet. Why you need a group by there? If I get it right, you can use this.
select * from dba_tab_columns a
where a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR')
and a.owner not in ('SYS', 'SYSTEM');
Whether you use group by or not, the query will give you the same output.
Ishan -
Query to find tables with excessive initial extent settings
After loading a database dump we found many tables occupying large space due to large initial extents storage parameter but with very few rows and am trying to determine if it would be worth the effort to reorganize the entire schema. In other words, we are looking for a query to compare the estimated actual space that would be occupied by the table rows vs. the current size to see the space savings if we were to reorganize.
I hacked out a script to calculate the estimated size using the table stats (or 64K if estimate is lower) and compared that vs. the extents allocated to each table but this seems a rather inexact way of doing it. Is there a more accurate approach?
Doing this on Oracle database 10.2.0.4 on Windows Server 2003 SE
SELECT a.table_name,
b.table_size_MB,
ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2) calc_size_MB,
b.table_size_MB - GREATEST(ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2), 0.0625) savings_MB
FROM dba_tables a,
(SELECT segment_name, sum(bytes)/(1024*1024) table_size_MB
FROM dba_extents
WHERE tablespace_name like 'PMDX' and segment_type = 'TABLE'
GROUP BY segment_name) b
WHERE a.owner = 'CAS' and a.table_name = b.segment_name
ORDER BY b.table_size_MB desc
TABLE_NAME TABLE_SIZE_MB CALC_SIZE_MB SAVINGS_MB
TPM06_POL_DATA_WRK_PREV 640 493.46 146.54
TPM06_POL_DATA_WRK_CURR 640 496.57 143.43
TPM06_POL_DATA_201006 640 496.8 143.2
TPM06_POL_DATA_201005 640 494.87 145.13
TPM06_POL_DATA_201004 640 490.45 149.55
TPM07_MOV_DTLS_WRK 256 198.66 57.34
...Hi,
Didn't you check the dba_extents view with respect to the tables which you estimated.
After loading a database dump we found many tables occupying large space due to large initial extents storage parameterYou might have modified the initial extent size before to your load by pre-created tables ,which might helped out with current situation prior to this as you might be well known with your current database. Does the segement using Autoallocate or Uniform. What is the block size of DB.
- Pavan Kumar N -
Query to find tables in database having maximum records or data
hello
how can i find 10 high volume tables in my database
RegardsHi user;
Please try below query:
How many schema we have and their size
set pages 999
col "size MB" format 999,999,999
col "Objects" format 999,999,999
select obj.owner "Owner" ,
obj_cnt "Objects" , decode(seg_size, NULL, 0, seg_size) "size MB" from
(select owner, count(*) obj_cnt from dba_objects group by owner) obj ,
(select owner, ceil(sum(bytes)/1024/1024) seg_size from dba_segments group by owner) seg where obj.owner = seg.owner(+) order by 3 desc ,2 desc, 1
To find Ten bigest object on our db
col owner format a15
col segment_name format a30
col segment_type format a15
col mb format 999,999,999
select owner , segment_name , segment_type , mb from (
select owner , segment_name , segment_type , bytes / 1024 / 1024 "MB" from dba_segments
order by bytes desc ) where rownum < 11
Regard
Helios -
Query to find employees who are managers for 3 or more employees
Hi,
I am using emp table in scott schema for this query.
select * from emp
where empno in
(select e.mgr
from emp e, emp m
where e.mgr = m.empno
group by e.mgr
having count(*) >= 3);
It gives all employee details where he is manager for more than or equal 3 employees. Please suggest all possible queries which gives same output.
Thanks
Raghuselect * from emp
select a.empno, a.ename , a.mgr, b.ename reported_to
from emp a, emp b
where a.mgr = b.empno
--start with keyword
SELECT empno, ename, mgr, LEVEL
FROM emp
START WITH empno = 7788
CONNECT BY PRIOR empno = mgr
ORDER siblings BY ename;
-- employee reported to
SELECT ename || ' reports to ' ||
PRIOR ename "Walk Top Down"
FROM emp
START WITH ename = 'KING'
CONNECT BY PRIOR empno = mgr
-- use of PRIOR in different places
SELECT ename || ' reports to ' ||
PRIOR ename "Walk Top Down"
FROM emp
START WITH ename = 'KING' --'SCOTT'
CONNECT BY PRIOR empno = mgr
-- using prior type 2
SELECT ename || ' reports to ' ||
PRIOR ename "Walk Top Down"
FROM emp
START WITH ename = 'CLARK' --'SCOTT'
CONNECT BY empno = PRIOR mgr
-- top down
SELECT empno, ename, job, mgr
FROM emp
START WITH ename = 'SMITH'
CONNECT BY PRIOR mgr = empno ;
-- bottom up
SELECT empno, ename, job, mgr
FROM emp
START WITH ename = 'SMITH'
CONNECT BY PRIOR empno = mgr ;
--level chart
SELECT LPAD(ename, LENGTH(ename) + (LEVEL * 2 ) - 1, '_ '), level
AS org_chart
FROM emp
START WITH ename='KING' --'SCOTT'
CONNECT BY PRIOR empno = mgr
--Using WHERE clause to eliminate a node.
SELECT deptno, empno,ename, job, sal
FROM emp
WHERE ename != 'FORD'
START WITH mgr IS NULL
CONNECT BY PRIOR empno = mgr;
-- Using CONNECT BY clause to eliminate a branch.
SELECT deptno, empno,ename, job, sal
FROM emp
START WITH mgr IS NULL
CONNECT BY PRIOR empno = mgr
AND ename != 'FORD'
SELECT EName "Employee",
LEVEL,
SYS_CONNECT_BY_PATH(ename, ' /') "Path"
FROM emp
START WITH mgr is null
CONNECT BY PRIOR empno = mgr;
-- 10g features
-- connect by isleaf
Select Ename "Employee", Connect_by_isleaf "IsLeaf", Level,
Sys_connect_by_path (Ename, ' /') "Path"
From Emp
Start With Mgr Is Null
Connect By Prior Empno = Mgr;
-- connect by iscycle
SELECT EName "Employee",
CONNECT_BY_ISLEAF "IsLeaf",
CONNECT_BY_ISCYCLE "IsCycle",
LEVEL,
SYS_CONNECT_BY_PATH(ename, ' /') "Path"
FROM emp
START WITH mgr is null
CONNECT BY nocycle prior empno = mgr;
-- connect by root
SELECT ename "Employee", CONNECT_BY_ROOT ename "Manager",
LEVEL-1 "Pathlen", SYS_CONNECT_BY_PATH(ename, '/') "Path"
FROM emp
WHERE LEVEL > 1 and deptno = 10
CONNECT BY PRIOR empno = mgr; -
How to find table name(s) in a dynamic query
In one of our (9iAS PORTAL)applications, any user can able to run their query statment and get output. All queries will be executed as dynamic SQL thru' a common shema/user who has 'SELECT' privilege on all tables but all users don't have this privilege on all tables. Now, before executing any query I need to find out what are the table name(s) used in this query to check the privilege for the respective user. How do I extract all table names being used in a dynamic query?.
Thanks
-KrishnamurthyI guess that his users log in to application first, then application uses one account to log in to database, so application are not direct database user since all users share the same account to database. If so, when a user lgins in, you may write it down from application to a database audit table, and you need to write down the dynamic query to the database audit table too, then you may query that audit table to find out. up to here, it looks that your application has to do more to assign what role to a user running the application, since database does not know what user is assessing it.
-
SQL Query to find Receipt No.s which are not matched to AP Invoices
Hi
Please help me to frame a query to find list of Receipt No.s which are not matched with AP Invoices.
Please refer to the below query .
SELECT
poh.segment1 "PO No.",
aps.vendor_name "Supplier Name",
pol.item_description "Item Description",
rcvh.receipt_num "GRV No.s",
rcvl.quantity_received "Quantity",
pol.unit_price "Rate/Unit",
rcvtl.tax_name||' - '||initcap(rcvtl.tax_type) "Tax",
(rcvl.quantity_received * pol.unit_price) + nvl(rcvtl.tax_amount,0) "Amount"
FROM
po_headers_all poh,
po_lines_all pol,
po_distributions_all pod,
ap_suppliers aps,
rcv_shipment_headers rcvh,
rcv_shipment_lines rcvl,
rcv_transactions rcvt,
jai_rcv_line_taxes rcvtl
WHERE
poh.po_header_id = pol.po_header_id
AND poh.po_header_id = pod.po_header_id
AND pol.po_line_id = pod.po_line_id
AND aps.vendor_id = poh.vendor_id
AND aps.vendor_id = rcvh.vendor_id
AND rcvh.shipment_header_id = rcvl.shipment_header_id
AND poh.po_header_id = rcvl.po_header_id
AND pol.po_line_id = rcvl.po_line_id
AND rcvh.shipment_header_id = rcvt.shipment_header_id
AND rcvl.shipment_line_id = rcvt.shipment_line_id
AND poh.po_header_id = rcvt.po_header_id
AND pol.po_line_id = rcvt.po_line_id
AND aps.vendor_id = rcvt.vendor_id
AND rcvh.shipment_header_id = rcvtl.shipment_header_id
AND rcvl.shipment_line_id = rcvtl.shipment_line_id
AND rcvt.transaction_id = rcvtl.transaction_id
AND aps.vendor_id = rcvtl.vendor_id
AND rcvt.transaction_type = 'RECEIVE'
AND poh.authorization_status = 'APPROVED'
AND poh.segment1 = '210001079'
I have'nt included the Invoice Tables in the above query.
Please help me in that area.
This is bit urgent.
Please help me.
Regards
Nakul VenkatramanI am using ORACLE 11gR2 If you're licensed for Diangnostics pack then you might want to look at the AWR tables, e.g. DBA_HIST_SQLSTAT and cross-reference with DBA_HIST_SNAPSHOT.
By this will i get the top 5 consumed queries of DEV user in the whole session or its just the top 5 queries at that particular time. The "executions" columns in this query, does it mean that the no. of. times the query has executed... This will get you a random 5 queries that were first parsed by DEV. Depending on your application code/structure, it may well be that all code (except for system-recursive sql) executed by DEV is parsed by DEV, and all code parsed by DEV is executed by DEV but this isn't true for all.
In terms of top N queries, you need to ORDER BY and then restrict by ROWNUM at an outer level to the ROWNUM otherwise the ROWNUM filter is applied before the ORDER BY.
i.e.
SELECT *
FROM
(SELECT ...
FROM ...
WHERE
ORDER BY...)
WHERE ROWNUM <= ....
The "executions" columns in this query, does it mean that the no. of. times the query has executedYes.
http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/dynviews_3064.htm#REFRN30259
Edited by: Dom Brooks on Oct 24, 2011 9:45 AM -
How to find lsit of Infoobjects per query in a table
Hi All,
is there a way to find list of all the info Objects per query in a table.
i know there are tables like RSZELTXREF and rszcompdir and rsrrepdir
I am not able to make out the relation between them.
All I want is to know what are the characteristics per query.
I have a list of queries and need to know what are the characteristics in them.
Please reply.
Many Thanks,
JogaUse the below way:
1. Use RSRREPDIR table: Provide your technical name of the Query in COMPID field. Hit F8. Collec the COMPUID of the query here.
2. Use table: RSZELTXREF: Provide the COPMUID from RSRREPDIR table in SELTUID field and hit F8. in Active version. Here collect the element details from the field TELTUID.
3. Use table RSZELTTXT: and provide all the elements list that you hvae collected in step 2 in ELTUID field of this table. Hit F8. Once done you can see the individual object lists in Short text as well as in Long text.
Always use Object version as "A" to get the active object list.
Hope this clarifies your requirement. -
Query to find out whether a table is sub-partitoned , composite type one
Could you please let me know the query to find out whether a paritioned table
is
1). composite paritioned one.
2). sub-paritioned one.
I find that there are 2 cols in all_tab_partitions view, which lets me know
1). COMPOSITE VARCHAR2(3)
To find composite paritioned one or not.
2). SUBPARTITION_COUNT NUMBER
To find whether a table is sub-paritioned one or not.
Any light on the above topic is highly appreciated.So it seems you've found the answer yourself?
with »user_tab_partitions« and »user_tab_subpartitons« you'll get all the neccessary information you are looking for. -
How to find Tables behind a Custom Query in SAP
Hi Gurus,
Can anyone please help me find tables behind a custom query in SAP.
Regards
AsHi
Check the name of the programm assigned to transaction, it should be like this:
AQZZ<user group>=======<query name>======
or
AQIC<user group>=======<query name>======
It depends of the query area is global or cross-client
So run SQ01, select the quey area, select the quey group and so your query: now you can see the infoset and then you see it by SQ02 transaction
Max -
How do I query to find out if the MONITORING clause was enabled on a table?
Our customers are currently running Oracle 8.1.7 in the field. I am writing a database schema updater tool that is supposed to examine the schemas and make necessary changes to them.
Recently, the MONITORING clause was added to many of the tables in our schemas. I need to find out if the tables currently have MONITORING enabled.
But, even though the Oracle documentation is very large, again, I cannot find any information about how to determine if MONITORING on a table is on or off.
Any ideas? An SQL query? JDBC metadata?
Tom Harris
Cisco Systems, Inc.What is the output of the following statements on your system?
Remember, table names are stored in caps in the dictionary if not enclosed within double-quotes.
SQL> create table t (x number) ;
Table created.
SQL> select monitoring from user_tables where table_name = 'T' ;
MON
NO
1 row selected.
SQL> alter table t monitoring ;
Table altered.
SQL> select monitoring from user_tables where table_name = 'T' ;
MON
YES
1 row selected.
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
SQL> -
Query to find the Salary table details HRMS 11i
I am looking query to find the persons salary details in Oralce EBS 11i.
I tried the below query bu it didn'ty work.
SELECT papf.employee_number
,papf.full_name
,pj.NAME job
,haou.NAME ORGANIZATION
,ppp.proposed_salary_n salary
FROM per_all_people_f papf
,per_all_assignments_f paaf
,per_jobs pj
,hr_all_organization_units haou
,per_position_definitions ppd
,per_all_positions pap
,per_pay_proposals ppp
WHERE 1 = 1
AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
AND papf.current_employee_flag = 'Y'
AND papf.employee_number IS NOT NULL
AND paaf.person_id = papf.person_id
AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND paaf.job_id = pj.job_id
AND paaf.organization_id = haou.organization_id
AND paaf.position_id = pap.position_id
AND pap.position_definition_id = ppd.position_definition_id
AND ppp.pay_proposal_id = (SELECT MAX (pay_proposal_id)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id)
In our case all the below tables have 0 records..
select count(*) from PER_PAY_PROPOSALS ;
COUNT(*)
0
select count(*) from pay_element_entry_values_f;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRY_VALUES_F;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRIES_F;
COUNT(*)
0Hi,
Your results clearly states that there is no salary data which is been captured as well as there are no element entries which are assigned to any assignment.
Please do the below which will insert records in salary as well as element entries table:
1. Add a salary proposal to any active employee (People Enter and Maination --> Search for any employee --> Assignment --> Salary) - This will insert a record in PER_PAY_PROPOSALS table
2. Add an element entry to any active assignment (People Enter and Maination --> Search for any employee --> Assignment --> Entries) - This will insert a record in PAY_ELEMENT_ENTRIES_F and PAY_ELEMENT_ENTRY_VALUES_F table
Hope this clarifies.
Thanks,
Sanjay -
Query to find indexes bigger in size than tables sizes
Team -
I am looking for a query to find the list of indexes in a schema or in a entire database which are bigger in size than the respective tables size .
Db version : Any
Thanks
Venkatresults are the same in my case
1 select di.owner, di.index_name, di.table_name
2 from dba_indexes di, dba_segments ds
3 where ds.blocks > (select dt.blocks
4 from dba_tables dt
5 where di.owner = dt.owner
6 and di.leaf_blocks > dt.blocks
7 and di.table_name = dt.table_name)
8* and ds.segment_name = di.index_name
SQL> /
OWNER INDEX_NAME TABLE_NAME
SYS I_CON1 CON$
SYS I_OBJAUTH1 OBJAUTH$
SYS I_OBJAUTH2 OBJAUTH$
SYS I_PROCEDUREINFO1 PROCEDUREINFO$
SYS I_DEPENDENCY1 DEPENDENCY$
SYS I_ACCESS1 ACCESS$
SYS I_OID1 OID$
SYS I_PROCEDUREC$ PROCEDUREC$
SYS I_PROCEDUREPLSQL$ PROCEDUREPLSQL$
SYS I_WARNING_SETTINGS WARNING_SETTINGS$
SYS I_WRI$_OPTSTAT_TAB_OBJ#_ST WRI$_OPTSTAT_TAB_HISTORY
SYS I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST WRI$_OPTSTAT_HISTGRM_HISTORY
SYS WRH$_PGASTAT_PK WRH$_PGASTAT
SYSMAN MGMT_STRING_METRIC_HISTORY_PK MGMT_STRING_METRIC_HISTORY
DBADMIN TSTNDX TSTTBL
15 rows selected -
Query to find the no of columns in a table
Is there a query to find the total number of columns in a table?
Dou you know read?
-- the number of rows in a table named yourtable:
select count(1) from yourtable;
-- the number of columns in a table
-- If is a user's table:
select count(1)
from user_tab_columns
where table_name='YOURTABLE'
--If it is´t
select count(1)
from DBA_tab_columns
where owner = 'USEROWNER'
and table_name='YOURTABLE'
Maybe you are looking for
-
Updating Adobe Creative Cloud Enterprise
I recieved 2 Adobe Creative Cloud Enterprise licenses to fulfill my insurance on Adobe Premiere. I see how to use the packager to deploy applications to end users, but the update option in the help menu is greyed out. Does anyone know the best way to
-
Can not complete install of elements 13
Exit Code: 7 Please see specific errors below for troubleshooting. For example, ERROR: -------------------------------------- Summary -------------------------------------- - 0 fatal error(s), 2 error(s) ERROR: This installer does not support install
-
Dear All; I am new to ADF security, my target is to create a web application, with authentication through a login page, and session tracking through out the users session, i used to do this all in code, the JSP way, where i check the session in every
-
HT1848 Having trouble transferring music to my computer.
I tried to click on the "transfer music from my iPhone" button but the music will not be transfered to my computer. For a second it worked with the Genius, I thought, but then when I disconnected my phone, the songs were no longer in the library. Is
-
How do I remove NIDAQ drivers version 6.8.1 when thier is not an uninstall file?
How do I remove NIDAQ driver version 6.8.1 when their is not an uninstall file? I tried installing the latest version of NIDAQ, but am unable to until the old version (6.8.1) has been uninstalled. There is no uninstall feature in the add/remove optio