4.SQLPLUS使用技巧

1.sqlplus登录界面:

#1.字符界面
Linux/Unix/Dos平台默认方式
#2.图形界面
Win图形界面下使用

2.sqlplus连接:

#1.登录sys用户
sqlplus / as sysdba
#2.登录scott用户
sqlplus scott/tiger

3.sqlplus连接参数连接数据库:

#1.测试tnsping
[oracle@yuanzj.com:/home/oracle]$ tnsping 192.168.2.18:1521/orcl10g

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 18-FEB-2023 18:32:54

Copyright (c) 1997,  2010, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=orcl10g))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.18)(PORT=1521)))
OK (0 msec)

#2.测试服务名
[oracle@yuanzj.com:/home/oracle]$ tnsping orcl10g

TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 18-FEB-2023 18:33:32

Copyright (c) 1997,  2010, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yuanzj.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl10g)))
OK (10 msec)

#3.远程登录数据库
[oracle@yuanzj.com:/home/oracle]$ sqlplus scott/tiger@192.168.2.18:1521/orcl10g

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Feb 18 18:34:18 2023

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options

scott@ORCL10G 2023-02-18 18:34:18> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options
[oracle@yuanzj.com:/home/oracle]$ sqlplus scott/tiger@192.168.2.18:1522/orcl11g

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Feb 18 18:34:36 2023

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

scott@ORCL11G 2023-02-18 18:34:36> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

#4.本地服务名登录数据库
[oracle@yuanzj.com:/home/oracle]$ 10g 
[oracle@yuanzj.com:/home/oracle]$ sqlplus scott/tiger@orcl10g

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Feb 18 18:36:24 2023

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options

scott@ORCL10G 2023-02-18 18:36:24> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options
[oracle@yuanzj.com:/home/oracle]$ 11g 
[oracle@yuanzj.com:/home/oracle]$ sqlplus scott/tiger@orcl11g

SQL*Plus: Release 11.2.0.4.0 Production on Sat Feb 18 18:36:31 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

scott@ORCL11G 2023-02-18 18:36:31> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

4.sqlplus常用命令 

#1.连接指定用户
sqlplus scott/tiger
#2.显示当前用户和错误
show user 
show errors
#3.显示对象结构
desc <object_name>
例如:
desc emp
#4.编辑文件编辑文件
edit/ed <filename> 编辑文件
define _editor='vi'

5.spool命令的使用

5.1.屏幕输出保留到文件中

5.2.替换现存文件中的内容

5.3.追加内容到现存文件 

5.4关闭spool

scott@ORCL10G 2023-02-18 18:53:36> spool /home/oracle/emp.txt rep
scott@ORCL10G 2023-02-18 18:53:47> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 18:53:53> spool off
scott@ORCL10G 2023-02-18 18:54:00> select * from dept;

    DEPTNO DNAME	  LOC
---------- -------------- -------------
	10 ACCOUNTING	  NEW YORK
	20 RESEARCH	  DALLAS
	30 SALES	  CHICAGO
	40 OPERATIONS	  BOSTON

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 18:54:08> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options
[oracle@yuanzj.com:/home/oracle]$ cat emp.txt 
scott@ORCL10G 2023-02-18 18:53:47> select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 1980-12-17 00:00:00        800                    20
      7499 ALLEN      SALESMAN        7698 1981-02-20 00:00:00       1600        300         30
      7521 WARD       SALESMAN        7698 1981-02-22 00:00:00       1250        500         30
      7566 JONES      MANAGER         7839 1981-04-02 00:00:00       2975                    20
      7654 MARTIN     SALESMAN        7698 1981-09-28 00:00:00       1250       1400         30
      7698 BLAKE      MANAGER         7839 1981-05-01 00:00:00       2850                    30
      7782 CLARK      MANAGER         7839 1981-06-09 00:00:00       2450                    10
      7788 SCOTT      ANALYST         7566 1987-04-19 00:00:00       3000                    20
      7839 KING       PRESIDENT            1981-11-17 00:00:00       5000                    10
      7844 TURNER     SALESMAN        7698 1981-09-08 00:00:00       1500          0         30
      7876 ADAMS      CLERK           7788 1987-05-23 00:00:00       1100                    20
      7900 JAMES      CLERK           7698 1981-12-03 00:00:00        950                    30
      7902 FORD       ANALYST         7566 1981-12-03 00:00:00       3000                    20
      7934 MILLER     CLERK           7782 1982-01-23 00:00:00       1300                    10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 18:53:53> spool off

6.定义开始提示符:

scott@ORCL10G 2023-02-18 18:59:36> prompt foway>
foway>

7.定义变量提示符

scott@ORCL10G 2023-02-18 19:01:57> acc vi number
20

8.保存脚本

scott@ORCL10G 2023-02-18 19:02:40> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:02:45> save /tmp/s1.sql
Created file /tmp/s1.sql

9.运行缓冲区语句

