Starting SQLPlus.docx

上传人:b****5 文档编号:6845751 上传时间:2023-01-11 格式:DOCX 页数:19 大小:29.22KB
下载 相关 举报
Starting SQLPlus.docx_第1页
第1页 / 共19页
Starting SQLPlus.docx_第2页
第2页 / 共19页
Starting SQLPlus.docx_第3页
第3页 / 共19页
Starting SQLPlus.docx_第4页
第4页 / 共19页
Starting SQLPlus.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

Starting SQLPlus.docx

《Starting SQLPlus.docx》由会员分享,可在线阅读,更多相关《Starting SQLPlus.docx(19页珍藏版)》请在冰豆网上搜索。

Starting SQLPlus.docx

StartingSQLPlus

StartingSQL*Plus

Thischapterdescribeshowtostart,login,andconnecttoadatabase,howtogethelp,andhowtoexitSQL*Plus.

Specifictopicsdiscussedare:

∙LoginUsernameandPassword

∙ConnectingtoaDatabase

∙StartingSQL*Plus

∙ExitingSQL*Plus

∙SQLPLUSProgramSyntax

LoginUsernameandPassword

WhenyoustartSQL*Plus,youneedausernameandpasswordtologintoanOracleDatabaseschema.YourusernameandpasswordidentifyyouasanauthorizeduseroftheOracleDatabaseschema.

Thedatabaseadministrator(DBA)isresponsibleforcreatingyourdatabaseaccountwiththenecessaryprivilegesandgivingyoutheusernameandpasswordthatenablesyoutoaccessyouraccount.

DefaultloginsarecreatedandyouarepromptedforassociatedpasswordsduringOracleDatabaseinstallation.Someofthedefaultloginusernamescreatedare:

∙SYS

∙SYSTEM

∙HR

LoginsarecreatedanddisplayedinmessagesduringOracleDatabaseinstallation.

Forfurtherinformationaboutthedefaultlogins,seetheOracleDatabaseAdministrator'sGuide.

Onceyouhaveloggedin,youcanconnectunderadifferentusernamewiththeSQL*PlusCONNECTcommand.Theusernameandpasswordmustbevalidforthedatabase.Forexample,toconnecttheusernameTODDtothedefaultdatabaseusingthepasswordFOX,youcouldenter

CONNECTTODD/FOX

Inthecommand-lineinterface,ifyouomittheusernameandpassword,SQL*Pluspromptsyouforthem.YoualsohavetheoptionoftypingonlytheusernamefollowingCONNECTandomittingthepassword(SQL*Plusthenpromptsforthepassword).BecauseCONNECTfirstdisconnectsyoufromyourcurrentdatabase,youwillbeleftunconnectedtoanydatabaseifyouuseaninvalidusernameandpasswordinyourCONNECTcommand.

Ifyoulogonorconnectasauserwhoseaccounthasexpired,youarepromptedtochangeyourpasswordbeforeyoucanconnect.

Ifanaccountislocked,amessageisdisplayedandconnectionasthisuserisnotpermitteduntiltheaccountisunlockedbyyourDBA.

YoucanusetheDISCONNECTcommandtodisconnectfromadatabasewithoutleavingSQL*Plus.

ChangingyourPassword

Inthecommand-lineinterface,youcanchangeyourpasswordwiththePASSWORDcommand.See"PASSWORD".

ChangingYourPasswordiniSQL*Plus

YoucanchangeyourOracleDatabaseaccountpasswordintheChangePasswordscreen.IfyouhaveloggedinwithDBAprivileges,youcanchangethepasswordofotherusers.YouaccesstheChangePasswordscreenfromthePreferencesscreen.

Descriptionoftheillustrationprefs_password.gif

Username:

EnteryourOracleDatabaseaccountusername.

Oldpassword:

EnteryourcurrentOracleDatabaseaccountpassword.

Newpassword:

Enteryournewpassword.

Retypenewpassword:

Enteryournewpasswordagaintomakesureyouhaveentereditcorrectly.

