Unix Technical Forum

challenge: v7 DBA script --> 8i, 9i, 10g

This is a discussion on challenge: v7 DBA script --> 8i, 9i, 10g within the Oracle Database forums, part of the Database Server Software category; --> ok, smarties... here's a v7 style DBA script that flattens the columns list of USER_CONS_COLUMNS into comma separated list ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2008, 07:36 AM
Mark C. Stock
 
Posts: n/a
Default challenge: v7 DBA script --> 8i, 9i, 10g

ok, smarties...

here's a v7 style DBA script that flattens the columns list of
USER_CONS_COLUMNS into comma separated list (part of a set of scripts to
check if FK constraints are indexed)

sample output:

TABLE_NAME C CONSTRAINT_NAME COLUMNS
------------ - --------------- --------------------
INV P SYS_C0016017 ID
INV_ITM P INV_ITM_PK INV_ITM, ITM_SEQ
INV_ITM R SYS_C0016020 INV_ITM

how would you improve it for
[_] 8i?
[_] 9i?
[_] 10g?
[_] 11x?

-- mcs

SELECT table_name
,constraint_type
,constraint_name
, col1
|| DECODE(col2, NULL, NULL, ', ')
|| col2
|| DECODE(col3, NULL, NULL, ', ')
|| col3
|| DECODE(col4, NULL, NULL, ', ')
|| col4
|| DECODE(col5, NULL, NULL, ', ')
|| col5 AS columns
FROM (SELECT table_name
,constraint_type
,constraint_name
,MIN(DECODE(position, 1, column_name)) col1
,MIN(DECODE(position, 2, column_name)) col2
,MIN(DECODE(position, 3, column_name)) col3
,MIN(DECODE(position, 4, column_name)) col4
,MIN(DECODE(position, 5, column_name)) col5
FROM (SELECT ucc.table_name
,uc.constraint_type
,ucc.constraint_name
,ucc.position
,ucc.column_name
FROM user_cons_columns ucc
,user_constraints uc
WHERE uc.constraint_type IN ('P', 'R')
AND uc.constraint_name = ucc.constraint_name
AND uc.table_name = ucc.table_name
AND uc.owner = ucc.owner)
GROUP BY table_name
,constraint_type
,constraint_name)
ORDER BY table_name
,constraint_type
,constraint_name


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-23-2008, 07:37 AM
Daniel Morgan
 
Posts: n/a
Default Re: challenge: v7 DBA script --> 8i, 9i, 10g

Mark C. Stock wrote:

> ok, smarties...
>
> here's a v7 style DBA script that flattens the columns list of
> USER_CONS_COLUMNS into comma separated list (part of a set of scripts to
> check if FK constraints are indexed)
>
> sample output:
>
> TABLE_NAME C CONSTRAINT_NAME COLUMNS
> ------------ - --------------- --------------------
> INV P SYS_C0016017 ID
> INV_ITM P INV_ITM_PK INV_ITM, ITM_SEQ
> INV_ITM R SYS_C0016020 INV_ITM
>
> how would you improve it for
> [_] 8i?
> [_] 9i?
> [_] 10g?
> [_] 11x?
>
> -- mcs
>
> SELECT table_name
> ,constraint_type
> ,constraint_name
> , col1
> || DECODE(col2, NULL, NULL, ', ')
> || col2
> || DECODE(col3, NULL, NULL, ', ')
> || col3
> || DECODE(col4, NULL, NULL, ', ')
> || col4
> || DECODE(col5, NULL, NULL, ', ')
> || col5 AS columns
> FROM (SELECT table_name
> ,constraint_type
> ,constraint_name
> ,MIN(DECODE(position, 1, column_name)) col1
> ,MIN(DECODE(position, 2, column_name)) col2
> ,MIN(DECODE(position, 3, column_name)) col3
> ,MIN(DECODE(position, 4, column_name)) col4
> ,MIN(DECODE(position, 5, column_name)) col5
> FROM (SELECT ucc.table_name
> ,uc.constraint_type
> ,ucc.constraint_name
> ,ucc.position
> ,ucc.column_name
> FROM user_cons_columns ucc
> ,user_constraints uc
> WHERE uc.constraint_type IN ('P', 'R')
> AND uc.constraint_name = ucc.constraint_name
> AND uc.table_name = ucc.table_name
> AND uc.owner = ucc.owner)
> GROUP BY table_name
> ,constraint_type
> ,constraint_name)
> ORDER BY table_name
> ,constraint_type
> ,constraint_name


I'm going to present this to my students tonight at class.

But in version 11x the syntax is:

SELECT whatiwant
FROM whereeveritis

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-23-2008, 07:37 AM
Mark C. Stock
 
Posts: n/a
Default Re: challenge: v7 DBA script --> 8i, 9i, 10g

you forgot the hint:

| I'm going to present this to my students tonight at class.
|
| But in version 11x the syntax is:
|
| SELECT --+ faster_than_a_greased_pig
whatiwant
| FROM whereeveritis
|
| --
| Daniel Morgan
| http://www.outreach.washington.edu/e...ad/oad_crs.asp
| http://www.outreach.washington.edu/e...oa/aoa_crs.asp
| damorgan@x.washington.edu
| (replace 'x' with a 'u' to reply)
|


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-23-2008, 07:37 AM
Niall Litchfield
 
Posts: n/a
Default Re: challenge: v7 DBA script --> 8i, 9i, 10g

I thought in v11x the query was

<resultset>
return what i want here without any sql just xml ta
</resultset>

--
Niall Litchfield
Oracle DBA
Audit Commission UK
*****************************************
Please include version and platform
and SQL where applicable
It makes life easier and increases the
likelihood of a good answer
******************************************
"Mark C. Stock" <mcstockX@Xenquery .com> wrote in message
news:aa2dnVmvtr6GJb_dRVn-vw@comcast.com...
> you forgot the hint:
>
> | I'm going to present this to my students tonight at class.
> |
> | But in version 11x the syntax is:
> |
> | SELECT --+ faster_than_a_greased_pig
> whatiwant
> | FROM whereeveritis
> |
> | --
> | Daniel Morgan
> | http://www.outreach.washington.edu/e...ad/oad_crs.asp
> | http://www.outreach.washington.edu/e...oa/aoa_crs.asp
> | damorgan@x.washington.edu
> | (replace 'x' with a 'u' to reply)
> |
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-23-2008, 07:37 AM
Hans Forbrich
 
Posts: n/a
Default Re: challenge: v7 DBA script --> 8i, 9i, 10g



Niall Litchfield wrote:
>
> I thought in v11x the query was
>
> <resultset>
> return what i want here without any sql just xml ta
> </resultset>
>


Apparently the proposed syntax, with RPM mode (Read Programmer's Mind -
TM} will be something like

<resultset>
AnswerHere
</resultset>

or, using the high performance modifier, it's

<resultset>
AnswerHereNOW
</resultset>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-23-2008, 07:37 AM
Daniel Morgan
 
Posts: n/a
Default Re: challenge: v7 DBA script --> 8i, 9i, 10g

Mark C. Stock wrote:

> you forgot the hint:
>
> | I'm going to present this to my students tonight at class.
> |
> | But in version 11x the syntax is:
> |
> | SELECT --+ faster_than_a_greased_pig
> whatiwant
> | FROM whereeveritis
> |


ROFL

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com