Please give the query to find out primary key in table in Sql plus
Dear friends,
Please give me the query to find out the primary key in Sql plus.
hi
SQL> DESC user_constraints
Name
OWNER
CONSTRAINT_NAME
CONSTRAINT_TYPE
TABLE_NAME
SEARCH_CONDITION
R_OWNER
R_CONSTRAINT_NAME
DELETE_RULE
STATUS
DEFERRABLE
DEFERRED
VALIDATED
GENERATED
BAD
RELY
LAST_CHANGE
INDEX_OWNER
INDEX_NAME
INVALID
VIEW_RELATED
SQL> SELECT constraint_name,table_name,r_constraint_name,status
2 FROM user_constraints WHERE constraint_type='P';
CONSTRAINT_NAME TABLE_NAME R_CONSTRAINT_NAME STATUS
SYS_C003141 CUSTOMERS ENABLED
PK_DEPT DEPT ENABLED
SYS_C003139 SALESREPS ENABLEDKhurram
Similar Messages
-
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. -
Query to find out the time used by an user for an application
Hello All,
I want to know the query to find out the whole time used by the user for an application. Please view the below data
Employee:
SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
1 10 Visu 21-Nov-2010 06:30:00 07:30:00
2 10 Visu 21-Nov-2010 06:40:00 07:20:00
3 10 Visu 21-Nov-2010 06:50:00 07:50:00
4 10 Visu 21-Nov-2010 07:30:00 08:30:00
5 10 Visu 21-Nov-2010 09:30:00 10:30:00
By checking the above data we can say that the total time Visu used the application is
8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
10.30 - 9.30 (Based on 5th rec) = 1hr
So the total time Visu used the application would be 3 hrs = 180 mins.
Could you please help me in getting the result from that data using a query?odie_63 wrote:
I think it may be solved with analytics too.
with t1 as (
select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
t2 as (
select emp_id,
emp_name,
emp_date,
to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
from t1
t3 as (
select t2.*,
case
when login_time < max(logout_time) over(
partition by emp_id,emp_date
order by login_time
rows between unbounded preceding
and 1 preceding
then 0
else 1
end start_of_group
from t2
t4 as (
select t3.*,
sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
from t3
t5 as (
select emp_id,
emp_date,
min(login_time) login_time,
max(logout_time) logout_time
from t4
group by emp_id,
emp_date,
grp
select emp_id,
numtodsinterval(sum(logout_time - login_time),'day') time_spent
from t5
group by emp_id
order by emp_id
EMP_ID TIME_SPENT
10 +000000000 03:00:00.000000000
SQL> SY. -
Query to find out which process consuming more cpu?
Hi All,
some one please tell me the query to find out which process is consuming more
cpu resources?
Thanks and Regards
SrikanthUse V$SESSTAT to determine which sessions are using most CPU, and investigate what SQL these users/sessions are executing:
SQL> select ss.sid, se.command, ss.value CPU, se.username, se.program
from v$sesstat ss, v$session se
where ss.statistic# in
(select statistic#
from v$statname
where name = 'CPU used by this session')
and se.sid=ss.sid
order by ss.value desc; -
Query to find out license products installed
hai dba
tell me the query to find out what r hte products installed r licensed??
regards
dba1) From OAM: Oracle Applications Manager > Site Map > License Manager > Reports > License Products/Shared Products
2) Use $AD_TOP/sql/adutconf.sql
3) Use the following query:
SQL> select fa.APPLICATION_SHORT_NAME, fpi.PATCH_LEVEL, DECODE(fpi.STATUS, 'I','Installed',
'S','Shared', 'N', 'Inactive', fpi.STATUS) Status , fpi.DB_STATUS
from fnd_product_installations fpi,FND_APPLICATION fa
where fpi.APPLICATION_ID in (
select APPLICATION_ID from FND_APPLICATION)
and fa.APPLICATION_ID=fpi.APPLICATION_ID; -
Query to find out pertcular schema related datafiles free space????
hai,
whats the query to find out free space in datafiles and index files related free space for perticular schmea?
Regards
dbaIf you wish to get free space in index tablespace then use following query:
select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
from
(select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_space
from dba_free_space group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as tbs_size
from dba_data_files group by tablespace_name
UNION
select tablespace_name, sum(bytes)/1024/1024 tbs_size
from dba_temp_files
group by tablespace_name ) b
where a.tablespace_name(+)=b.tablespace_name
and a.tablespace_name='INDX';
and if you get info for all tablespace then :
select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
from
(select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_space
from dba_free_space group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as tbs_size
from dba_data_files group by tablespace_name
UNION
select tablespace_name, sum(bytes)/1024/1024 tbs_size
from dba_temp_files
group by tablespace_name ) b
where a.tablespace_name(+)=b.tablespace_name; -
Can you suggest me that what should i do in this case.
Actually i am having one table that is a MasterTable.I am referring this table in more than 300 tables that means i am having foreign key of this primary key in 300+ tables.
due to this i am getting following error during deleting any row,
doesn't matter that data is existing in reference table or not.
Error that i am getting is
"The query processor ran out of stack space during query optimization. Please simplify the query"
Can you suggest me that what should i do to avoid this error,because i am unable to delete this entry.
Apart from it,i am getting performance problem too,so is it due to such huge FK on it.
Please suggest me on following points
1. Is it worst way to handle it,if yes then please suggest me solution for it.
2. If it is a correct way then what should i do if getting error during deleting any record.
3. Is it right to create Foreign key on each table where i am saving data of this master. if no then how to manage integrity.
4. What people do in huge database when they wants to create foreign key for any primary key.
5. Can you suggest me that how DBA's are handling this in big database,where they are having huge no. of tables.The most common reason of getting such error is having more than 253 foreign key constraints on a table.
The max limit is documented here:
http://msdn.microsoft.com/en-us/library/ms143432(SQL.90).aspx
Although a table can contain an unlimited number of FOREIGN KEY constraints, the recommended maximum is 253. Depending on the hardware configuration hosting SQL Server, specifying additional foreign key constraints may be expensive for the query
optimizer to process. If you are on 32 bit, then you might want to move to 64 bit to get little bigger stack space but eventually having 300 FK is not something which would work in long run.
Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
This posting is provided "AS IS" with no warranties, and confers no rights.
My Blog |
Team Blog | @Twitter
Author: SQL Server 2012 AlwaysOn -
Paperback, Kindle -
Query to find out the list of user who have delete access
Hi,
I need a query to find out the list of users who have delete access on perticular folder/universe/ reports in infoview.
Please advice.
Regards,
Neo.orton607 wrote:
thanks for replying guys. But the thing is i am using dynamic sql execute immediate in my package, so i want those tables also and the schema name.
thanks,
ortonThis is not possible. The best you could do is to have a good guess.
Or how would you parse some dynamic statement as this:
v_suffix := 'loyees';
v_sql := 'Select count(*) from (select ''nonsense'' col1 from emp'||v_suffix||') where col1 = ''Y'''';
execute_immediate(v_sql);
...What is the table name? How do you want to parse that?
Better rewrite all dynamic SQL statements into non dynamic ones. Or do the source control logic for those dynamic parts in an extra module. For example implement your own dependency table and force every developer to add there all dynamic parts. -
Need query to find out the sum till a period
Hi,
I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
Thanksnot familiar with report but could you do something like this
with t as
select 1 grp, 10 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11 union all
select 2 grp, 5 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11
input as
( select null grp, null the_cost, null running_total, v_eff_dt effective_dt from dual)
select * from(
select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
input.effective_dt inp_eff_dt
from t, input
where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in -
Query to find out the Activities done against a table
Hi,
One table has been truncated and data reloaded into the table by the user. But at latter stage user deny that activity. I believe all these activities stored in any oracle 10g database table.
Need a query to find out the activities done on a specific date say 6th Sep.
This is too urgent. Thanks in advanceHi,
Welcome to the forum!
If you don't have enable table auditing maybe you can see last_ddl_time column of user_objects view:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> select * from test2;
COL1 COL2 COL3
1 1 3
1 2 3
1 3 3
SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
12/09/2009 12:20:26 12/09/2009 12:20:27
SQL> truncate table test2;
Table truncated
SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
12/09/2009 12:20:26 12/09/2009 14:01:21
SQL> Regards, -
Query to find out last quarter data
Hi All,
I need a SQL query to find out. I have an amount field like below
Period | Amt | Amt2
====================
Jul | 0 | 0+20+30
Aug | 20 | 0
Sep | 30 | 0
Oct | 0 | 0+50
Nov | 50 |
My need is Amt2 which needs to calculating in Qtr wise. Can any one post me a query for this.
Thanks,
KamalHi Valli,
Thanks, so we need to create a function and then call that from report. I have doubt in this, for example if the user enter 'SEP-12' then it will find which QTR from the case statement. But if the user have account number which is available in all the months from 2010 - 2012.
So now user will give two inputs like period_name='SEP-12' and Account Number=101010 then it should give output like sum(Q3) in the year of 2012. Here how it will calculate year wise? or do we need to specify any condition here?
Please advice,
Thanks,
Kamal -
Query to find out controls displayed as in UI for an applet,along with view
Hi,
I am looking for a query to find out list of all the controls as displayed in UI applet along with applet's view.
Please note that in the query only mapped controls (those displayed in UI ) should come up.
Regards,
KunalHi,
If the EUL is an apps mode (EBS) EUL then the eu_username column is the apps user id or apps resp id. If you want to show only the responsibilities and convert those ids to names then you need to use the EUL5_GET_APPS_USERRESP function like this:
select ba_name, ba_developer_key, EUL5_GET_APPS_USERRESP(eu.eu_username, 'R') responsibility_name
from eul5_bas ba
, eul5_access_privs ap
, eul5_eul_users eu
where ba.ba_id = ap.gba_ba_id
and ap.ap_type = 'GBA'
and ap.ap_eu_id = eu.eu_id
and eu.eu_role_flag=1
order by 1,2,3Rod West -
How to use ONE query to find out tree structure?
ID------------upperID----------Name------------------------isFolder
1------------ 0---------- Folder
1------------------------------------1
2------------ 1------------ Folder 1- Sub
Folder--------------------1
3------------ 2------------
Folder1-Item1-A--------------------------0
4------------ 1------------ Folder 1- Sub
Item-----------------------0
Hi all, if I have a table like above to demonstrate the
folders and item relationship. This structure allows the user to
create unlimited folders and items.
Now I would like to use one query to find out the tree
structure of this table, how could I do the query.
Any help on this will be highly appreciated!
Thanks,
ezAlso, see this thread:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 55788&enterthread=y -
We are getting multiple 8623 Errors in SQL Log while running Vendor's software.
How can you catch which Query causes the error?
I tried to catch it using SQL Profiler Trace but it doesn't show which Query/Sp is the one causing an error.
I also tried to use Extended Event session to catch it, but it doesn't create any output either.
Error:
The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that
reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
Extended Event Session that I used;
CREATE EVENT SESSION
overly_complex_queries
ON SERVER
ADD EVENT sqlserver.error_reported
ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
WHERE ([severity] = 16
AND [error_number] = 8623)
ADD TARGET package0.asynchronous_file_target
(SET filename = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xel' ,
metadatafile = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xem',
max_file_size = 10,
max_rollover_files = 5)
WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
GO
-- Start the session
ALTER EVENT SESSION overly_complex_queries
ON SERVER STATE = START
GO
It creates only .xel file, but not .xem
Any help/advice is greatly appreciatedHi VK_DBA,
According to your error message, about which query statement may fail with error message 8623, as other post, you can use trace flag 4102 & 4118 for overcoming this error. Another way is looking for queries with very long IN lists, a large number of
UNIONs, or a large number of nested sub-queries. These are the most common causes of this particular error message.
The error 8623 occurs when attempting to select records through a query with a large number of entries in the "IN" clause (> 10,000). For avoiding this error, I suggest that you could apply the latest Cumulative Updates media for SQL Server 2012 Service
Pack 1, then simplify the query. You may try divide and conquer approach to get part of the query working (as temp table) and then add extra joins / conditions. Or You could try to run the query using the hint option (force order), option (hash join), option
(merge join) with a plan guide.
For more information about error 8623, you can review the following article.
http://blogs.technet.com/b/mdegre/archive/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan.aspx
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
SQL query to find out last login for each database
Hi everybody,
I have a view with following columns:
DatabaseSid, lastLogin, firstLogin.
I want to now the newest last_login date for every database.
SID First Login Last Login
e.g. Database1, 11.11.2011, 01.12.2011
Database1, 01.04.2012, 01.05.2012
Database3, 03.03.2004, 03.06.2005
Database 3 07.09.2012, 12.10.2012
How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
Thank you in advance
SteveSteve wrote:
Hi everybody,
I have a view with following columns:
DatabaseSid, lastLogin, firstLogin.
I want to now the newest last_login date for every database.
SID First Login Last Login
e.g. Database1, 11.11.2011, 01.12.2011
Database1, 01.04.2012, 01.05.2012
Database3, 03.03.2004, 03.06.2005
Database 3 07.09.2012, 12.10.2012
How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
Thank you in advance
SteveI'm curious as to how you collect this information from multiple databases into one database, and of what value the data is once you have it.
Maybe you are looking for
-
Error in opening datafile after use of DATAFILE RESIZE command
Hi Friends, I am facing a strange problem here. We got a space problem yesterday ORA-01659: unable to allocate MINEXTENTS beyond 42 in tablespace and I increased the underlying datafiles using resize command. The datafiles were 1G earlier and I have
-
View Characteristics Value in COOIS
Hi, Is there a way where I can view the characteristics value for the Production Orders using COOIS? Thanks. Cheers, Sue
-
Combine icc profile + correction curve
For a monthly magazine on uncoated paper, our workflow is as follows: - convert every photo to uncoated cmyk (PSO Uncoated) + apply some corrections to look nice in this profile - apply a fixed correction curve to the photo's - (resize images + apply
-
Is there a good reference in how to interpret the "show AP stats" command? I have a new (online for 15 days) 1142 listed below. It is the first 802.11n AP I've deployed. The stat counters look bad (TxFragment Count = TxFrameCount, RetryCount > TxF
-
How to extract specific text from a string using REGEXP
Some- &3*1233 Test Oralce #1`2" pip, various lengths couplers Misc. Metal,,'VENDOR'), PART_NO=5966 DESCRIPTION=INV 564400 2" How can I extract text start from 'Test' and end before DESCRIPTION? the results I need is as follows: Test Oralce #1`2" pip,