Apply

ClicktheApplybuttontochangethepasswordforyourOracleDatabaseaccount.

Cancel

ClicktheCancelbuttontoclearthescreenwithoutchangingyourpassword.

ExpiredPassword

Inthecommand-lineinterface,ifyourpasswordhasexpired,SQL*Pluspromptsyoutochangeitwhenyouattempttologin.Youareloggedinonceyousuccessfullychangeyourpassword.

ExpiredPasswordScreeniniSQL*Plus

Ifyourpasswordhasexpired,theExpiredPasswordscreenisautomaticallydisplayedwhenyouattempttologin.FilloutthefieldsontheExpiredPasswordscreenasyouwouldfortheChangePasswordscreen.

Youareloggedinonceyousuccessfullychangeyourpassword.IfyouclicktheCancelbutton,youarereturnedtotheLoginscreen.

Descriptionoftheillustrationpassword_expired.gif

ConnectingtoaDatabase

YoumustconnecttoanOracleDatabase(instance)beforeyoucanqueryormodifydatainthatdatabase.Youcanconnecttothedefaultdatabaseandtootherdatabasesaccessiblethroughyournetwork.Toconnecttoanotherdatabaseoveranetwork,bothdatabasesmusthaveOracleNetconfigured,andhavecompatiblenetworkdrivers.Youmustentereitheraconnectionidentifieroranetservicenametoconnecttoadatabaseotherthanthedefault.

Theconnectionidentifierornetservicenameisentered:

∙asanargumenttotheSQLPLUSProgramSyntaxwhenstartingacommand-linesession.

∙intheConnectionIdentifierfieldintheiSQL*PlusLoginScreenwhenstartingiSQL*Plus.

∙intheHostStringfieldintheLogOndialogwhenStartingtheWindowsGraphicalUserInterface.

∙asanargumenttotheCONNECTcommandfromacurrentsession.

NetServiceName

YourDBAisresponsibleforcreatingthedatabasesyouuseanddefiningnetservicenamesfortheminthetnsnames.orafile.IniSQL*Plus,yourDBAcanalsorestrictthedatabasesavailabletothoseshowninadropdownlistofnetservicenames.

Anetservicenamedefinitioninthetnsnames.orafilehasthesyntax:

net_service_name=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port))

(CONNECT_DATA=

(SERVICE_NAME=service_name)))

Touseanetservicename(alias),itmusthaveanentryinthetnsnames.orafileonthemachinerunningSQL*Plus,orforiSQL*Plus,themachinerunningtheiSQL*PlusApplicationServer.Anentryintnsnames.oraisnotrequiredifyouuseaconnectionidentifier.

Example4-1tnsnames.oraentryforthesalesdatabase

SALES1=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))

(CONNECT_DATA=

(SERVICE_NAME=)))

Example4-2Startacommand-linesessiontothesalesdatabaseusingthenetservicename

SQLPLUShr/password@SALES1

SeetheOracleNetServicesReferenceGuideandtheOracleNetServicesAdministrator'sGuideformoreinformationaboutdatabaseconnectionsandnetservicenamedefinitions.

FullConnectionIdentifier

Dependingonyourconfiguration,usethefullconnectionidentifiersyntaxlike:

(DESCRIPTION=

(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port))

(CONNECT_DATA=

(SERVICE_NAME=service_name)))

Youcanoptionallyusethe(INSTANCE_NAME=instance)phraseinplaceofthe(SERVICE_NAME=service_name)phrase.

WhenconnectingtoanOracle8idatabase,usethe(SID=name)phraseinplaceofthe(SERVICE_NAME=service_name)phrase.

Example4-3FullconnectionidentifierforSALES1

SQLPLUShr/password@(DESCRIPTION=

(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))

(CONNECT_DATA=

(SERVICE_NAME=)))

EasyConnectionIdentifier

Theeasyorabbreviatedconnectionidentifierhasthesyntax:

[//]host[:

port][/[service_name]]

