Author Archives: Rich Soule

Finding Unindexed Foreign Keys in Oracle, now with index creation DDL!

2025-08-13 Update: It’s now even better, use this post instead: https://carsandcode.com/2025/08/13/finding-unindexed-foreign-keys-in-oracle-now-with-even-better-index-creation-ddl/

Previously I wrote a better query for finding unindexed foreign key indexes. Today Lance (one of the great folks at Insum) and I went through the query in a code review and we came up with a few improvements.

The first thing that bothered me was the ‘possible missing index’ result. I did some testing, and I couldn’t come up with a situation where I’d get a missing index result, but the index really was there, so I made the results just say “Missing” if I couldn’t find the index.

Lance and I also cleaned up a few column names to make things easier to understand. For example, I previously had a column named foreign_key_index that had either “Exists” or “Missing” which really wasn’t a foreign_key_index, but instead a flag showing the status of the foreign key index. This was renamed to “index_existence”. Other columns got better names too.

Lance made a suggestion to take the final query and make it a CTE (Common Table Expression, sometimes called a “with clause”), and then create a new simple final query that just selected each column name from the CTE making it very easy for folks to comment out columns if they are not interested in them, or to re-order the columns if they wanted.

We also added another column to the report with the DDL that would create an index that would eliminate the missing foreign key index.

Some notes on that DDL statement:

  • I’m a very big fan of naming things what they are so my index name ends up being quite long. You’ll almost certainly need to have long object names enabled in your database if you want to use the index name as is. If you need a shorter name, you can just modify the query.
  • If the query returns multiple foreign key indexes to create on a single table, take a look and see if one of the multicolumn indexes would also eliminate the need for some of the indexes that have fewer columns. Remember though, that the columns need to be in the right order. So if your table has a foreign key constraint on columns c1, c2, c3, and c4 that points to one table and then another foreign key constraint just on only c4 that points to another table, an index on c1, c2, c3, and c4 in that order will be able to be used for foreign key constraint number one, but not for foreign key constraint number two.
  • I always use lowercase to write all my statements as science says that this is easier for humans to read. All lowercase letters are also much easier to write. When my statements are run, the data dictionary is always populated in uppercase because I never double-quote any of the schema, table, or column names. Some people (and this is never recommended) actually double-quote table and column names and put names in lowercase or mixed-case in the data dictionary which means that every statement that accesses those objects must reference those objects as double-quoted identifiers. Amazingly you can also create schemas in lowercase too! I would never, never do this as you’re just making all your code harder to read and write. I debated on allowing for this craziness, but in the end decided that, yeah, it’s probably better to just help the misguided folks who do this so the owner, table name, and column name(s) in the DDL statement are all double-quoted identifiers as they are stored in the data dictionary. The DDL isn’t as pretty, but it works for more people.

The query could also be just a bit more efficient by eliminating the first column, index_existence. The DDL column now is effectively the same information. I left it because I think it adds some value and would make filtering a bit easier to read.

I’ve formatted the query below to be easy to read when displayed with at least 144 columns of width (see the image above). Below the code doesn’t look as pretty because there are not 144 columns of width in the text block.

To that end, here’s the “better” query:

