SQL*PLUS

LOGIN

if you do not have username and password of a system user you can use the following command in the command line tool

sqlplus / as sysdba

As you are already logged in OS sqlplus considers you a system user and lets you login like this so that you can create a new user with certain grants.

OUTPUT VIEW
output in sql*plus does not look the best, so we adjust it with this command. We can choose the column name and the amount of characters that is to be shown after a. Example where we give 20 characters to the column.

column COLUMN_NAME format a20

To restore default formatting we use

clear columns;

OUTPUT IN FILE
if you want to output in a file you should use spool command

spool on
spool c:\path_to_the_file.txt
select * from dictionary -- statement you want to be in output
spool off

RUNNING SCRIPTS
we have to check in which folder are we located with the following command
host pwd

To change the current directory, you would need to exit sql*plus with the exit command and then change it and reenter sql*plus

and then to list files with the extension sql
host ls *.sql

and then we can run the command
@nameOfTheScript.sql
column first_name format a12;

SET EDITOR
SQL> DEFINE _EDITOR=vi

When you start the editor, SQL*Plus uses the afiedt.buf temporary file to pass text to the editor. You can use the SET EDITFILE command to specify a different file name. For example:
SQL> SET EDITFILE /tmp/myfile.sql

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: