I said there were 8 ways to avoid using SELECT * FROM queries in SQL Developer – but I didn’t actually count them. So let’s do that now.
— OracleSQLDeveloper (@OracleSQLDev) November 23, 2016
But wait, what’s wrong with SELECT * FROM queries?
- you don’t need all the columns
- columns can change
- columns can be added
- columns can be removed
At some point, your application (or report) will ‘break.’
So, how do we avoid this? Let’s count the ways.
Drag and Drop from the Tree
I like this one a lot, the order in which I select the columns in the tree is the order in which they’ll be inserted into the worksheet.
Drag and Drop from a DESC Window
SHIFT+F4 – table pops up. Select one or more columns, and drag them in.
Click on the columns you want. We write the query for you.
One or more fields, we can even alias them for you auto-mmagically.
SQL Text Expansion
A new Database 12c feature – get the REAL SQL behind your query – very helpful when dealing with VIEWs.
SUPER DUPER TRICK: Did you know you can change the parser squiggly line helper marks?
SELECT * Peeking/Replacement
Place your mouse over the asterisk, we’ll show you the columns underneath. If you click on them, we’ll replace it for you.
Just take the time to type it out
Don’t laugh. Using tools has a tendency to make us code FAST. Which is good, unless you need to think something through. So while these other methods are ‘wicked-awesome’ – don’t forget about the tried and true ways…like copying and pasting code you’ve already written 🙂
There is a number 8!
Oracle ACE Sabine reminds me of this final method – copying one or more column headers from your query result grid. So if you have the text already there, you can simply grab it.