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,
MS
user_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
Similar Messages
-
Need MDX query to find something like date diff and Date Range for last 10 days
Hi ,
I need two Query .First Query for below;
I have below data in table like.
Cat StartDate EndDate
A 2000-01-01 2000-01-15
B 2000-01-02 2000-01-30
C 2000-01-01 2000-01-31
D 2000-02-01 2000-02-28
A 2000-01-10 2000-01-31
I need if Startdate and Date completes whole one month then set status =1 else 0 using MDX query.
like this ;
Cat StartDate EndDate Status
A 2000-01-01 2000-01-15 1
B 2000-01-02 2000-01-30 0
C 2000-01-01 2000-01-31 1
D 2000-02-01 2000-02-28 1
A 2000-01-10 2000-01-31 1
In second query I need last 10 days from current days like;
Now = 8/20/2014
output will be ;
8/20/2014
8/19/2014
8/18/2014
8/17/2014
8/16/2014
8/15/2014
8/14/2014
8/13/2014
8/12/2014
8/11/2014
8/10/2014
Please help me .
ThanksHi Prajapati,
In your scenario, you can use Properties and Datediff function to achieve your requirement. Since not know the structure of your cube, we cannot give you the esact query.
I have tested it on the AdventureWorks cube, the query below is for you reference.
WITH MEMBER [Measures].[StartDate]
AS
[Employee].[Employee Department].CURRENTMEMBER.PROPERTIES('Start Date')
MEMBER [Measures].[WorkYear]
AS
DATEDIFF('yyyy',[Measures].[StartDate],NOW())
MEMBER [Measures].[Status]
AS
IIF(DATEDIFF('yyyy',[Measures].[StartDate],NOW())>10,1,0)
SELECT {[Measures].[StartDate],[Measures].[WorkYear],[Measures].[Status]} ON 0,
[Employee].[Employee Department].[Employee].MEMBERS ON 1
FROM [Adventure Works]
Results
Reference
http://msdn.microsoft.com/en-us/library/ms144821.aspx
Regards,
Charlie Liao
TechNet Community Support -
Need a query to find Grops mapped on Folders
Hi ,
I need a query builder query to find out the list of folder and mapped groups to those folder.
Would you please let me know if that is possible I triead but no luck .
Regards,
NeoHi,
This query sound goods but I get error
Select SI_NAME, SI_KIND From CI_APPOBJECTS, CI_INFOOBJECTS
Where PARENTS("SI_NAME='Myfolder'",'CHILDREN(''SI_NAME=''UserGroup''')")
Please let me know if I am giong in right direction becuse I never used Parents and child concept bit confused.
All I need is when I put in my folder name it has to show me all the groups mapped to it.
If this query gives the result , it will be the great logic I would say
Thanks a ot.
Neo A -
Need a query for access tables
Hi
I need a query , help please:
table1:
id description serial
1 des1 ser1
2 des2 ser2
3 des3 ser3
table2:
id id1(id of table1) date
stat
1 1
2001 A
2 1
2008 N
3 2
2010 A
4 1
2012 F
==============
i need this data structure: (stat column must return for maximum date of id1 from table2)
id(from table1) serial(from table1) stat(from table2)
1 ser1
2012
2 ser2
2010
3 ser3
Nullmaybe you can try this.
declare @t1 table
(id int,[description] varchar(50),serial varchar(10))
declare @t2 table
(id int,id1 int,[date] char(4),stat char(10))
insert into @t1 values
(1,'des1','ser1'),
(2,'des2','ser2'),
(3,'des3','ser3')
insert into @t2 values
(1,1,'2001','A'),
(2,1,'2008','N'),
(3,2,'2010','A'),
(4,1,'2012','F')
select a.id,a.serial,max(b.date)
from @t1 a
left join @t2 b
on a.id = b.id1
group by a.id,a.serial
| SQL PASS Taiwan Page |
SQL PASS Taiwan Group
|
My Blog -
Need a query for export table data .....
Hi,
I need a query for exporting the data in a table to a file.
Can anyone help me ?
Thanking You
JeneeshSQL> spool dept.txt
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> spool off
SQL> ed dept.txt -
Need a Query to find Unassigned Price Lists
Hi
I need a query which will show any Price List NOT assigned to a Business Partner. I have the following:
SELECT T0.[ListNum], T0.{ListName] From OPLN T0
WHERE T0.[ListNum} NOT IN T1.[ListNum[ from OCRD T1
Haven't worked that much with NOT IN statement.
Thank you!Hi Daniel,
Please check below Query.
SELECT T0.[ListNum], T0.[ListName] From OPLN T0 WHERE T0.[ListNum] NOT IN ( SELECT DISTINCT T1.[ListNum] FROM OCRD T1 )
Hope this help
Regards::::
Atul Chakraborty -
Need a query to find a table by two of its column names
I work in software quality assurance. Oftentimes I am trying to figure out from which table data is being pulled, but the database has thousands of tables to look through. Instead of looking through all the tables, I just take a guess at one of the column names and execute a query like this:
SELECT table_name FROM information_schema.columns WHERE column_name like '%pur%code%'
That usually works, but occassionally it can return hundreds of table names which doesn't help me much. Instead, I'd like to form a query that could take two column names and return all the tables that have those columns.
So, in English, I want to say:
"Give me the names of all the tables that have a column named like %pur%code% and another column named like %client%loc%"
How do I do this?One might have hoped that the QA guy actually had sufficient documentation to tell him which table information was "pulled from".
(or is he actually checking that the documentation is accurate and complete .... )
SQL> select phrase from well_known
where upper ( phrase ) like '%PIG%' and upper ( phrase ) like '%FLY%' -
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 -
Need sql query to find out same item is used in open po and closed po
Hi Experts,
I have an requirement is that, i need to find out the item is used in open po and closed po.
example: A is the item is used in closed PO and Open PO.
i need to write down the scripts how many same items is used in open po and closed po.
if any sql script is there please share.
Please let us know if any concerns.
Thanks
bmnHi
Please try below query
select
distinct c.segment1
from
po_lines_all a,
po_line_locations_all b,
mtl_system_items_b c
where
a.po_line_id= b.po_line_id
and a.item_id=c.inventory_item_id
and b.closed_code='OPEN'
and a.item_id in ( select
item_id
from
po_lines_all d,
po_line_locations_all e,
mtl_system_items_b f
where
d.po_line_id= e.po_line_id
and d.item_id=f.inventory_item_id
and e.closed_code in ('CLOSED','FINALLY CLOSED','CLOSED FOR INVOICE','CLOSED FOR RECEIVING')); -
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 -
I have 5 columns in a table and these columns have newline characters data( either chr(10) or chr(13)).
Now I need to fetch data so that all the records which have new line character( either chr(10) or chr(13) ) in any of these 5 columns should be retrieved.
Please help me with a correct query for this task.
Edited by: nav on Jun 2, 2011 10:21 PMAn example .. you can do it for all 5 columns adding "OR" conditions
with t as
(select 'Arun'||chr(10) a, 'Gupta'||chr(13) b from dual union all
select 'Dinesh'||chr(10) a, 'Kumar'||chr(13) b from dual union all
select 'Naresh'||chr(10) a, 'Raja' b from dual union all
select 'Harish' a, 'Mahesh' b from dual union all
select 'Jatin'||CHR(13) a, 'Mahesh' b from dual
select * from t
where a like '%'||CHR(10)
or a like '%'||CHR(13)
or b like '%'||CHR(10)
or b like '%'||CHR(13) Regards
Arun -
Need a Query to find whether the database needs any media recovery...
Hi,
I am at the mount stage of a database and yet be opened.at this stage any Query is available or any other way is there to find whether the database needs any media recovery or Instance recovery..?
my objective is before opening the database i need to make sure it is consistent or inconsistent and any form of recovery is needed..
thanks ®ards,
Ragunath
Edited by: ragu.dba.in on Mar 6, 2013 12:57 AMHi Ragunath,
Use these queries , SCN should be consistent .. no fuzzy files, check for recovery of files in v$recover_file .. pass sufficient archives & fulfill the checks before open reset-logs
set line 900
set pages 900
set echo on
alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
set numwidth 13
col CHECKPOINT_CHANGE# for 9999999999999999
col CHANGE# for 9999999999999999
column error format a10
column member format a60
show parameter db_recover
select * from v$recover_file;
select file#, status from v$datafile;
select file#, checkpoint_change#, checkpoint_time, error from v$datafile_header;
select distinct status from v$backup;
select distinct checkpoint_change# from v$datafile_header;
select hxfil file_id, fhscn scn, fhthr thread, fhrba_seq sequence, fhsta status from x$kcvfh;
select distinct fhscn from x$kcvfh;
select hxfil file_id, fhtnm tablespace_name from x$kcvfh;
##### Fuzzy Check ####
alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
set feedback on
set heading on
set pagesize 1000
set linesize 175
column checkpoint_change# format 999999999999999999999
select status, checkpoint_change#, fuzzy,
to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as checkpoint_time,
count(*)
from v$datafile_header
group by status, checkpoint_change#, fuzzy, checkpoint_time
order by status, checkpoint_change#, fuzzy, checkpoint_time;Thanks,
Ajay More
http://www.moreajays.com -
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
ThanksHi 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 -
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 -
Need sql query to find out Joins attached with folders in Discoverer
Hi,
Can anyone let me know the sql query which can be used to identify the joins which are attached to the folders.
Actually we have to identify all the joins conditions from folders those are migrated from one instance to others.
Thanks
abhishekI recommend that you implement the admin EUL supplied by oracle, you can get there a lot of repository information (metalink note: 556932.1).
Try to use this (maybe you will need some pkg's):
SELECT
DECODE(KEYS.FK_MANDATORY,
1,
'Always exist in master folder',
'Might not exist in master folder') "Detail Item values",
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID, 'N') "Join Master --> Detail",
KEYS.KEY_DESCRIPTION JOIN_DESCRIPTION,
KEYS.KEY_DEVELOPER_KEY JOIN_IDENTIFIER,
KEYS.KEY_NAME JOIN_NAME,
DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') "AutoGen",
DECODE(DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') ,
'Yes',
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID),
KEYS.KEY_NAME) "Actual Join Name",
KEYS.KEY_UPDATED_DATE JOIN_LAST_UPDATE,
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "One to One join",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) "Outer Join on Detail",
DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) "Outer Join on Master",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) || DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) ||
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "Optional Join Configurations",
OBJ.OBJ_NAME "MASTER_FOLDER",
OBJ_DETAIL.OBJ_NAME "DETAIL_FOLDER"
FROM EUL10G_US.EUL5_OBJS OBJ,
EUL10G_US.EUL5_EXPRESSIONS EXP,
EUL10G_US.EUL5_KEY_CONS KEYS,
EUL10G_US.EUL5_OBJS OBJ_DETAIL
WHERE ((KEYS.KEY_ID = EXP.JP_KEY_ID) AND
(OBJ.OBJ_ID = KEYS.FK_OBJ_ID_REMOTE) AND
(OBJ_DETAIL.OBJ_ID = keys.KEY_OBJ_ID));
Maybe you are looking for
-
Getting ODI - 20088 error while Generating the Scenario.
Hi Gurus, When i am trying to create a scenario for the duplicated Package i am getting the following error. Source temporary interface SDE_ORA_WorkorderDimension_EAM.W_WORKORDER_DS_SQ_WIP_DISCRETE_JOBS cannot be used as a derived table. Source datas
-
Portal Password Reset - Active Directory - Urgent
Friends We are using SAP Portal 6.0 SP 18. The Portal UME data source has been configured with Microsoft ADS. Now we have an requirement to change the user Password in the Active Directory from the Portal. How can we achieve this...? I am OK even t
-
Failed to open database connections
Hi all, I have installed oracle db succesfully, but when I run operational client, it downloads some plugins for a while, but then crashed abovementioned error. Any ideas what should I test in this situation? Br. Mr. Pasi Finland
-
Subject: exp query=\"where to_char\(DATE_FIELD\,\'MMYYYY\'\)=\'032006\'\" RDBMS Version: 9.2.0.7 Operating System and Version: AIX 5 Error Number (if applicable): LRM-00101 Product (i.e. SQL*Loader, Import, etc.): export Product Version: 9.2.0.7 exp
-
Why does search engine drop down menu only works once?
I'm quite happy with the new Safari 4 (first time user) but I'm frustrated by only being able to select once with my mouse from the 'Recent Searches' drop down window. Let me explain. After I launch Safari 4, I'm able to use my mouse and select one o