1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Using SQL*Plus pdf

15 443 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 15
Dung lượng 241 KB

Nội dung

C Copyright © Oracle Corporation, 2001. All rights reserved. Using SQL*Plus C-2 Copyright © Oracle Corporation, 2001. All rights reserved. Objectives After completing this appendix, you should be able to After completing this appendix, you should be able to do the following: do the following: • Log in to SQL*Plus Log in to SQL*Plus • Edit SQL commands Edit SQL commands • Format output using SQL*Plus commands Format output using SQL*Plus commands • Interact with script files Interact with script files C-3 Copyright © Oracle Corporation, 2001. All rights reserved. SQL and SQL*Plus Interaction SQL*Plus SQL*Plus Buffer Buffer Server SQL statements Query results SQL scripts C-4 Copyright © Oracle Corporation, 2001. All rights reserved. SQL Statements versus SQL*Plus Commands SQL SQL statements statements SQL SQL • A language A language • ANSI standard ANSI standard • Keywords cannot be Keywords cannot be abbreviated abbreviated • Statements manipulate Statements manipulate data and table data and table definitions in the definitions in the database database SQL*Plus SQL*Plus • An environment An environment • Oracle proprietary Oracle proprietary • Keywords can be Keywords can be abbreviated abbreviated • Commands do not Commands do not allow manipulation of allow manipulation of values in the database values in the database SQL SQL buffer buffer SQL*Plus SQL*Plus commands commands SQL*Plus SQL*Plus buffer buffer C-5 Copyright © Oracle Corporation, 2001. All rights reserved. • Log in to SQL*Plus. Log in to SQL*Plus. • Describe the table structure. Describe the table structure. • Edit your SQL statement. Edit your SQL statement. • Execute SQL from SQL*Plus. Execute SQL from SQL*Plus. • Save SQL statements to files and append SQL Save SQL statements to files and append SQL statements to files. statements to files. • Execute saved files. Execute saved files. • Load commands from file to buffer Load commands from file to buffer to edit. to edit. Overview of SQL*Plus C-6 Copyright © Oracle Corporation, 2001. All rights reserved. Logging In to SQL*Plus • From a Windows environment: From a Windows environment: • From a command line: From a command line: sqlplus [ sqlplus [ username username [/ [/ password password [@ [@ database database ]]] ]]] C-7 Copyright © Oracle Corporation, 2001. All rights reserved. Displaying Table Structure Use the SQL*Plus Use the SQL*Plus DESCRIBE DESCRIBE command to display the command to display the structure of a table. structure of a table. DESC[RIBE] tablename C-8 Copyright © Oracle Corporation, 2001. All rights reserved. Name Null? Type DEPARTMENT_ID NOT NULL NUMBER(4) DEPARTMENT_NAME NOT NULL VARCHAR2(30) MANAGER_ID NUMBER(6) LOCATION_ID NUMBER(4) Displaying Table Structure SQL> DESCRIBE departments C-9 Copyright © Oracle Corporation, 2001. All rights reserved. SQL*Plus Editing Commands • A[PPEND] A[PPEND] text text • C[HANGE] / C[HANGE] / old old / / new new • C[HANGE] / C[HANGE] / text text / / • CL[EAR] BUFF[ER] CL[EAR] BUFF[ER] • DEL DEL • DEL DEL n n • DEL DEL m n m n C-10 Copyright © Oracle Corporation, 2001. All rights reserved. SQL*Plus Editing Commands • I[NPUT] I[NPUT] • I[NPUT] I[NPUT] text text • L[IST] L[IST] • L[IST] L[IST] n n • L[IST] L[IST] m n m n • R[UN] R[UN] • n n • n text n text • 0 0 text text [...].. .Using LIST, n, and APPEND SQL> LIST 1 SELECT last_name 2* FROM employees SQL> 1 1* SELECT last_name SQL> A , job_id 1* SELECT last_name, job_id SQL> L 1 SELECT last_name, job_id 2* FROM employees C-11 Copyright © Oracle Corporation, 2001 All rights reserved Using the CHANGE Command SQL> L 1* SELECT * from employees SQL> c/employees/departments... departments SQL> L 1* SELECT * from departments C-12 Copyright © Oracle Corporation, 2001 All rights reserved SQL*Plus File Commands • • • • • • • C-13 SAVE filename GET filename START filename @ filename EDIT filename SPOOL filename EXIT Copyright © Oracle Corporation, 2001 All rights reserved Using the SAVE and START Commands SQL> 1 2* SQL> L SELECT last_name, manager_id, department_id FROM employees... my_query SQL> START my_query LAST_NAME MANAGER_ID DEPARTMENT_ID - King 90 Kochhar 100 90 20 rows selected C-14 Copyright © Oracle Corporation, 2001 All rights reserved Summary Use SQL*Plus as an environment to: • • • • C-15 Execute SQL statements Edit SQL statements Format output Interact with script files Copyright © Oracle Corporation, 2001 All rights reserved . • Log in to SQL*Plus Log in to SQL*Plus • Edit SQL commands Edit SQL commands • Format output using SQL*Plus commands Format output using SQL*Plus commands • Interact. database SQL SQL buffer buffer SQL*Plus SQL*Plus commands commands SQL*Plus SQL*Plus buffer buffer C-5 Copyright © Oracle Corporation, 2001. All rights reserved. • Log in to SQL*Plus. Log

Ngày đăng: 17/02/2014, 14:20

TỪ KHÓA LIÊN QUAN

w