![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In Oracle SQL (or any other dialect), if there an easy way to select all cols in a table except for 2 explicitly specified cols, without having to type the majority of the column names? Example 1: Select all columns select a.* from * all_tables a; Example 2: Pseudo SQL to select all columns but two in a table having many columns (e.g. 47 columns out of 49 columns for this example table in 10g): select all columns except for MIN_EXTENTS and MAX_EXTENTS from * all_tables a; Is this a job for "SQL writing SQL", using PL/SQL and a limiting subquery like: select column_name from all_tab_cols where owner = 'SYS' and * table_name = 'ALL_TABLES' and * column_name not in ('MIN_EXTENTS', 'MAX_EXTENTS'); ... or is this a much simpler solution (one that doesn't involve manually copy-pasting 47 columns)? Thanks. Dana |
#3
| |||
| |||
|
|
Well, are you asking for a dynamic thing or an easy way to limit what other users see? If the latter, use views. |
|
If the former, either play around with ..._tab_cols for the report-generator kind of thing or keep a bunch of files around with all the columns in them and grab what you need in your editor for the real ad-hoc stuff. |
#4
| |||
| |||
|
|
Thanks Joel. Well, are you asking for a dynamic thing or an easy way to limit what other users see? *If the latter, use views. Not wanting to limit what others see. I need to limit columns for my own queries. If the former, either *play around with ..._tab_cols for the report-generator kind of thing or keep a bunch of files around with all the columns in them and grab what you need in your editor for the real ad-hoc stuff. Thanks for the suggestions. It's ad hoc plus from the way you're characterized ad hoc. I don't often know in advance what X number of columns I'll need to exclude; only know that I keep coming up against cases where I need most, but not all, of the columns in tables with a large number of columns. I think I'll write some reusable PL/SQL that: 1) Prompts for the number of columns to exclude 2) Prompts for the column names to be excluded, looping the number of times specified in step 1. If that's doable in PL/SQL. Or if someone already has this, please share. Or is an expert PL/SQL coder with some time to kill, please help. :-) Thanks. Dana |
#5
| |||
| |||
|
|
Thanks Joel. Well, are you asking for a dynamic thing or an easy way to limit what other users see? *If the latter, use views. Not wanting to limit what others see. I need to limit columns for my own queries. If the former, either *play around with ..._tab_cols for the report-generator kind of thing or keep a bunch of files around with all the columns in them and grab what you need in your editor for the real ad-hoc stuff. Thanks for the suggestions. It's ad hoc plus from the way you're characterized ad hoc. I don't often know in advance what X number of columns I'll need to exclude; only know that I keep coming up against cases where I need most, but not all, of the columns in tables with a large number of columns. I think I'll write some reusable PL/SQL that: 1) Prompts for the number of columns to exclude 2) Prompts for the column names to be excluded, looping the number of times specified in step 1. If that's doable in PL/SQL. |
|
Or if someone already has this, please share. Or is an expert PL/SQL coder with some time to kill, please help. :-) Thanks. Dana |
![]() |
| Thread Tools | |
| Display Modes | |
| |