Example4-4Startacommand-linesessiontothesalesdatabaseusingtheeasyconnectionidentifier

sqlplushr/password@sales-server:

1521/

Example4-5CONNECTtothesalesdatabaseusingtheeasyconnectionidentifier

connecthr/password@sales-server:

1521/

Theeasyconnectionidentifiercanbeusedwhereveryoucanuseafullconnectionidentifier,oranetservicename.Theeasysyntaxislesscomplex,andnotnsnames.oraentryisrequired.

ConnectionlessSessionwith/NOLOG

Inthecommand-lineinterface,itispossibletostartSQL*Pluswithoutconnectingtoadatabase.Thisisusefulforperformingsomedatabaseadministrationtasks,writingtransportablescripts,ortouseSQL*Pluseditingcommandstowriteoreditscripts.

Youusethe/NOLOGargumenttotheSQLPLUScommandtostartaconnectionlesscommand-linesession.AfterSQL*PlushasstartedyoucanconnecttoadatabasewiththeCONNECTcommand.

Example4-6StartaconnectionlessSQL*Plussessionwith/NOLOG

SQLPLUS/NOLOG

StartingSQL*Plus

IfyouareconnectingtoaremoteOracledatabase,makesureyourOracleNetsoftwareisinstalledandworkingproperly.Formoreinformation,seetheOracleNetServicesAdministrator'sGuide.

WhenyoustartaSQL*Pluscommand-lineorWindowsGUIsession,andafteraCONNECTcommandinthatsession,thesiteprofile,glogin.sql,andtheuserprofilefile,login.sql,areprocessed:

∙AfterSQL*Plusstartsandconnects,andpriortodisplayingthefirstprompt.

∙AfterSQL*Plusstartsandconnects,andpriortorunningascriptspecifiedonthecommand-line.

∙Priortothefirstpromptwhen/NOLOGisspecifiedonthecommand-lineandnoconnectionismade.

Thesiteprofilefile,glogin.sqlisprocessedfirst,thentheuserprofilefile,login.sql.

WhenyoustartaniSQL*Plussession,andafteraCONNECTcommandinthatsession,thesiteprofile,glogin.sql,isprocessed:

∙AfteriSQL*Plusstartsandconnects.

∙AfteriSQL*Plusstartsandconnects,andpriortorunningascriptspecifiedinadynamicURL.

BehaviorinSQL*Plus10.1maybeunexpecteddependingonthesettingofSETSQLPLUSCOMPATIBILITY.Forexample,processingglogin.sqlandlogin.sqlafteraCONNECTcommandonlyoccurswiththedefaultSQLPLUSCOMPATIBILITYsettingof10.1.Formoreinformation,seeSETSQLPLUSCOMPAT[IBILITY]{x.y[.z]}.

StartingCommand-lineSQL*Plus

TobeginusingSQL*Plus,youmustfirstunderstandhowtostartandstopSQL*Plus.

Example4-7StartingSQL*Plus

ThisexampleshowsyouhowtostartSQL*Plus:

1.MakesurethatSQL*Plushasbeeninstalledonyourcomputer.

2.Logontotheoperatingsystem(ifrequired).

3.Enterthecommand,SQLPLUS,andpressReturn.

Note:

Someoperatingsystemsexpectyoutoentercommandsinlowercaseletters.Ifyoursystemexpectslowercase,entertheSQLPLUScommandinlowercase.

SQLPLUS

SQL*Plusdisplaysitsversionnumber,thecurrentdate,andcopyrightinformation,andpromptsyouforyourusername(thetextdisplayedonyoursystemmaydifferslightly):

SQL*Plus:

Release10.1.0.2.0-ProductiononThuOct516:

29:

012003

(c)Copyright1982,2003OracleCorporation.Allrightsreserved.

Enteruser-name:

4.EnteryourusernameandpressReturn.SQL*Plusdisplaystheprompt"Enterpassword:

".

5.EnteryourpasswordandpressReturnagain.Foryourprotection,yourpassworddoe

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1