I have a table with a massive number of columns. So many, that when I do SELECT * I can't even see any values because all the columns fill up the screen. I'd like to do something like this:
SELECT * FROM my_table WHERE NAME LIKE '%unique name%' AND <THIS COLUMN> IS NOT NULL
Is this possible? Note: VALUE is not a column.
There are so many questions on SO that ask this same question, but they have some bizarre twist, and the actual question is not answered.
I've tried:
SELECT * FROM my_table WHERE NAME LIKE '%unique name%' AND VALUE NOT NULL
*
Invalid relational operator
SELECT * FROM my_table WHERE NAME LIKE '%unique name%' AND VALUE <> ''
*
'VALUE': invalid identifier
SELECT * FROM my_table WHERE NAME LIKE '%unique name%' AND COLUMN NOT NULL
*
Missing Expression
Bonus Questions:
- Is there any way to force Oracle to only show one output screen at a time?
- Is there a variable to use in the WHERE clause that relates to the current column? Such as:
WHERE this.column = '1', where it would check each column to match that expression? - Is there any way to get back your last command in Oracle? (I have to remote into a Linux box running Oracle - it's all command line - can't even copy/paste, so I have to type every command by hand, with a wonky connection, so it's taking an extremely long time to debug this stuff)
my_tablein this example a table with a columnnameand another columnvalue? Or are you trying to do something wherenameis the name of each column in the table andvalueis the value in that column? So if I have a table with hundreds of columns, I am dynamically picking the columns I want to read and only displaying rows where at least one of those columns has a non-NULL value?VALUEis not a column.NAMEis a column. The name in the LIKE expression is unique enough to only return one row. However, it returns too many columns, they fill up the entire screen without showing any values.SELECT name, col1 FROM my_table WHERE NAME LIKE '%unique name%' AND col1 IS NOT NULLdbms_output-prints the column name and value if it is non-null. bonus question 2: no, there is no notion of a "current column" in the where clause.