tags:

views:

68

answers:

1

I've recently started using oracle after a few years of using mysql. I was immediately struck by how verbose oracle is compared to mysql. Four-word queries (like SHOW INDEX IN < table> ) become four-line queries in oracle.

My question is: how do real oracle DBAs interact with oracle efficiently. There must be some way to alias commonly used commands (like you do in the unix shell). I find it hard to believe that they would type something like

select index_name, column_name, column_position from user_ind_columns
where table_name='MYTABLENAME' order by index_name, column_position

every time they wanted to do something as simple as list the indexes of a table. Otherwise how can they get any work done?

+6  A: 

You can use an IDE like SQL Developer or Toad; these have a UI to browse tables, indexes and other objects without typing any commands.

Or in SQL Plus you can simply save commonly used queries as scripts in files, for example a script called show_index could contain:

select index_name, column_name, column_position from user_ind_columns
where table_name=upper('&TABLENAME.') order by index_name, column_position;

You would run this in SQL Plus like this:

SQL> @show_index 
Enter value for tablename: mytable
Tony Andrews
+1 - Also, if you have it licensed the Oracle supplied Enterprise Manager can show many of these things as well as aid in tasks such as segment reorganization, tuning, etc. I find it somewhat clunky compared to tools such as Toad and SQL Developer, but it has it's uses.
RC
To add to this, check out the Reports functionality in Oracle SQL Developer (View > Reports). I have recently started using this and have found it quite useful. There are a lot of time-saving snippets in there. For example, if you were searching a specific tables indexes:Data Dictionary Reports > Table > Indexes > All IndexesYou can also add user defined reports.
idea