run,r,/执行上次运行的sql语句

10.获取脚本到buf中,不执行

[oracle@yuanzj.com:/home/oracle]$ scott 

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Feb 18 19:05:05 2023

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options

scott@ORCL10G 2023-02-18 19:05:05> l
  1* ALTER SESSION SET nls_date_format = 'yyyy-mm-dd HH24:MI:SS'
scott@ORCL10G 2023-02-18 19:05:06> get /tmp/s1.sql
  1* select * from emp
scott@ORCL10G 2023-02-18 19:05:15> l
  1* select * from emp

11.读入文件中的sql到buf中并执行

scott@ORCL10G 2023-02-18 19:06:08> start /tmp/s1.sql

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

12.查看buf中的语句

scott@ORCL10G 2023-02-18 19:06:15> l
  1* select * from emp

13.删除buf中的sql语句

scott@ORCL10G 2023-02-18 19:06:52> del
scott@ORCL10G 2023-02-18 19:07:19> l
SP2-0223: No lines in SQL buffer.

14.移除buf中的语句

scott@ORCL10G 2023-02-18 19:07:20> start /tmp/s1.sql

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:07:53> l
  1* select * from emp
scott@ORCL10G 2023-02-18 19:07:56> cl buff
buffer cleared
scott@ORCL10G 2023-02-18 19:08:00> l
SP2-0223: No lines in SQL buffer.

15.清屏

scott@ORCL10G 2023-02-18 19:08:02> cl scr

scott@ORCL10G 2023-02-18 19:08:28> 

16.替换sql语句中的字符

--先输入行数
--再输入c/old_value/new_value
--更改第一次出现的值
scott@ORCL10G 2023-02-18 19:10:20> select empno,
  2  ename
  3  from emp;

     EMPNO ENAME
---------- ----------
      7369 SMITH
      7499 ALLEN
      7521 WARD
      7566 JONES
      7654 MARTIN
      7698 BLAKE
      7782 CLARK
      7788 SCOTT
      7839 KING
      7844 TURNER
      7876 ADAMS
      7900 JAMES
      7902 FORD
      7934 MILLER

14 rows selected.

Elapsed: 00:00:00.01
scott@ORCL10G 2023-02-18 19:10:38> l  --英文单词l
  1  select empno,
  2  ename
  3* from emp
scott@ORCL10G 2023-02-18 19:10:39> 1  --数字1
  1* select empno,
scott@ORCL10G 2023-02-18 19:10:57> c/empno/job
  1* select job,
scott@ORCL10G 2023-02-18 19:11:08> l  --英文单词l
  1  select job,
  2  ename
  3* from emp
scott@ORCL10G 2023-02-18 19:11:11> r
  1  select job,
  2  ename
  3* from emp

JOB	  ENAME
--------- ----------
CLERK	  SMITH
SALESMAN  ALLEN
SALESMAN  WARD
MANAGER   JONES
SALESMAN  MARTIN
MANAGER   BLAKE
MANAGER   CLARK
ANALYST   SCOTT
PRESIDENT KING
SALESMAN  TURNER
CLERK	  ADAMS
CLERK	  JAMES
ANALYST   FORD
CLERK	  MILLER

14 rows selected.

Elapsed: 00:00:00.00

17. 当前行下增加新内容

scott@ORCL10G 2023-02-18 19:11:11> r
  1  select job,
  2  ename
  3* from emp

JOB	  ENAME
--------- ----------
CLERK	  SMITH
SALESMAN  ALLEN
SALESMAN  WARD
MANAGER   JONES
SALESMAN  MARTIN
MANAGER   BLAKE
MANAGER   CLARK
ANALYST   SCOTT
PRESIDENT KING
SALESMAN  TURNER
CLERK	  ADAMS
CLERK	  JAMES
ANALYST   FORD
CLERK	  MILLER

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:11:12> 1 --数字1
  1* select job,
scott@ORCL10G 2023-02-18 19:14:47> i empno,
scott@ORCL10G 2023-02-18 19:15:09> l --英文单词1
  1  select job,
  2  empno,
  3  ename
  4* from emp

18.当前行尾增加内容

scott@ORCL10G 2023-02-18 19:15:11> 2
  2* empno,
scott@ORCL10G 2023-02-18 19:16:19> a HIREDATE,
  2* empno,HIREDATE,
scott@ORCL10G 2023-02-18 19:16:37> l
  1  select job,
  2  empno,HIREDATE,
  3  ename
  4* from emp

19.调用系统命令

scott@ORCL10G 2023-02-18 19:17:42> ! df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        91G  9.3G   77G  11% /
tmpfs           1.9G  371M  1.6G  20% /dev/shm
/dev/sda1       190M   36M  145M  20% /boot
/dev/sdb1       140G  3.0G  130G   3% /oradata
/dev/sdb2        60G   52M   57G   1% /backup
.host:/         932G  280G  653G  31% /mnt/hgfs

