[Discuss] [OT RTFM]Quick Oracle SQL quesiton
Jerry Feldman
gaf at blu.org
Sat Oct 5 07:22:53 EDT 2013
I just want to reiterate thanks. With the current generation of my
product we have to detect both the old-style schemas and the new style.
that added an extra role and username. By doing this in SQL I have saved
quite a bit of bash scripting.
On 09/25/2013 04:58 PM, Jerry Feldman wrote:
> Thanks the or syntax will work fine. It is just several years since I
> wrote the templates. I actually sat on the ANSI database committee when
> they first approved the SQL standard :-)
>
> On 09/25/2013 02:38 PM, Tim Callaghan wrote:
>> I assume you now want to get back two rows with one statement, one for
>> each, right? If so,
>>
>> select 'schema1' uname, count(*) from dba_users where username like
>> '%schema1%'
>> union
>> select 'schema2' uname, count(*) from dba_users where username like
>> '%schema2%';
>>
>>
>> If you just want back a count including both, then,
>>
>> select count(*) from dba_users where username like '%schema1%' or
>> username like '%schema2%';
>>
>>
>>
>>
>>
>> On Wed, Sep 25, 2013 at 1:28 PM, Jerry Feldman <gaf at blu.org
>> <mailto:gaf at blu.org>> wrote:
>>
>> I'm modifying some existing SQL templates for use in a internal script
>> where we are adding a second schema (or user in Oracle) so the new
>> schemas are schema1 and schema2. I'm just not sure how to change this
>> query to it can refer to both schemas.
>>
>> The original line is below is from when we had a single schema.
>> select count(*) from dba_users where username like '%schema%';
>>
>>
>> I could simply do it twice because all I do is check the result.
>> select count(*) from dba_users where username like '%schema1%';
>> select count(*) from dba_users where username like '%schema2%';
>>
>>
>>
>>
>>
>>
>>
>> --
>> Jerry Feldman <gaf at blu.org <mailto:gaf at blu.org>>
>> Boston Linux and Unix
>> PGP key id:3BC1EB90
>> PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66 C0AF 7CEA 30FC 3BC1
>> EB90
>>
>>
>>
>> _______________________________________________
>> Discuss mailing list
>> Discuss at blu.org <mailto:Discuss at blu.org>
>> http://lists.blu.org/mailman/listinfo/discuss
>>
>>
>
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://lists.blu.org/mailman/listinfo/discuss
--
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix
PGP key id:3BC1EB90
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66 C0AF 7CEA 30FC 3BC1 EB90
More information about the Discuss
mailing list