Re: how to find out the Primary key in SQL plus?

Re: how to find out the Primary key in SQL plus?

 

  

I use view:

CREATE OR REPLACE VIEW v_acons AS
SELECT
decode(t.status,'ENABLED','Ena','Dis') status,

decode(t.constraint_type,'P','PK','R','FK','C','CK','U','UK',t.constraint_type)
constraint_type,
t.constraint_name,
t.owner,
t.table_name,
substr(c.column_name,1,30) column_name,
c.position,
t.r_owner,
t.r_constraint_name
FROM
dba_constraints t,
dba_cons_columns c
WHERE
c.constraint_name(+)=t.constraint_name AND
c.owner(+)=t.owner;

fort primary key select " constraint_type='PK' "

KAzi

Hornbeck David wrote:
> Desc does not identify the primary key. That is a constraint and needs
> to be checked from the system table. Ask your dba to provide access to
> the system table or an ERD diagram that indicates the pk.
>
> -----Original Message-----
> From: Pitchai Siva (GE Infra Energy Non-GE)
> [mailto:oracledba-ezmlmshield-x5378658.[Email address protected]
> Sent: Tuesday, March 04, 2008 8:52 AM
> To: LazyDBA Discussion
> Subject: how to find out the Primary key in SQL plus?
>
> Hi DBA's,
>
>
>
> In SQL Plus, how to find out the primary key columns if I put the DESC
> <table_name>
>
>
>
> Every one knows that the primary key constraint columns shows as the
> "NOT NULL"
>
>
>
> But, suppose if the table has primary key as well NOT NULL constraint
> also in multiple columns how can we find out the primary key constraint
> columns?
>
> If you are not using any GUI tools (like TOAD, PL/SQL developer)
>
>
>
> If I try to fetch the details from all_constraints table using the below
> query, I don't have privileges to access the system table
>
>
>
> Select * from all_constraints
>
> where table_name =Table_name'
>
> and owner = 'schema_name'
>
> and constraint_type = 'P';
>
>
>
> How can we find out the Primary key constraint using DESC <table_name>
> command in SQL_PLUS?
>
>
>
> Regards,
>
> Siva.P
>
> Bangalore
>
>
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
> ______________
>
> The information contained in this message is proprietary and/or
confidential. If you are not the
> intended recipient, please: (i) delete the message and all copies;
(ii) do not disclose,
> distribute or use the message in any manner; and (iii) notify the
sender immediately. In addition,
> please be aware that any message addressed to our domain is subject to
archiving and review by
> persons other than the intended recipient. Thank you.
> _____________
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>




Oracle LazyDBA home page