Finding tables that contain a column
Hi all,
I am a relatively new SQL user and am trying to figure out how to find all tables that contain a particular column, eg, 'cust_id'. I have tried a bunch of different things and searched on Google but I think I don't quite have/understand the syntax I need.
Also, how would I display a list of all the columns in all the tables?
Thanks!
Hi,
apex wrote:
Thanks for the input! I got my first question working.
I am still trying to understand basic ideas in SQL, eg what is the all_tab_columns in Raj's link, as usually I call something from a particular table. All_tab_columns is a view in the sys schema. There are several tables and views in the sys schema whose names start with user_ or all_ (or dba_, but you may not have privileges to see those) which are collectively called the Data Dictionary . They contain information about the database itself, including the tables in the database.
It states there that the ANALYZE command can be used to gather statistics for this view, but I have not been able to get it working.
Eg, in Oracle SQL Developer, I type in "help <analyze>" but it doesn't tell me what the syntax of this command is, I had to use Google which gives the following
To estimate statistics:
ANALYZE TABLE tablename ESTIMATE STATISTICS SAMPLE 30 PERCENT;
To compute statistics:
ANALYZE TABLE tablename COMPUTE STATISTICS;
But when I try the last one it just says
table CUSTOMERS analyzed.
but I don't see any output, and if I try to use ANALYZE all_tab_columns; it gives me an error message. When you analyze a table, a message like "table CUSTOMERS analyzed" is all you expect to see. The main purpose of anlyzing isn't to produce a report for you to read (as helpful as thant might be) but to update the data dictionary, so that Oracle knows how to do queries efficiently. For example, if you have a query like
SELECT *
FROM patients
WHERE birth_date = DATE '1981-07-28'
AND state_abbr = 'NY';How does the system decide whether to look for rows with the right birth_date first, or the right state? The statistics in the data dictionary might tell it that birth_date has many more ditinct values, so looking for a particular birth_date first will narrow down the search much faster than looking for a particular state.
By the way, the ANALYZE command has been deprecated. Unless you're using a very old version of Oracle, you should be calling the dbms_stats package instead:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_stats.htm#CIHBIEII
I am using Sam's teach yourself SQL in 10 minutes which is very good at the very specific commands and functions it describes but doesn't really orient me to the language, doesn't explain how to use the help functions, or any treatment of tasks not contanied in the book. If someone can recommend another source would appreciate it. Much thanks!That's the frustrating thing about books; you can't ask them questions. (On the other hand, that's one of the nice things about this forum.)
I can understand why the book doesn't say much about analyzing. The book is about SQL (e.g., how to create a table or write a query). Statistics are not in the scope of that book. Actually, they're not really in the scope of this forum, either. If you have questions about statistics, you're better off posting them in the "Database - General" forum:
General Database Discussions
Similar Messages
-
Table that contain epstp field
dear all expert
i want to create report for pr relase
i have some problem, in item category i found epstp field, but i cannot found the table
in eban i found pstyp, but its different with epstp
please help me to found table that contain epstp fieldHi,
you can find in T163X and T163Y.
epstp is Item category in purchasing document.
Regrds,
Nikhil. -
Optimise query on the table which contain 1000 column
Hi ,
I have query on the table which contain 1000 columns
when i am executing query on same table .It is taking time .
Select * from abc
where col1 between start_date and end_date ;
abc table contain 1000 columns.
please tell me how to optimise queryYeah, that was my thought as well ... 1000 columns? wtf?
I can't think of many reasons for why you'd need to do a select * on it, and the scenarios that would require that are better addressed at the DBA level, perhaps using db replication and the data pump, etc. So to start with try selecting just the data you would need.
One thing you can do right off the bat is to partition that table by date, and also to analyze and run statistics on it (this was a nightly operation at my last job).
You can also create a materialzed view that refreshes overnight, just on the slice of the data you need. Use a forced fast refresh to make it current before you use it. -
Tables that contains the legacy systems authorization information
Hi all,
I'm setting up legacy systems in my SAP GRC 5.3. We would like to check if the information uploaded from the extractor is correct. Does anyone know what are the GRC 5.3 tables that contains all the systems authorization from the legacy system uploaded?
Thank you in advanced.Hi,
If I understand your question correctly, you wish to know the GRC 5.3 RAR tables that contains the authorization information and want to connect a legacy system.
If you check the /VIRSA/* tables, you can find all the GRC related tables.
However, if you are trying to perform an offline risk analysis, refer the below Article:
http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/20a06e3f-24b6-2a10-dba0-e8174339c47c
Hope this helps!!
Regards,
Raghu -
Prepare statement to insert a row that contains Blob column. Which way is correct?
When we make prepare statement to insert a row that contains Blob column. Which way is correct? And what is the difference? Does anyone know?
1. Preparestatement.setBlob(parameter number, blob type object)
2. Preparestatement.setBlob(parameter number, inputstream type object)
This link show the test I made.
https://community.oracle.com/thread/3680185?sr=inbox&customTheme=otnWhen we make prepare statement to insert a row that contains Blob column. Which way is correct? And what is the difference? Does anyone know?
1. Preparestatement.setBlob(parameter number, blob type object)
2. Preparestatement.setBlob(parameter number, inputstream type object)
I answered that in your other thread and provided a link to the JDBC Dev Guide section that discusses how to work with LOBs and BFILEs.
Did you read that doc section?
Did you read my reply in your other thread?
In java a BLOB is just the locator that gives you access to the actual content. In your case you got access by selecting an existing BLOB locator and getting its inputstream. That inputstream is what gives you access to the actual blob content.
The locator is just that; it specifies the LOCATION of the blob content but it is NOT the content. -
Hyperion Explorer 8.3 querying multiple tables that contain a specific item
I have 3 annual tables that contain data for 3 different years. Each table has a sale amount, item sold, and customer ID. I want to pull a specific customer ID from all 3 tables at once.
Is there a way to achieve this?
Thanks!
JohnnyAdd the 3 fields from the first table, then click Query > Append Query, then add the same 3 fields in the same order from the second table, then add the same 3 fields in the same order from the third table. This creates a UNION between the three tables; which means they need to be in the same order and have the same datatype.
If you want to show duplicate data found in the different sources, just change the UNION operator to a UNION ALL operator, otherwise it will suppress any duplicate rows.
To limit the data to one specific customer ID, you can set a limit on each of the UNION tabs with 'Customer ID = <selection>'.
Good luck!
Jarod Vierstra -
Need to update a table that contains large volume of xml data
Hi,
i want to update a table that contains large amount of XML data.
when execute the query it shows an error .
Xml parsing is failed .But tghe data in xml is well formed.don't know why its happening .
Pls help me on this.
Thanks,
Fahadbelow is my code..
pls do the needful.
create or replace
PROCEDURE SPFETCHRETRIEVEDATA (
p_txteordernum IN trnorderitem.TXTEORDERNUM%TYPE,
p_intversionnum IN trnorderitem.INTVERSIONNUM%TYPE ,
p_interrorcode OUT NUMBER)
AS
------variable declaration---
v_xmlorderitem XMLTYPE;
v_trnsiebelmodification XMLTYPE;
diff XMLTYPE;
BEGIN
BEGIN
select xmlorderitemxml into v_xmlorderitem
from trnorderitem
where TXTEORDERNUM= p_txteordernum
AND INTVERSIONNUM= p_intversionnum;
END;
--insert into tempxml values ('xmlorderitem',v_xmlorderitem);commit;
BEGIN
SELECT TrnSiebelModificationXML into v_trnsiebelmodification
from trnsiebelmodification
where TXTEORDERNUM= p_txteordernum
AND INTVERSIONNUM= p_intversionnum
AND TXTSIEBELFIELDNAME='Asset XML';
-- insert into tempxml values ('trnsiebelmodification',v_trnsiebelmodification);commit;
-- EXCEPTION
-- WHEN TOO_MANY_ROWS THEN
-- dbms_output.put_line('Statement return multiple rows');
END;
--------comparing differences between xml data and storing into a variable -----------
BEGIN
select xmldiff(v_xmlorderitem, v_trnsiebelmodification)
into diff
from dual;
--insert into tempxml values ('diffxml',diff);commit;
if diff IS NOT NULL THEN
UPDATE trnsiebelmodification
SET TXTACTIONTYPE='Update2'
WHERE TXTEORDERNUM= p_txteordernum
AND INTVERSIONNUM= p_intversionnum
AND TXTSIEBELFIELDNAME='Asset XML';
ELSE
UPDATE trnsiebelmodification
SET TXTACTIONTYPE='No Change2'
WHERE TXTEORDERNUM= p_txteordernum
AND INTVERSIONNUM= p_intversionnum
AND TXTSIEBELFIELDNAME='Asset XML';
END IF;
END;
END SPFETCHRETRIEVEDATA;Edited by: BluShadow on 11-Sep-2012 14:13
added {noformat}{noformat} tags. Please read: {message:id=9360002} and learn to do this yourself. -
ANYBODY GIVE ME THE TABLE/TABLES THAT CONTAIN TCODE AND DEVELOPMENT CLASS
ANYBODY GIVE ME THE TABLE/TABLES THAT CONTAIN TCODE AND DEVELOPMENT CLASS
Hi phani,
The table TSTC contains the transaction codes.
Also the below links provides a lot of info on the Standard SAP Tables.
http://www.sapdev.co.uk/tables/tables.htm
Pls reward if useful..
Thanks,
Sirisha. -
Count number of distinct values for a column for all tables that contains that column
Imagine I have one Column called cdperson. With the query below I know which Tables have column cdperson
select
t.[name]fromsys.schemassinnerjoin
sys.tables
tons.schema_id=t.schema_idinnerjoin
sys.columnscont.object_id=c.object_idinnerjoin
sys.types
donc.user_type_id=d.user_type_idwherec.name ='cdperson'
now I want to know for each table, how many distinct values of cdperson I have and I want the result ordered by the table that has more distinct values (descending)
Table1
cdperson select distinct(cdperson) = 10
cdadress
quant
Table2 with
cdaddress (no column cdperson in this table)
quant
Table3
cdperson select distinct(cdperson) = 100
value
Table 4
cdperson select distinct(cdperson) = 18
sum
I want this result ordered by number of distinct cdperson
table3 100
table4 18
table 10
Thks for your answersI had to add schema name to the above script to make it work in AdventureWorks:
CREATE TABLE #temp(TableName sysname , CNT BIGINT)
DECLARE @QRY NVARCHAR(MAX);
SET @qry=(SELECT
N'INSERT INTO #TEMP SELECT '''+schema_name(t.schema_id)+'.'+T.[name] +''' AS TableName, COUNT (DISTINCT ProductID) DistCount FROM '+
schema_name(t.schema_id)+'.'+t.[name] +';'
FROM sys.schemas s INNER JOIN sys.tables t ON s.schema_id=t.SCHEMA_ID
INNER JOIN sys.columns c ON t.object_id=c.object_id INNER JOIN sys.types d ON c.user_type_id=d.user_type_id
WHERE c.name ='ProductID'
FOR XML PATH(''))
EXEC(@QRY)
SELECT * FROM #temp ORDER BY TableName
DROP TABLE #temp
Production.Product 504
Production.ProductCostHistory 293
Production.ProductDocument 31
Production.ProductInventory 432
Production.ProductListPriceHistory 293
Production.ProductProductPhoto 504
Production.ProductReview 3
Production.TransactionHistory 441
Production.TransactionHistoryArchive 497
Production.WorkOrder 238
Production.WorkOrderRouting 149
Purchasing.ProductVendor 211
Purchasing.PurchaseOrderDetail 211
Sales.SalesOrderDetail 266
Sales.ShoppingCartItem 3
Sales.SpecialOfferProduct 295
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
How do you sort a table that contains links to cells in another table?
This is something that I used to be able to do in Numbers but since 2 or 3 updates ago this doesn't seem to happen.
The problem I have is that I have a table that includes cells that are a sum of a number of cells from another table. When I try and sort by a column all the info in the cells change because, I imagine, the commands linking to the cells in the other table are offsetting by however many rows a particular row has moved.
This didn't used to happen; it used to hold on to the same data and links regardless of where the sort function moved a row to.
Had a look through the help pages but can't find anything about it. Has anyone found a way around this?
Thanks in advance.
MattHi mmatt,
There are several ways to create sort-safe formulas. Without knowing what you are doing in your table it is hard to give specific advice but in general INDEX(), OFFSET() and I think INDIRECT() are sort safe- ie they will ocntinue to point to the same cell wherever they are in your sort.
If you want specific advice you would need to provide more info.
quinn -
Where Is Table That Contains DTP Filter Entries?
Hi,
I am trying to find the table where my "Filter" entries for a DTP are contained. I would like to use these entries in my start routine. In the old 3.5, the table was RSSELDONE, but I can't seem to find the NW04S version of this table.
Thanks for your help.P-Dub:
To date I have not found a table that specifically contains the DTP filter entries. If you are looking for a way to access this information from a transformation though, you may reference following logic:
create an internal table (itab) of type RSBK_S_RANGE in the local portion of a start routine.
fill the internal table (itab) as follows:
itab[] = p_r_request->GET_TH_RANGE( ).
The selection criteria of the DTP will then be available within your transformation in the internal table itab.
All DTP attributes at run time can be accessed in this way. For a list of the methods available, look at the interface if_rsbk_request_admintab_view, know as p_r_request in the start routine.
==============Start Routine CODE Example - BEGIN==============
Method start_routine
Calculation of source package via start routine
<-> source package
METHOD start_routine.
*=== Segments ===
FIELD-SYMBOLS:
<SOURCE_FIELDS> TYPE tys_SC_1.
DATA:
MONITOR_REC TYPE rstmonitor.
$$ begin of routine - insert your code only below this line -
... "insert your code here
DATA: i_dtpfilter type standard table of RSBK_S_RANGE
initial size 0.
break CONTDG.
i_dtpfilter[] = p_r_request->GET_TH_RANGE( ).
==============Start Routine CODE Example - END=================
Good luck,
The Dude -
Track table that contains a block id
Friends
Is it possible to find wich table(s) contains data from a specific block?
I got stuck on a scenario that I'm not using RMAN and I got a block corruption and I need to fix it...
I have the block#, but I could not find a querie to track which table contains that data
CheersSQL> select file#, block#, CORRUPTION_CHANGE#, CORRUPTION_TYPE from V$DATABASE_B
LOCK_CORRUPTION;
FILE# BLOCK# CORRUPTION_CHANGE# CORRUPTIO
3 144438 0 CORRUPT
3 144277 0 CORRUPT
3 144446 0 CORRUPT
12 134018 0 CORRUPT
3 144501 0 CORRUPT
12 134714 0 CORRUPT
3 144493 0 CORRUPT
3 144293 0 CORRUPT
3 144309 0 CORRUPT
3 144325 0 CORRUPT
SQL> select segment_name, segment_type, owner
2 from dba_extents
3 where file_id = 12
4 and 134018 between block_id and block_id + blocks -1;
SEGMENT_NAME
SEGMENT_TYPE OWNER
PRODUCT
TABLE BLI
I'm not running rman :( -
Okc/okx table that contains Transaction Type from the pricing/billing tab
We are running 11.5.9 EBS, and the module is Service Contracts Authoring.
I have a sql script that pulls data from the header and subline level for service contracts. If possible I would like to get the Transaction Type form the Pricing/Billing Tab. Summary > Pricing/Billing - submenu "Billing". I have not been able to find a table in OKC or OKX that contains this Transaction Type ID which can be tied back the cust_trx_type_id in the AR.RA_CUST_TRX_TYPES_ALL and in turn get the NAME for the transaction.I'm not sure where the cust_trx_type_id would be stored in OKC/OKS tables, but the table OKS_BILL_TRANSACTIONS stores the trx_number that you can link to ra_customer_trx_all and get the cust_trx_type_id.
HTH
Alka -
Find table which contains "job name" and "Mail sent to users"
Hi Folks,
I have a requirement whenever I run a job(xyz), it send mail to users, Can you please let me know the table which contains both job name and successfully mail sent to users.
Thanks in Advance.
Lakshmi.Hi,
You can find the job name in TBTCJOB.
Regards,
Ravi
Note : Please mark the helpful answers -
JOIN 2 tables that have same column ?
I need to learn how to join two tables that both have the same column name:
tbl1 - idskey
tbl2 - idskey
the idskey column holds a id_number
When I do the JOIN I would like to make sure that only Distinct records are joined from both tables and that any duplicates are removed in the final join. So if:
Tbl1 has a idskey of: 12345
and
Tbl2 has a idskey of: 12345
In the final JOIN I want to remove one of those duplicates.
I actually need to join 3 tables that have the same linking column names for the join, but if I learn how to do this correctly on 2, that will be a start.
10g for db, thanks!Hi,
SELECT DISTINCT and GROUP BY are the most common ways to get unique results from non-unique keys. Exactly how you use them depends on exactly what you want to do.
SELECT DISTINCT guarantees that no two rows in the result set, conisdering all columns, will be identical.
GROUP BY produces one row from a set of rows that have a common feature. The values on that row may be a composite of values from various rows in that set (e.g., an average).
Please post a small, specific example. For instance:
"I have two rows in tbl1 ...
and these fhtee rows in tbl2 ...
Notice how there is one row with idskey=12345 in tbl1 but two such rows in tbl2.
How can I get theses results ...
where only one row has idskey=12345?"
Maybe you are looking for
-
How do I transfer music from my ipod touch to a new computer?
Okay, so I threw out my old computer because it had a virus and it cannot be repaired. All my music was stored in it but I have it all in my ipod touch. I just got a new computer and I downloaded the itunes library but I don't know how to transfer my
-
Hi - I recently migrated to Mac from a PC (about a week ago) and I noticed today that the HDD is nearly full already. There is no where near this amount of data on the HDD and I am confused as to what the Time machine is doing for me. I have two sepe
-
Does Flex can use Wamp as server?
I'm new to Flex mobile development and I can't find a way to connect my project with wamp server and confused that flex can retrieve datas from multiple tables from web server. Can anyone help me please
-
I've got some old film clips on video and they look bad full-screen. How can I get iDVD to play them back half screen or less? thanks DB
-
BW3.x - BEx - Views vs Queries
Where can I find the link between a view and the related query? Thanks. LQ