How to get table comments via SQL in Oracle?

Since 10g Oracle doesn’t immediately drop tables when we issue a DROP TABLE statement. Instead it renames them like this BIN$IN1vjtqhTEKcWfn9PshHYg==$0 and puts them in the recycle bin. This allows us to recover tables we didn’t mean to drop. Find out more. Tables in the recycle bin are still tables, so they show up in … Read more

Oracle equivalent of Postgres’ DISTINCT ON?

The same effect can be replicated in Oracle either by using the first_value() function or by using one of the rank() or row_number() functions. Both variants also work in Postgres. first_value() select distinct col1, first_value(col2) over (partition by col1 order by col2 asc) from tmp first_value gives the first value for the partition, but repeats … Read more

SQL: how to limit a join on the first found row?

The key word here is FIRST. You can use analytic function FIRST_VALUE or aggregate construct FIRST. For FIRST or LAST the performance is never worse and frequently better than the equivalent FIRST_VALUE or LAST_VALUE construct because we don’t have a superfluous window sort and as a consequence a lower execution cost: select table_A.id, table_A.name, firstFromB.city … Read more

Return results of a sql query as JSON in oracle 12c

12cR2 (available in the Oracle Cloud) supports this natively. SQL> select JSON_ARRAY(EMPLOYEE_ID, FIRST_NAME,LAST_NAME) from HR.EMPLOYEES; JSON_ARRAY(EMPLOYEE_ID,FIRST_NAME,LAST_NAME) ——————————————————————————– [100,”Steven”,”King”] [101,”Neena”,”Kochhar”] or SQL> select JSON_OBJECT(‘ID’ is EMPLOYEE_ID , ‘FirstName’ is FIRST_NAME,’LastName’ is LAST_NAME) from HR.EMPLOYEES; JSON_OBJECT(‘ID’ISEMPLOYEE_ID,’FIRSTNAME’ISFIRST_NAME,’LASTNAME’ISLAST_NAME) —————————————————————————- {“ID”:100,”FirstName”:”Steven”,”LastName”:”King”} {“ID”:101,”FirstName”:”Neena”,”LastName”:”Kochhar”}

what is oradiag_ folder?

I never installed Oracle on my system and don’t know why these directories kept being created, but I finally managed to stop them from reappearing. Here’s how it’s done. First, head over to: cd ~/oradiag_<username>/diag/clients/user_<username>/host_*/trace/ and then head sqlnet.log You should see an error message complaining about a directory not existing for r/w. For me, … Read more

techhipbettruvabetnorabahisbahis forumueduedueduseduseduseduedusedueduedu