with owner_exclusion_list as (          select username from dba_users where oracle_maintained ='Y'
                                   union all select 'ORDS_METADATA' from dual
                                   union all select 'ORDS_PUBLIC_USER' from dual )
        , constraint_columns as ( select owner
                                       , table_name
                                       , constraint_name
                                       , listagg(column_name, ', ') within group(order by position) as constraint_column_list
                                    from dba_cons_columns 
                                    join dba_constraints using (owner, table_name, constraint_name)
                                   where constraint_type = 'R' -- R = Referential Foreign Key Constraint
                                     and owner not in (select * from owner_exclusion_list)
                                group by owner, table_name, constraint_name )
        , index_columns as ( select index_owner as owner
                                  , table_name
                                  , index_name
                                  , listagg(column_name, ', ') within group(order by column_position) as index_column_list
                               from dba_ind_columns 
                              where index_owner not in (select * from owner_exclusion_list)
                           group by index_owner, table_name, index_name )
        , foreign_key_index_query as ( select decode(ic.table_name, null, 'Missing'
                                                                        , 'Exists')                                   as index_existence
                                            , to_char(dbat.num_rows, '999,999,999,999,999')                           as last_analyzed_row_count
                                            , dbat.last_analyzed
                                            , cc.owner                                                                as table_owner
                                            , cc.table_name
                                            , constraint_name                                                         as foreign_key_name
                                            , constraint_column_list                                                  as foreign_key_column_list
                                            , coalesce(index_name, '*** Missing Index ***')                           as index_name
                                            , coalesce(index_column_list,'*** Missing Index ***')                     as index_column_list
                                            , decode(ic.table_name, null, 'create index '||lower(cc.table_name||'_foreign_key_index_'||
                                                                          replace(replace(constraint_column_list,',','_'),' '))||' on "'|| 
                                                                          cc.owner || '"."'||cc.table_name||'"("'||
                                                                          replace(replace(constraint_column_list,',','","'),' ')||'");'
                                                                        , '*** Supporting index already exists ***' ) as create_index_ddl
                                         from constraint_columns cc
                                         join dba_tables dbat on ( dbat.owner = cc.owner and dbat.table_name = cc.table_name)
                                    left join index_columns ic on (    cc.owner = ic.owner and cc.table_name = ic.table_name 
                                                                   and ic.index_column_list like cc.constraint_column_list || '%' ) )
  select index_existence
       , last_analyzed_row_count
       , last_analyzed
       , table_owner
       , table_name
       , foreign_key_name
       , foreign_key_column_list
       , index_name
       , index_column_list
       , create_index_ddl
    from foreign_key_index_query
order by last_analyzed_row_count desc nulls last, table_owner, table_name, foreign_key_column_list;

2024-02 Update: As my friend Anton Nielsen pointed out, not everybody has DBA privs… If you don’t, just do a search and replace of “dba_” with “all_”. Then you can run this as a non-privileged user and you’ll be sure to capture missing indexes in your own schema and any other schema you can see.

2024-03 Update: Jeff Smith gave the Insum team an overview of the SQL Developer extension for VSCode. His blog post shows how to add snippets to VSCode SQL Developer. I thought I’d give it a shot and created the following which works like a charm. Using “ffk”, for “Find Foreign Keys” will give you the above query if you put the following into your oracle_sql.json file.

"ffk": {
"prefix": "ffk",
"body": [
"with owner_exclusion_list as ( select username from dba_users where oracle_maintained ='Y'",
" union all select 'ORDS_METADATA' from dual",
" union all select 'ORDS_PUBLIC_USER' from dual )",
" , constraint_columns as ( select owner",
" , table_name",
" , constraint_name",
" , listagg(column_name, ', ') within group(order by position) as constraint_column_list",
" from dba_cons_columns ",
" join dba_constraints using (owner, table_name, constraint_name)",
" where constraint_type = 'R' -- R = Referential Foreign Key Constraint",
" and owner not in (select * from owner_exclusion_list)",
" group by owner, table_name, constraint_name )",
" , index_columns as ( select index_owner as owner",
" , table_name",
" , index_name",
" , listagg(column_name, ', ') within group(order by column_position) as index_column_list",
" from dba_ind_columns ",
" where index_owner not in (select * from owner_exclusion_list)",
" group by index_owner, table_name, index_name )",
" , foreign_key_index_query as ( select decode(ic.table_name, null, 'Missing'",
" , 'Exists') as index_existence",
" , to_char(dbat.num_rows, '999,999,999,999,999') as last_analyzed_row_count",
" , dbat.last_analyzed",
" , cc.owner as table_owner",
" , cc.table_name",
" , constraint_name as foreign_key_name",
" , constraint_column_list as foreign_key_column_list",
" , coalesce(index_name, '*** Missing Index ***') as index_name",
" , coalesce(index_column_list,'*** Missing Index ***') as index_column_list",
" , decode(ic.table_name, null, 'create index '||lower(cc.table_name||'_foreign_key_index_'||",
" replace(replace(constraint_column_list,',','_'),' '))||' on \"'|| ",
" cc.owner || '\".\"'||cc.table_name||'\"(\"'||",
" replace(replace(constraint_column_list,',','\",\"'),' ')||'\");'",
" , '*** Supporting index already exists ***' ) as create_index_ddl",
" from constraint_columns cc",
" join dba_tables dbat on ( dbat.owner = cc.owner and dbat.table_name = cc.table_name)",
" left join index_columns ic on ( cc.owner = ic.owner and cc.table_name = ic.table_name ",
" and ic.index_column_list like cc.constraint_column_list || '%' ) )",
" select index_existence",
" , last_analyzed_row_count",
" , last_analyzed",
" , table_owner",
" , table_name",
" , foreign_key_name",
" , foreign_key_column_list",
" , index_name",
" , index_column_list",
" , create_index_ddl",
" from foreign_key_index_query",
"order by last_analyzed_row_count desc nulls last, table_owner, table_name, foreign_key_column_list;"
],
"description": "Find unindexed foreign keys"
}

