Вы находитесь на странице: 1из 4

2 SOL*Pus

Introducton
SOL*Pus s the nteractve (ow-eve) user nterface to the Orace
database management
system. Typcay, SOL*Pus s used to ssue ad-hoc queres and to vew
the query resut on
the screen. Some of the features of SOL*Pus are:
A but-n command ne edtor can be used to edt (ncorrect) SOL
queres. Instead of
ths ne edtor any edtor nstaed on the computer can be nvoked.
There are numerous commands to format the output of a query.
SOL*Pus provdes an onne-hep.
Ouery resuts can be stored n fes whch then can be prnted.
Oueres that are frequenty ssued can be saved to a fe and nvoked
ater. Oueres can be
parameterzed such that t s possbe to nvoke a saved query wth a
parameter.
A Mnma User Gude
Before you start SOL*Pus make sure that the foowng UNIX she
varabes are propery set
(she varabes can be checked usng the env command, e.g., env | grep
ORACLE):
ORACLE HOME, e.g., ORACLE HOME=/usr/pkg/orace/734
ORACLE SID, e.g, ORACLE SID=prod
In order to nvoke SOL*Pus from a UNIX she, the command sqpus has to
be ssued.
SOL*Pus then dspays some nformaton about the product, and prompts
you for your user
name and password for the Orace system.
gertz(catbert)54: sqpus
SOL*Pus: Reease 3.3.4.0.1 - Producton on Sun Dec 20 19:16:52 1998
Copyrght (c) Orace Corporaton 1979, 1996. A rghts reserved.
Enter user-name: scott
Enter password:
Connected to:
Orace7 Server Reease 7.3.4.0.1 - Producton Reease
Wth the dstrbuted opton
PL/SOL Reease 2.3.4.0.0 - Producton
SOL>
20
SOL> s the prompt you get when you are connected to the Orace
database system. In
SOL*Pus you can dvde a statement nto separate nes, each contnung
ne s ndcated by
a prompt such 2>, 3> etc. An SOL statement must aways be termnated
by a semcoon (;).
In addton to the SOL statements dscussed n the prevous secton,
SOL*Pus provdes some
speca SOL*Pus commands. These commands need not be termnated by
a semcoon. Upper
and ower case etters are ony mportant for strng comparsons. An SOL
query can aways be
nterrupted by usng <Contro>C. To ext SOL*Pus you can ether type
ext or qut.
Edtor Commands
The most recenty ssued SOL statement s stored n the SOL buffer,
ndependent of whether the
statement has a correct syntax or not. You can edt the buffer usng the
foowng commands:
|st| sts a nes n the SOL buffer and sets the current ne (marked
wth an "") to
the ast ne n the buffer.
<number> sets the actua ne to <number>
c|hange|/<od strng>/<new strng> repaces the frst occurrence of
<od strng> by
<new strng> (for the actua ne)
a|ppend|<strng> appends <strng> to the current ne
de deetes the current ne
r|un| executes the current buffer contents
get<fe> reads the data from the fe <fe> nto the buffer
save<fe> wrtes the current buffer nto the fe <fe>
edt nvokes an edtor and oads the current buffer nto the edtor. After
extng the
edtor the modfed SOL statement s stored n the buffer and can be
executed (command
r).
The edtor can be defned n the SOL*Pus she by typng the command
defne edtor =
<name>, where <name> can be any edtor such as emacs, v, |oe, or
|ove.
SOL*Pus Hep System and Other Usefu Commands
To get the onne hep n SOL*Pus |ust type hep <command>, or |ust
hep to get
nformaton about how to use the hep command. In Orace Verson 7 one
can get the
compete st of possbe commands by typng hep command.
To change the password, n Orace Verson 7 the command
ater user <user> dentfed by <new password>;
s used. In Orace Verson 8 the command passw <user> prompts the user
for the
od/new password.
The command desc|rbe| <tabe> sts a coumns of the gven tabe
together wth ther
data types and nformaton about whether nu vaues are aowed or not.
You can nvoke a UNIX command from the SOL*Pus she by usng host
<UNIX command>.
For exampe, host s -a *.sq sts a SOL fes n the current drectory.
21
You can og your SOL*Pus sesson and thus queres and query resuts by
usng the
command spoo <fe>. A nformaton dspayed on screen s then stored
n <fe>
whch automatcay gets the extenson .st. The command spoo off turns
spoong off.
The command copy can be used to copy a compete tabe. For exampe,
the command
copy from scott/tger create EMPL usng seect from EMP;
copes the tabe EMP of the user scott wth password tger nto the reaton
EMPL. The
reaton EMP s automatcay created and ts structure s derved based on
the attrbutes
sted n the seect cause.
SOL commands saved n a fe <name>.sq can be oaded nto SOL*Pus
and executed
usng the command @<name>.
Comments are ntroduced by the cause rem|ark| (ony aowed between
SOL statements),
or - - (aowed wthn SOL statements).
Formattng the Output
SOL*Pus provdes numerous commands to format query resuts and to
bud smpe reports.
For ths, format varabes are set and these settngs are ony vad durng
the SOL*Pus sesson.
They get ost after termnatng SOL*Pus. It s, however, possbe to save
settngs n a fe named
ogn.sq n your home drectory. Each tme you nvoke SOL*Pus ths fe s
automatcay
oaded.
The command coumn <coumn name> <opton 1> <opton 2> . . . s
used to format coumns
of your query resut. The most frequenty used optons are:
format A<n> For aphanumerc data, ths opton sets the ength of
<coumn name> to
<n>. For coumns havng the data type number, the format command can
be used to
specfy the format before and after the decma pont. For exampe, format
99,999.99
specfes that f a vaue has more than three dgts n front of the decma
pont, dgts are
separated by a coon, and ony two dgts are dspayed after the decma
pont.
The opton headng <text> reabes <coumn name> and gves t a new
headng.
nu <text> s used to specfy the output of nu vaues (typcay, nu
vaues are not
dspayed).
coumn <coumn name> cear deetes the format defntons for
<coumn name>.
The command set nesze <number> can be used to set the maxmum
ength of a snge
ne that can be dspayed on screen. set pagesze <number> sets the
tota number of nes
SOL*Pus dspays before prntng the coumn names and headngs,
respectvey, of the seected
rows.
Severa other formattng features can be enabed by settng SOL*Pus
varabes. The command
show a dspays a varabes and ther current vaues. To set a varabe,
type set <varabe>
<vaue>. For exampe, set tmng on causes SOL*Pus to dspay tmng
statstcs for each
SOL command that s executed. set pause on |<text>| makes SOL*Pus
wat for you to press
Return after the number of nes defned by set pagesze has been
dspayed. <text> s the
message SOL*Pus w dspay at the bottom of the screen as t wats for
you to ht Return.
22

Вам также может понравиться