案例教学讲稿sqlplus_第1页
案例教学讲稿sqlplus_第2页
案例教学讲稿sqlplus_第3页
案例教学讲稿sqlplus_第4页
案例教学讲稿sqlplus_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Using SQL*Plus ObjectivesAfter completing this appendix, you should be able to do the following:Log in to SQL*PlusEdit SQL commandsFormat output using SQL*Plus commandsInteract with script filesSQL and SQL*Plus InteractionBufferServerSQL statementsQuery resultsSQL scriptsSQL*PlusSQL Statements Versu

2、sSQL*Plus Commands SQLA languageANSI-standardKeywords cannot beabbreviatedStatements manipulate dataand table definitions in thedatabaseSQLstatementsSQLbufferSQL*Plus commandsSQL*Plus bufferSQL*Plus An environmentOracle-proprietaryKeywords can be abbreviatedCommands do not allow manipulation of valu

3、es in the databaseOverview of SQL*Plus Log in to SQL*Plus.Describe the table structure.Edit your SQL statement.Execute SQL from SQL*Plus.Save SQL statements to files and append SQL statements to files.Execute saved files.Load commands from file to buffer to edit.sqlplus username/passworddatabaseLogg

4、ing in to SQL*Plus 12Changing the Settings of SQL*Plus EnvironmentDisplaying Table StructureUse the SQL*Plus DESCRIBE command to display the structure of a table:DESCRIBE tablenameDisplaying Table StructureName Null? Type- - -DEPARTMENT_ID NOT NULL NUMBER(4)DEPARTMENT_NAME NOT NULL VARCHAR2(30)MANAG

5、ER_ID NUMBER(6)LOCATION_ID NUMBER(4)DESCRIBE departmentsSQL*Plus Editing CommandsAPPEND textCHANGE / old / newCHANGE / text /CLEAR BUFFERDELDEL nDEL m nSQL*Plus Editing CommandsINPUTINPUT textLISTLIST nLIST m n RUNnn text0 textUsing LIST, n, and APPENDLIST 1 SELECT last_name 2* FROM employees1 1* SE

6、LECT last_nameA , job_id 1* SELECT last_name, job_idLIST 1 SELECT last_name, job_id 2* FROM employeesUsing the CHANGE CommandLIST 1* SELECT * from employeesc/employees/departments 1* SELECT * from departmentsLIST 1* SELECT * from departmentsSQL*Plus File CommandsSAVE filenameGET filenameSTART filena

7、me filenameEDIT filenameSPOOL filenameEXITUsing the SAVE, START, and EDIT CommandsLIST 1 SELECT last_name, manager_id, department_id 2* FROM employeesSAVE my_query Created file my_querySTART my_queryLAST_NAME MANAGER_ID DEPARTMENT_ID- - -King 90Kochhar 100 90.107 rows selected.Using the SAVE, START,

8、 and EDIT CommandsEDIT my_querySERVEROUTPUT CommandUse the SET SERVEROUTPUT command to control whether to display the output of stored procedures or PL/SQL blocks in SQL*Plus. The DBMS_OUTPUT line length limit is increased from 255 bytes to 32767 bytes.The default size is now unlimited.Resources are

9、 not pre-allocated when SERVEROUTPUT is set.Because there is no performance penalty, use UNLIMITED unless you want to conserve physical memory.SET SERVEROUTPUT ON | OFF SIZE n | UNLIMITED FORMAT WRAPPED | WORD_WRAPPED | TRUNCATEDUsing the SQL*Plus SPOOL CommandSPOOL file_name.ext CREATE | REPLACE |

10、APPEND | OFF | OUTOptionDescriptionfile_name.extSpools output to the specified file name.CREATECreates a new file with the name specified.REPLACEReplaces the contents of an existing file. If the file does not exist, REPLACE creates the file.APPENDAdds the contents of the buffer to the end of the fil

11、e you specify.OFFStops spooling.OUTStops spooling and sends the file to your computers standard (default) printer.Using the AUTOTRACE CommandDisplays a report after the successful execution of SQL DML statements such as SELECT, INSERT, UPDATE or DELETE.The report can now include execution statistics and the query execution path.SET AUTOTRACE ON | OFF | TRACEONLY EXPLAIN STATISTICSSET AUTOTRACE ON- The AUTOTRACE report includes both the optimizer- execution path and the SQL statement execution - statistics.Sum

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论