Finding Unindexed Foreign Keys in Oracle

Update: There is a new better version of the query here: https://carsandcode.com/2025/08/13/finding-unindexed-foreign-keys-in-oracle-now-with-even-better-index-creation-ddl/

I’ve always been a bit unhappy with most (all?) of the queries you find when searching for “Oracle unindexed foreign keys query” on Google. Certainly, the ones that don’t use listagg to aggregate the constraint columns and the index columns are insane. I realize those queries might have been around since before listagg was available, but listagg was introduced in 11gR2 which was released in 2009.

To that end, the following 33 line query will find all the possibly unindexed foreign key constraints in your database. Since the matching happens on the column names, if you have a difference in column names between the constraint columns and the index columns, you won’t get a match and it will show up in the results as ‘Could be missing’. 99.99 times out of a hundred the index is missing.

I’ve also added the number of rows and last analyzed date from DBA_TABLES (remember, this number of rows may not be accurate as the value is only updated when the table is analyzed) so that the biggest possible offenders would be the first results. Even if the number of rows is small and the statistics are up to date, you’ll pretty much always want to have that foreign key index to eliminate over-locking the detail rows when a master row is updated. In all my years I’ve yet to run across a business application where the ‘index caused too much overhead’ and needed to be removed. I’m not saying those situations don’t exist, but they are exceedingly rare.

If you want to see how Oracle is doing with its schemas, you could change the owner_exclusion_list CTE (Common Table Expression, sometimes called a WITH clause) to something like “select ‘nobody’ from dual’). Right now that CTE gets the list of schemas that are Oracle maintained and adds in the ORDS_METADA and ORDS_PUBLIC_USER schemas which are, for some reason, not marked as Oracle maintained.

Using an APEX page to display the results of the query also allows me to format the last analyzed date using APEX’s “since” formatting, which gives a really good indication of possible stale statistics.

Update: Again, there is a new, better version of this query here: https://carsandcode.com/2025/08/13/finding-unindexed-foreign-keys-in-oracle-now-with-even-better-index-creation-ddl/

     with owner_exclusion_list as (          select username from dba_users where oracle_maintained ='Y'
                                   union all select 'ORDS_METADATA' from dual
                                   union all select 'ORDS_PUBLIC_USER' from dual )
        , constraint_columns as ( select owner
                                       , table_name
                                       , constraint_name
                                       , listagg(column_name, ', ') within group(order by position) as constraint_column_list
                                    from dba_cons_columns 
                                    join dba_constraints using (owner, table_name, constraint_name)
                                   where constraint_type = 'R' -- R = Referential Foreign Key Constraint
                                     and owner not in (select * from owner_exclusion_list)
                                group by owner, table_name, constraint_name )
        , index_columns as ( select index_owner as owner
                                  , table_name
                                  , index_name
                                  , listagg(column_name, ', ') within group(order by column_position) as index_column_list
                               from dba_ind_columns 
                              where index_owner not in (select * from owner_exclusion_list)
                           group by index_owner, table_name, index_name )
   select decode(ic.table_name, null, 'Could be missing'
                                    , 'Exists'          )              as foreign_key_index
        , to_char(dbat.num_rows, '999,999,999,999,999,999')            as last_analyzed_row_count
        , dbat.last_analyzed
        , cc.owner
        , cc.table_name
        , constraint_name                                              as foreign_key_constraint_name
        , constraint_column_list                                       as foreign_key_column_list
        , coalesce(index_name, '*** Possible Missing Index ***')       as index_name
        , coalesce(index_column_list,'*** Possible Missing Index ***') as index_column_list
     from constraint_columns cc
     join dba_tables dbat on ( dbat.owner = cc.owner and dbat.table_name = cc.table_name)
