Some useful sql commands and knowledge in sqlplus

1. When you access sqlplus with sysdba withought password to check system tables

   sqlplus / as sysdba
   

2. When you access sqlplus with anonymous, only use sqlplus command without any privileges

   sqlplus /nolog 
   

3. To check sid information
we need to check tnsnames.ora file in network folder

4. Display cache commands: l or run
1) assume you have sql command to query like
select * from table1;
2) after executing, you can input ‘run’ or ‘l’, the sqlplus console will show
select * from table1;

5. Fast run last command: /
1) assume you have sql command to query like

      select * from table1;

2) after executing, you can input ‘/’ , the sqlplus console will show again
result of ‘select * from table1’;

6. Assume you have long rows table for query in sqlplus
for example, when there are many tables now, you can input :

   set pause on
   select * from tab;

‘set pause on’ means when up to pagesize rows, the result will stop until you input ENTER the key to next page

7. When you need to add parameter manually, not directly in sql command, use

   select * from tablename where id=&myid

Then after executing, you will get input value tip, after inputing, the sql will continue to run

8. Comment in sqlplus command with multiple lines

For example:

   select columna -- this is columna comment
   from tablename;

Leave a Reply

Your email address will not be published. Required fields are marked *