scott@ORCL10G 2023-02-18 19:17:46> ho df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        91G  9.3G   77G  11% /
tmpfs           1.9G  371M  1.6G  20% /dev/shm
/dev/sda1       190M   36M  145M  20% /boot
/dev/sdb1       140G  3.0G  130G   3% /oradata
/dev/sdb2        60G   52M   57G   1% /backup
.host:/         932G  280G  653G  31% /mnt/hgfs

20.变量

#1.define
#2.undefine
#3.var[iable]
&
&&

21.set 参数值

scott@ORCL10G 2023-02-18 19:20:35> set heading on
scott@ORCL10G 2023-02-18 19:20:45> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:20:51> set heading off
scott@ORCL10G 2023-02-18 19:21:04> select * from emp;

      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:21:34> set feedback on
scott@ORCL10G 2023-02-18 19:21:44> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:21:47> set feedback off
scott@ORCL10G 2023-02-18 19:21:50> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10
Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:22:39> set pagesize 0
scott@ORCL10G 2023-02-18 19:22:48> select * from emp;
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:22:53> set pagesize 1000
scott@ORCL10G 2023-02-18 19:23:01> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.01
scott@ORCL10G 2023-02-18 19:23:57> set linesize 100
scott@ORCL10G 2023-02-18 19:24:04> select * from emp;

     EMPNO ENAME      JOB	       MGR HIREDATE		      SAL	COMM	 DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
      7369 SMITH      CLERK	      7902 1980-12-17 00:00:00	      800		     20
      7499 ALLEN      SALESMAN	      7698 1981-02-20 00:00:00	     1600	 300	     30
      7521 WARD       SALESMAN	      7698 1981-02-22 00:00:00	     1250	 500	     30
      7566 JONES      MANAGER	      7839 1981-04-02 00:00:00	     2975		     20
      7654 MARTIN     SALESMAN	      7698 1981-09-28 00:00:00	     1250	1400	     30
      7698 BLAKE      MANAGER	      7839 1981-05-01 00:00:00	     2850		     30
      7782 CLARK      MANAGER	      7839 1981-06-09 00:00:00	     2450		     10
      7788 SCOTT      ANALYST	      7566 1987-04-19 00:00:00	     3000		     20
      7839 KING       PRESIDENT 	   1981-11-17 00:00:00	     5000		     10
      7844 TURNER     SALESMAN	      7698 1981-09-08 00:00:00	     1500	   0	     30
      7876 ADAMS      CLERK	      7788 1987-05-23 00:00:00	     1100		     20
      7900 JAMES      CLERK	      7698 1981-12-03 00:00:00	      950		     30
      7902 FORD       ANALYST	      7566 1981-12-03 00:00:00	     3000		     20
      7934 MILLER     CLERK	      7782 1982-01-23 00:00:00	     1300		     10

14 rows selected.

Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:24:06> set linesize 1
scott@ORCL10G 2023-02-18 19:24:11> select * from emp;
SP2-0253: data item 1 ("EMPNO") will not fit on line
Elapsed: 00:00:00.00
scott@ORCL10G 2023-02-18 19:24:13> set linesize 50
scott@ORCL10G 2023-02-18 19:24:25> select * from emp;

     EMPNO ENAME      JOB	       MGR
---------- ---------- --------- ----------
HIREDATE		   SAL	     COMM
------------------- ---------- ----------
    DEPTNO
----------
      7369 SMITH      CLERK	      7902
1980-12-17 00:00:00	   800
	20

      7499 ALLEN      SALESMAN	      7698
1981-02-20 00:00:00	  1600	      300
	30

      7521 WARD       SALESMAN	      7698
1981-02-22 00:00:00	  1250	      500
	30

      7566 JONES      MANAGER	      7839
1981-04-02 00:00:00	  2975
	20

      7654 MARTIN     SALESMAN	      7698
1981-09-28 00:00:00	  1250	     1400
	30

      7698 BLAKE      MANAGER	      7839
1981-05-01 00:00:00	  2850
	30

      7782 CLARK      MANAGER	      7839
1981-06-09 00:00:00	  2450
	10

      7788 SCOTT      ANALYST	      7566
1987-04-19 00:00:00	  3000
	20

      7839 KING       PRESIDENT
1981-11-17 00:00:00	  5000
	10

      7844 TURNER     SALESMAN	      7698
1981-09-08 00:00:00	  1500		0
	30

      7876 ADAMS      CLERK	      7788
1987-05-23 00:00:00	  1100
	20

      7900 JAMES      CLERK	      7698
1981-12-03 00:00:00	   950
	30

      7902 FORD       ANALYST	      7566
1981-12-03 00:00:00	  3000
	20

      7934 MILLER     CLERK	      7782
1982-01-23 00:00:00	  1300
	10


14 rows selected.

Elapsed: 00:00:00.00

 

posted @ 2023-02-18 17:23  竹蜻蜓vYv  阅读(46)  评论(0编辑  收藏  举报