left join index_columns ic on (    cc.owner = ic.owner and cc.table_name = ic.table_name 
                               and ic.index_column_list like cc.constraint_column_list || '%' )
 order by dbat.num_rows desc nulls last, cc.owner, cc.table_name, constraint_column_list;

Update: And again, there is a new better version of this query here: https://carsandcode.com/2025/08/13/finding-unindexed-foreign-keys-in-oracle-now-with-even-better-index-creation-ddl/

Let me know if this query is helpful, and happy DBAing/Developing!

Note: On my Twitter post about this blog, I took a screenshot and put in the alt text for the image with the username column in the first CTE as ‘username’ instead of just username. This means that the Oracle maintained schemas are NOT excluded anymore. I was testing on a database that only had a single schema and wanted to include the Oracle schemas too. I also left off the owner column for the list in the final query.

2024-02 Update: As my friend Anton Nielsen pointed out, not everybody has DBA privs… If you don’t, just do a search and replace of “dba_” with “all_”. Then you can run this as a non-privileged user and you’ll be sure to capture missing indexes in your own schema and any other schema you can see.


Kscope23 Recap

I’ve been back for a while but thought I’d post some plans for my Kscope content and talk about the conference itself now that it’s in the bag.

I arrived late Friday night and things were pretty quiet. I spent some time in the bar trying various bourbons and whiskeys before calling it an early night.

The next morning I ran into Connor McDonald (check out his amazing content on Youtube). He mentioned that he was planning to go visit the famous Tom Kyte (the original creator of Ask TOM, and author of one of the very best Oracle books, Expert Oracle Database Architecture) but apparently Tom fell off a ladder and broke some ribs. Hopefully, Tom will recover soon. A bit later I joined the team going to the community service day event. They gave us matching shirts to wear and we boarded buses to Mile High Behavioral Healthcare and did a bunch of cleaning, gardening, and painting. I was on the painting crew and painted a gazebo and a few tables with a great team of folks. I ended up buying MHBH some picnic tables after we went to pick up one of their existing picnic tables and it essentially disintegrated. When one of the guests of MHBH asked me “How do I get one of those shirts?” I gave him mine. While the shirt was cool I’m sure he’ll get more use out of it than I would have.

By Sunday the rest of the Insum team had started to show up and we had a great time re-connecting.

Both of my main presentations were on Monday. Thankfully I’d delivered both before, so I was really comfortable with the content although it was going to be my first time delivering my “You know you might have a bad data model when…” presentation in just thirty minutes (I’d been given one of the 30 minute sessions for this presentation). It’s a bunch of slides with the type of queries that you would either see in your applications or queries you can run against your application schemas to see if there might be opportunities for enhancements. Upon the advice of Steven Feuerstein, another member of the Insum team, instead of starting with the theory of normalization, I started with the actual queries. Since the theory portion would take about 5 minutes, my plan was to cut it off at 25 minutes and jump to the theory. I set an alarm on my phone for 25 minutes, let the audience know what I planned to do, and dove in. When I finished my queries section, I glanced at my watch to see how much time I had left. As I was glancing at my watch, the alarm on my phone went off! It was perfect and I got a bit of applause from the audience. I finished off the theory portion and then got a lot of good feedback including from some of the very experienced folks in the audience (Oracle ACE directors, etc.).

Later in the day, I did my “APEX and ORDS for DBAs and System Admins” presentation. While I’ve delivered the content at other events before, I always update my presentations to the latest and greatest software, and with the very frequent updates of both ORDS and APEX I had to update everything a few days before the conference.

This presentation is actually about 2 to 4 hours of content, but I only had an hour to deliver it. Basically, I cut the presentation in half and gave folks a preview of what would be in the 2nd half if I had more time. I also went through the first half of the presentation pretty quickly. The premise of the presentation is that people often come to Kscope and they see all these really cool APEX solutions, but then when they go back to their own IT department the DBA or System Admin just says “No.” The reason for the “No” can be anything they feel like coming up with at the time (“Security”, “Too complicated”, “I don’t know how to do it”, etc.) but the conference attendee doesn’t get the very cool APEX and/or ORDS features that they saw at the conference. To solve this problem, I broke the first half of the presentation into three sections.

  1. Install the APEX database component and patch it in the database.
    This section shows that APEX is just a component of the database (it shows up in the dba_registry view) and, by showing what is happening in the database we see that there are NO security changes in the database when you do this. It also showed how the installation and patch take under 10 minutes. On my boxes, the APEX install takes usually takes under six minutes and the patch takes under 30 seconds.
  2. Now that you have the APEX component in the database, you have access to bunches of very cool APIs. Some of those APIs enable you to reach out of the database to access things on remote servers if the DBAs allow it. I show exactly how to enable this and how to create and manage an Oracle TLS wallet (yes, people and Oracle often refer to this as an SSL wallet, but we really stopped using SSL back in the 1990s. It’s been TLS for over 20 years… and it really is a TLS wallet). Wallet management can be very tricky and I can’t tell you the number of times I’ve seen very bad wallet setups on Oracle servers. I explain the various wallet types (TDE wallet, SEPS wallet, XDB wallet, and TLS wallet) and show how I build and maintain them.
  3. Finally, we get to the last step which is setting up and configuring ORDS for a production-ready deployment. While Kris Rice, the Oracle lead for the ORDS team, disagrees with me, I really don’t like deploying ORDS with /ords/ in the URL. As Sir Tim Berner’s Lee explains, cool URLs don’t have the technology used to deploy them in the URL. Yes, that link is from 1998. I figure when Kris is knighted by the King he can tell me I’m wrong. I also show how to maintain ORDS over time. I show how to create the best

At this point, I’ve covered the first half of the presentation but an hour has passed and I have to just show folks what the next three sections are:

  • Adding a database resource manager plan that ‘just works’ for APEX deployments.
  • Building a Systemd service to run ORDS.
  • Deploying the ORDS service as a ‘regular’ operating system user instead of the root user. The root user can, of course, deploy ORDS on port 443 (the default HTTPS port) trivially, but some folks would prefer not to run ORDS as root, so I show how to do this.

My plan is to take all of that content and publish it here (update: The entire 2-hour APEX & ORDS for DBAs and System Admins is now live!), but it will take a while. Life is very busy and I’m not exactly sure when I’ll be able to finish it all. Until then, all of the code and examples from my both presentations can be found in the following Github repos:

Finally, I was a co-presenter with Cary Milsap of Method R in a presentation on tracing APEX. It was also well-received and sparked a lot of interesting discussions.

When I do get the time to post everything from my presentations I’ll try to remember to come back and here and link it in. Update: Here’s the link to the whole presentation from start to finish!

Until then, happy DBAing, System Admining, APEXing, and ORDSing.


Raised $6000 for the Center for Child Protection!

The annual Ride Drive Give event at Circuit of the Americas on Friday May 5th at CotA was a great success. I gave 12 different rides at $500 each to raise $6000 for the charity. Each year the event is a big success.

https://centerforchildprotection.org/events/2023-ride-drive-give/

I was a “Hot Lap Driver” giving people rides in my Revolution.

I even made the Ride Drive Give website as the example for “Racecar Hot Laps”.

The day started with some time blocked out on the schedule for me to rest, but I let the organizers fill up the whole day with rides so I could generate as much as possible for the event.

Of the 12 different riders, only one rider got a bit queasy, so I slowed down a bit for him. For everyone else, it was a ‘pretty brisk’ lap.

It was quite a bit of fun for me too, although I was quite exhausted by the end of the day. I also had both the Boxster race car and the Revolution in my trailer (with, of course, the Revolution in front of the Boxster in the trailer), so I had to load two cars at the end of the day. Danny (one of the other instructors) gave me a hand loading the cars which took much less time than if I did it all myself.

I feel very lucky to be able to give back to the community in this way.

See you at the track!


See you at Kscope 23!

Today I got two emails from the KScope team:

Dear Richard,

Congratulations! You have been accepted to speak at ODTUG Kscope23, June 25–29, 2023, in Aurora, Colorado!

The following abstract has been accepted for a 60-minute session:

  APEX & ORDS for DBAs and System Admins

Followed by:

The following abstract has been accepted for a 30-minute session.

  You know you might have a bad data model when…

That was followed up by another email from Cary Millsap of Method-R. Cary submitted a session with me as the co-presenter.

The following abstract has been accepted for a 60-minute session.

  Tracing APEX: the Ultimate in Performance Observability

I have the first presentation already done since I just delivered it at the RMOUG conference a few weeks ago. Oracle, of course, released new versions of APEX and ORDS after I thought I was done, including an APEX patch the Monday before I left. I had to scramble to update my content to reflect the new versions right before I left.

Between now and June, Oracle is going to release new versions of APEX and ORDS so I’ll have to update my content for the first presentation.

The 2nd presentation is currently on my whiteboard (It’s really glass… so is it a glass board?) in my office, so I’ll put that together pretty soon.

Cary recently wrote a book that has some good details on his topic for the conference. I’ve been able to review the book and make it a bit better. I’m really looking forward to working with Cary to come up with some compelling content for the conference.

If you are going, you can use code VINS23 to get $100 off your registration. Hopefully, we’ll see you all there!


Rich Soule Racing’s Revolution at CotA this Weekend

Rich Soule Racing will be at CotA this weekend. Stop by and get a ride!

In 2021 my Radical SR3 had a failure on track. A few dollar worm gear hose clamp broke and took out the engine. I debated long and hard about what to replace the car with and through a lot of luck I managed to find a 2020 Revolution A-One. It’s pretty awesome. It’s got around 400 or so horsepower from a naturally aspirated Ford V6 and weighs in at around 1750 lbs.

If you happen to be at Circuit of the Americas this weekend stop by.


Why haven’t you moved to AL32UTF8 yet?

Hey DBAs! Run this query on your database:

select value as character_set
  from nls_database_parameters
 where parameter = 'NLS_CHARACTERSET';

CHARACTER_SET
________________
AL32UTF8

If you see anything other than AL32UTF8 as the answer to the above query, then you should be building a plan to get from whatever character set your database is currently running to Unicode (AL32UTF8). While this can seem daunting, Oracle actually provides a great tool to assist with the process called the Oracle Database Migration Assistant for Unicode (DMU).

DMU will show you if your database will have any issues when you migrate from your legacy character set to Unicode. As you can see from the splash screen above “Oracle recommends using Unicode as the database character set for maximum compatibility and extensibility“. Oracle strongly suggests that all new databases should be created using AL32UTF8 and that legacy databases created in the past should be migrated to AL32UTF8.

A great time to think about a character set upgrade is during a database upgrade. If you are planning on a 19c upgrade (and we should really be there already today, but, of course, “should” and “are” are two different words for a reason) or potentially even 23c when Oracle releases it soon, and your current character set isn’t AL32UTF8 then now is the time to plan the migration!

Here’s a real-life DMU story:

A customer of mine had a database that had been created on Solaris in the late ’80s and they had used whatever the default character set was at the time, which is really what everyone was doing back then. In 2013 we decided to upgrade the database to 12.1 and change the character set during the upgrade. The fear was that this was going to be a big problem and we came up with all kinds of plans on how to fix the various issues (data cleansing, adjusting column widths on tables, etc.) However, after talking about all the potential issues, we actually ran the DMU and it showed us that the problem was much smaller than we thought. We only had about 30 rows of data that could have an issue during the migration!

After checking with the business, we just went into the 30 rows and cleaned up the data. A few “do not”s got changed to “don’t”, saving a single character which was all we needed.

Today, I talk to folks about using DMU to check their databases before they decide that “the problem is too big”. DMU will sometimes show that the problem either doesn’t exist, or it’s very small.

As an aside:

Today I did an install of DMU on a server using the download of DMU from Oracle Support. After extracting the zip file on my Oracle Linux box into /opt/oracle/dmu, I noticed that the dmu.sh script was read-only. A simple chmod u+x on the dmu.sh script enabled me to start it up without any issues.

[oracle@databaseserver DB:dbacon /opt/oracle/dmu]
$ ./dmu.sh
-bash: ./dmu.sh: Permission denied

[oracle@databaseserver DB:dbacon /opt/oracle/dmu]
$ chmod u+x dmu.sh

[oracle@databaseserver DB:dbacon /opt/oracle/dmu]
$ ./dmu.sh

   Database Migration Assistant for Unicode
 Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.

Directly Upload Files to Oracle Support

After watching a client move a file from their Linux database server down to their Windows box and then use their browser to upload the file to Oracle Support, I remembered that there was a more efficient way to do this. I was confident that I had this post in my blog already, but lo and behold, I hadn’t.

So today I fix that:

Let’s say you have an SR number 3-111222333444 and you need to upload a big zip file name zipfile.zip and you use email@blah.com to log into Oracle Support. The below command will get the file directly from your Linux box to Oracle Support.


curl -T "zipfile.zip" -u "email@blah.com" https://transport.oracle.com/upload/issue/3-111222333444/

Happy Linuxing!

Photo by Wesley Tingey on Unsplash


My Oracle Database Server PS1 Environment Variable

Today I was doing some tricky remote troubleshooting of an ORDS deployment. It turned out that it was the networking team doing fun stuff with the removal of cookies from only one of the multiple load-balanced devices between the users and the ORDS server (99% sure of this, we’ll see later if I was right). Since this stuff can be almost impossible to figure out without sniffing packets and/or visibility into the whole network configuration, a good trick to remember is to just deploy ORDS standalone on the desktop of the user attempting to troubleshoot things. If it works on their desktop, then it’s almost certainly the networking team doing something funny between the users and the application servers.

During the whole troubleshooting session, where the DBA was typing in all the commands as I dictated them (so much fun!), the DBA was constantly typing pwd. This post is for that DBA.

I’ve added the following line to my .bash_profile on all my Oracle database servers:

export PS1='\n[\u@\h DB:$( echo $ORACLE_SID ) \t \w]\n\$ '

PS1 is the environment variable that controls what your prompt looks like.

Mine has the following:

\n = a new line. This means that all of my commands have some nice whitespace (although I use green on black, so is that blackspace?) between them.

[ = the starting bracket for my prompt.

\u@\h = username@hostname

DB:$( echo $ORACLE_SID ) = Each time a new prompt is generated, find the value of the $ORACLE_HOME environment variable and display it with a DB: in front of it. It took me a bit to figure out how to get this to evaluate every time a new prompt was drawn. For my middleware servers, I leave this portion off. I suppose if your middleware server talks to only a single database, you could just hardcode it into the prompt.

\t = the current time

\w = the current working directory. No more typing pwd every other command!

] = the ending bracket for my prompt.

\n = another new line. This allows your actual command prompt to always start on the left side of the screen instead of constantly moving across the screen as you navigate down directory paths.

\$ = print the normal prompt. Notice that there is a space before the closing ‘ so that commands are not jammed up against the prompt.

Hopefully, an Oracle DBA or two out there finds this useful!

Happy DBAing!

#joelkallmanday


Motorsport Safety Academy HPDE Instructor Training Level 1 Course

While I’ve been instructing since 2006, anywhere from 2 to 6 days per month, almost every single month (I’ve missed a month here or there with work or family obligations), one organization that I instruct with wanted to have all their instructors take the HPDE Instructor Training Level 1 Course.

The course is composed of 17 lessons of various lengths and types (some are videos, some are slides), 13 quizzes, and a final assessment. Note that the final assessment isn’t just a repeat of the questions from the quizzes (like many lesser online exams), but instead, it’s almost all brand new questions (some of which are generally related to the quiz questions, but nothing that appeared to be a direct copy). This week I made my way through the various lessons and quizzes and then passed the final exam today.

HPDE Instructor Level 1 Course Certificate of Completion

Overall, the content is very good. Even though I’ve been instructing since 2006, there were a few things the content brought to my attention that I’ll probably do differently going forward. For example, I used to tell students at Circuit of the Americas to “Don’t brake” on the way into Turn 16, and going forward I’m going to refrain from saying “No braking/Don’t break” and instead use something else… maybe “Steady throttle” or “Slight lift” depending on how fast they are going into the turn.

I’d agree with the creators that the content would prepare someone thinking about instructing to be more prepared before they took whatever school/training program their local HPDE organization had for instructors. It certainly wouldn’t qualify anyone who had not done any instructing before to become an instructor.

One area that I really felt could have been better was the quizzes and the exam. Some of the quiz questions were along the lines of “What is your favorite color?” and the answers would be Red, Green, Yellow, and Blue. And then, amazingly, you could get the answer wrong because they were not really asking which was your favorite color, but instead, “What color do we think should be your favorite color?”. There was also a spelling mistake in the correct answer to a quiz question (“stop” was spelled “stp”). Also, I felt that the final assessment had questions that were not in any way discussed in the material. That’s fine (and I did pass on the first attempt), but it would have been nice if at the beginning of the course (or at least at the start of the final assessment) it was made clear that you’d be answering questions that you should know from your own track experience rather than from the content of the course. And some of the questions and answers were just a bit too subjective for my taste.

Overall, I’d give the course an A-. With a bit of editing on the exam questions and final exam, it could easily be brought up to an A.

Happy HPDEing!