日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle notes,Oracle Notes

發布時間:2024/4/19 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle notes,Oracle Notes 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.Oracle匹配

#匹配第一個字母帶'A'的ENAME

SQL> show user;

USER is "SCOTT"

SQL> select * from emp where ename like 'A%';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7876 ADAMS CLERK 7788 23-MAY-87 1100 20

#匹配第二個字母帶'O'的ENAME

SQL> select * from emp where ename like '_O%';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7566 JONES MANAGER 7839 02-APR-81 2975 20

7902 FORD ANALYST 7566 03-DEC-81 3000 20

#匹配第三個字母帶'N'的ENAME

SQL> select * from emp where ename like '__N%';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7566 JONES MANAGER 7839 02-APR-81 2975 20

7839 KING PRESIDENT 17-NOV-81 5000 10

#匹配第四個字母帶'G'的ENAME

SQL> select * from emp where ename like '___G%';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7839 KING PRESIDENT 17-NOV-81 5000 10

2.Oracle轉義

SQL> update emp set ename='X_SCOTT' where ename='SCOTT';

1 row updated.

#匹配第二個字符帶'_'的ENAME,結果和執行select * from emp;是一樣的,匹配不到'_',需要對'_'進行轉義。

SQL> select * from emp where ename like '__%';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7369 SMITH CLERK 7902 17-DEC-80 800 20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7788 X_SCOTT ANALYST 7566 19-APR-87 3000 20

7839 KING PRESIDENT 17-NOV-81 5000 10

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7876 ADAMS CLERK 7788 23-MAY-87 1100 20

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7900 JAMES CLERK 7698 03-DEC-81 950 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7369 SMITH CLERK 7902 17-DEC-80 800 20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7788 X_SCOTT ANALYST 7566 19-APR-87 3000 20

7839 KING PRESIDENT 17-NOV-81 5000 10

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7876 ADAMS CLERK 7788 23-MAY-87 1100 20

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7900 JAMES CLERK 7698 03-DEC-81 950 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

#定義'\'為轉義符號

SQL> select * from emp where ename like '_\_%' escape '\';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7788 X_SCOTT ANALYST 7566 19-APR-87 3000 20

#定義'空格'為轉義符號

SQL> select * from emp where ename like '_ _%' escape ' ';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7788 X_SCOTT ANALYST 7566 19-APR-87 3000 20

#定義'a'為轉義符號

SQL> select * from emp where ename like '_a_%' escape 'a';

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7788 X_SCOTT ANALYST 7566 19-APR-87 3000 20

SQL>

3.設置Oracle開機啟動

[oracle@localhost Desktop]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 5 23:39:06 2018

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

Connected to an idle instance.

SQL> select status from v$instance

2 ;

select status from v$instance

*

ERROR at line 1:

ORA-01034: ORACLE not available

Process ID: 0

Session ID: 0 Serial number: 0

#Oracle默認是不啟動的,此時查詢Oracle狀態會報錯。

SQL> Disconnected

[oracle@localhost Desktop]$ su -

Password:

[root@localhost ~]# vim /etc/oratab

[root@localhost ~]# cat /etc/oratab

# $ORACLE_SID:$ORACLE_HOME::

# to the dbstart utility that the database should , "Y", or should not,

# "N", be brought up at system boot time.

orcl:/oracle/app/oracle/product/11.2.0/db_1:Y

[root@localhost ~]# vim /etc/rc.local

[root@localhost ~]# cat /etc/rc.local

#!/bin/sh

touch /var/lock/subsys/local

su - oracle '-c dbstart $ORACLE_HOME'

[root@localhost ~]#

重啟操作系統后測試:

[oracle@localhost Desktop]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 5 23:50:19 2018

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select status from v$instance;

STATUS

------------

OPEN

#Oracle已處于啟動狀態

SQL>

4.如何判斷Oracle是否啟動?

常規方法:

[oracle@localhost ~]$ netstat -anpl | grep 1521

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

tcp 0 0 :::1521 :::* LISTEN 2768/tnslsnr

tcp 0 0 ::1:12265 ::1:1521 ESTABLISHED 15679/ora_pmon_orcl

tcp 0 0 ::1:1521 ::1:12265 ESTABLISHED 2768/tnslsnr

#查看Oracle默認端口狀態,看到ESTABLISHED說明Oracle已經啟動。

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 6 03:55:49 2018

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select status from v$instance;

#直接登錄進來用命令查看Oracle狀態,看到OPEN說明Oracle已經啟動。

STATUS

------------

OPEN

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@localhost ~]$ netstat -anpl | grep 1521

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

tcp 0 0 :::1521 :::* LISTEN 2768/tnslsnr

tcp 0 0 ::1:12265 ::1:1521 TIME_WAIT -

利用進程查看,比較繁瑣,不推薦:

[oracle@localhost ~]$ ps -ef | grep oracle

oracle 2768 1 0 Jun05 ? 00:00:00 /oracle/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit

oracle 3299 1 0 Jun05 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login

oracle 3309 3266 0 Jun05 ? 00:00:00 gnome-session

oracle 3317 1 0 Jun05 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session

oracle 3318 1 0 Jun05 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session

oracle 3392 1 0 Jun05 ? 00:00:00 /usr/libexec/gconfd-2

oracle 3399 1 0 Jun05 ? 00:00:01 /usr/libexec/gnome-settings-daemon

oracle 3404 1 0 Jun05 ? 00:00:00 seahorse-daemon

oracle 3407 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd

oracle 3413 3309 0 Jun05 ? 00:00:01 metacity

oracle 3417 1 0 Jun05 ? 00:00:01 /usr/bin/pulseaudio --start --log-target=syslog

oracle 3418 3309 0 Jun05 ? 00:00:00 gnome-panel

oracle 3432 3417 0 Jun05 ? 00:00:00 /usr/libexec/pulse/gconf-helper

oracle 3433 3309 0 Jun05 ? 00:00:01 nautilus

oracle 3435 1 0 Jun05 ? 00:00:00 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=18

oracle 3442 1 0 Jun05 ? 00:00:00 /usr/libexec/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-fd=18

oracle 3443 1 0 Jun05 ? 00:00:00 /usr/libexec/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory --oaf-ior-fd=24

oracle 3445 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-gdu-volume-monitor

oracle 3451 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0

oracle 3457 3309 0 Jun05 ? 00:00:00 python /usr/share/system-config-printer/applet.py

oracle 3458 1 0 Jun05 ? 00:00:11 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr --blockFd 3

oracle 3474 3309 0 Jun05 ? 00:00:00 gnome-power-manager

oracle 3478 3309 0 Jun05 ? 00:00:00 abrt-applet

oracle 3486 3309 0 Jun05 ? 00:00:00 /usr/libexec/gdu-notification-daemon

oracle 3492 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor

oracle 3503 3309 0 Jun05 ? 00:00:00 gnome-volume-control-applet

oracle 3505 3309 0 Jun05 ? 00:00:00 rhsm-icon

oracle 3507 3309 0 Jun05 ? 00:00:00 nm-applet --sm-disable

oracle 3509 1 0 Jun05 ? 00:00:00 /usr/libexec/im-settings-daemon

oracle 3510 3309 0 Jun05 ? 00:00:00 /usr/sbin/restorecond -u

oracle 3512 3309 0 Jun05 ? 00:00:00 bluetooth-applet

oracle 3513 3309 0 Jun05 ? 00:00:00 /usr/libexec/polkit-gnome-authentication-agent-1

oracle 3514 3309 0 Jun05 ? 00:00:00 gpk-update-icon

oracle 3529 1 0 Jun05 ? 00:00:01 gnome-screensaver

oracle 3536 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor

oracle 3674 1 0 Jun05 ? 00:00:00 /usr/libexec/gconf-im-settings-daemon

oracle 3681 1 0 Jun05 ? 00:00:00 /usr/bin/gnote --panel-applet --oaf-activate-iid=OAFIID:GnoteApplet_Factory --oaf-ior-fd=19

oracle 3683 1 0 Jun05 ? 00:00:00 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationAreaApplet_Factory --oaf-ior-fd=28

oracle 3686 1 0 Jun05 ? 00:00:00 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=34

oracle 3687 1 0 Jun05 ? 00:00:00 /usr/libexec/gdm-user-switch-applet --oaf-activate-iid=OAFIID:GNOME_FastUserSwitchApplet_Factory --oaf-ior-fd=40

oracle 3702 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1

oracle 3713 1 0 Jun05 ? 00:00:17 /usr/bin/gnome-terminal -x /bin/sh -c cd '/home/oracle/Desktop' && exec $SHELL

oracle 3714 3713 0 Jun05 ? 00:00:00 gnome-pty-helper

oracle 3715 3713 0 Jun05 pts/0 00:00:00 /bin/bash

oracle 3968 1 0 Jun05 ? 00:00:00 /usr/libexec/notification-daemon

oracle 17272 3715 0 04:01 pts/0 00:00:00 ps -ef

oracle 17273 3715 0 04:01 pts/0 00:00:00 grep oracle

#查不到Oracle進程,說明Oracle沒有啟動。

[oracle@localhost ~]$ ps -ef | grep pmon

oracle 17276 3715 0 04:01 pts/0 00:00:00 grep pmon

#查不到Oracle進程,說明Oracle沒有啟動。

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 6 04:01:37 2018

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

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size 2228784 bytes

Variable Size 939527632 bytes

Database Buffers 654311424 bytes

Redo Buffers 7344128 bytes

Database mounted.

Database opened.

SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@localhost ~]$ ps -ef | grep pmon

oracle 17328 1 0 04:01 ? 00:00:00 ora_pmon_orcl_new

oracle 17425 3715 0 04:01 pts/0 00:00:00 grep pmon

#查到Oracle進程,說明Oracle已經啟動。

[oracle@localhost ~]$ ps -ef | grep oracle

oracle 2768 1 0 Jun05 ? 00:00:00 /oracle/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit

oracle 3299 1 0 Jun05 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login

oracle 3309 3266 0 Jun05 ? 00:00:00 gnome-session

oracle 3317 1 0 Jun05 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session

oracle 3318 1 0 Jun05 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session

oracle 3392 1 0 Jun05 ? 00:00:00 /usr/libexec/gconfd-2

oracle 3399 1 0 Jun05 ? 00:00:01 /usr/libexec/gnome-settings-daemon

oracle 3404 1 0 Jun05 ? 00:00:00 seahorse-daemon

oracle 3407 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd

oracle 3413 3309 0 Jun05 ? 00:00:01 metacity

oracle 3417 1 0 Jun05 ? 00:00:01 /usr/bin/pulseaudio --start --log-target=syslog

oracle 3418 3309 0 Jun05 ? 00:00:00 gnome-panel

oracle 3432 3417 0 Jun05 ? 00:00:00 /usr/libexec/pulse/gconf-helper

oracle 3433 3309 0 Jun05 ? 00:00:01 nautilus

oracle 3435 1 0 Jun05 ? 00:00:00 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=18

oracle 3442 1 0 Jun05 ? 00:00:00 /usr/libexec/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-fd=18

oracle 3443 1 0 Jun05 ? 00:00:00 /usr/libexec/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory --oaf-ior-fd=24

oracle 3445 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-gdu-volume-monitor

oracle 3451 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0

oracle 3457 3309 0 Jun05 ? 00:00:00 python /usr/share/system-config-printer/applet.py

oracle 3458 1 0 Jun05 ? 00:00:11 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr --blockFd 3

oracle 3474 3309 0 Jun05 ? 00:00:00 gnome-power-manager

oracle 3478 3309 0 Jun05 ? 00:00:00 abrt-applet

oracle 3486 3309 0 Jun05 ? 00:00:00 /usr/libexec/gdu-notification-daemon

oracle 3492 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor

oracle 3503 3309 0 Jun05 ? 00:00:00 gnome-volume-control-applet

oracle 3505 3309 0 Jun05 ? 00:00:00 rhsm-icon

oracle 3507 3309 0 Jun05 ? 00:00:00 nm-applet --sm-disable

oracle 3509 1 0 Jun05 ? 00:00:00 /usr/libexec/im-settings-daemon

oracle 3510 3309 0 Jun05 ? 00:00:00 /usr/sbin/restorecond -u

oracle 3512 3309 0 Jun05 ? 00:00:00 bluetooth-applet

oracle 3513 3309 0 Jun05 ? 00:00:00 /usr/libexec/polkit-gnome-authentication-agent-1

oracle 3514 3309 0 Jun05 ? 00:00:00 gpk-update-icon

oracle 3529 1 0 Jun05 ? 00:00:01 gnome-screensaver

oracle 3536 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor

oracle 3674 1 0 Jun05 ? 00:00:00 /usr/libexec/gconf-im-settings-daemon

oracle 3681 1 0 Jun05 ? 00:00:00 /usr/bin/gnote --panel-applet --oaf-activate-iid=OAFIID:GnoteApplet_Factory --oaf-ior-fd=19

oracle 3683 1 0 Jun05 ? 00:00:00 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationAreaApplet_Factory --oaf-ior-fd=28

oracle 3686 1 0 Jun05 ? 00:00:00 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=34

oracle 3687 1 0 Jun05 ? 00:00:00 /usr/libexec/gdm-user-switch-applet --oaf-activate-iid=OAFIID:GNOME_FastUserSwitchApplet_Factory --oaf-ior-fd=40

oracle 3702 1 0 Jun05 ? 00:00:00 /usr/libexec/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1

oracle 3713 1 0 Jun05 ? 00:00:18 /usr/bin/gnome-terminal -x /bin/sh -c cd '/home/oracle/Desktop' && exec $SHELL

oracle 3714 3713 0 Jun05 ? 00:00:00 gnome-pty-helper

oracle 3715 3713 0 Jun05 pts/0 00:00:00 /bin/bash

oracle 3968 1 0 Jun05 ? 00:00:00 /usr/libexec/notification-daemon

oracle 17328 1 0 04:01 ? 00:00:00 ora_pmon_orcl_new

oracle 17330 1 0 04:01 ? 00:00:00 ora_psp0_orcl_new

oracle 17332 1 1 04:01 ? 00:00:00 ora_vktm_orcl_new

oracle 17336 1 0 04:01 ? 00:00:00 ora_gen0_orcl_new

oracle 17338 1 0 04:01 ? 00:00:00 ora_diag_orcl_new

oracle 17340 1 0 04:01 ? 00:00:00 ora_dbrm_orcl_new

oracle 17342 1 0 04:01 ? 00:00:00 ora_dia0_orcl_new

oracle 17344 1 1 04:01 ? 00:00:00 ora_mman_orcl_new

oracle 17346 1 0 04:01 ? 00:00:00 ora_dbw0_orcl_new

oracle 17348 1 0 04:01 ? 00:00:00 ora_lgwr_orcl_new

oracle 17350 1 0 04:01 ? 00:00:00 ora_ckpt_orcl_new

oracle 17352 1 0 04:01 ? 00:00:00 ora_smon_orcl_new

oracle 17354 1 0 04:01 ? 00:00:00 ora_reco_orcl_new

oracle 17356 1 0 04:01 ? 00:00:00 ora_mmon_orcl_new

oracle 17358 1 0 04:01 ? 00:00:00 ora_mmnl_orcl_new

oracle 17360 1 0 04:01 ? 00:00:00 ora_d000_orcl_new

oracle 17362 1 0 04:01 ? 00:00:00 ora_s000_orcl_new

oracle 17401 1 0 04:01 ? 00:00:00 ora_qmnc_orcl_new

oracle 17417 1 0 04:01 ? 00:00:00 ora_cjq0_orcl_new

oracle 17419 1 0 04:01 ? 00:00:00 ora_j000_orcl_new

oracle 17421 1 0 04:01 ? 00:00:00 ora_j001_orcl_new

oracle 17423 1 0 04:01 ? 00:00:00 ora_j002_orcl_new

oracle 17427 1 0 04:01 ? 00:00:00 ora_q000_orcl_new

oracle 17429 1 0 04:01 ? 00:00:00 ora_q001_orcl_new

oracle 17451 3715 0 04:02 pts/0 00:00:00 ps -ef

oracle 17452 3715 0 04:02 pts/0 00:00:00 grep oracle

#查到Oracle進程,說明Oracle已經啟動。

[oracle@localhost ~]$

5.設置linesize永久生效

配置:

[oracle@localhost ~]$ cd $ORACLE_HOME/sqlplus/admin

[oracle@localhost admin]$ ls

glogin.sql help libsqlplus.def plustrce.sql pupbld.sql

[oracle@localhost admin]$ vim glogin.sql

[oracle@localhost admin]$ cat glogin.sql

--

-- Copyright (c) 1988, 2011, Oracle and/or its affiliates.

-- All rights reserved.

--

-- NAME

-- glogin.sql

--

-- DESCRIPTION

-- SQL*Plus global login "site profile" file

--

-- Add any SQL*Plus commands here that are to be executed when a

-- user starts SQL*Plus, or uses the SQL*Plus CONNECT command.

--

-- USAGE

-- This script is automatically run

--

set linesize 100

[oracle@localhost admin]$

測試:

[oracle@localhost Desktop]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 7 02:54:49 2018

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select status from v$instance;

STATUS

------------

OPEN

SQL> conn scott/scott

Connected.

SQL> select * from emp;

#執行這條命令時終端寬度一定要足夠,否者顯示的效果可能不是linesize 100

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7369 SMITH CLERK 7902 17-DEC-80 800 20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7788 SCOTT ANALYST 7566 19-APR-87 3000 20

7839 KING PRESIDENT 17-NOV-81 5000 10

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7876 ADAMS CLERK 7788 23-MAY-87 1100 20

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7900 JAMES CLERK 7698 03-DEC-81 950 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

6.drop表和flashback表

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

BONUS TABLE

DEPT TABLE

EMP TABLE

SALGRADE TABLE

SQL> drop table emp;

Table dropped.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

#出現這段代碼,說明表被放到了回收站。

BIN$bgqB/QJjEJHgVQAAAAAAAQ==$0 TABLE

BONUS TABLE

DEPT TABLE

SALGRADE TABLE

SQL> select * from "BIN$bgqB/QJjEJHgVQAAAAAAAQ==$0";

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7369 SMITH CLERK 7902 17-DEC-80 800 20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7788 SCOTT ANALYST 7566 19-APR-87 3000 20

7839 KING PRESIDENT 17-NOV-81 5000 10

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7876 ADAMS CLERK 7788 23-MAY-87 1100 20

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

---------- ---------- --------- ---------- --------- ---------- ---------- ----------

7900 JAMES CLERK 7698 03-DEC-81 950 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

14 rows selected.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

BIN$bgqB/QJjEJHgVQAAAAAAAQ==$0 TABLE

BONUS TABLE

DEPT TABLE

SALGRADE TABLE

SQL> drop table bonus;

Table dropped.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

BIN$bgqB/QJjEJHgVQAAAAAAAQ==$0 TABLE

BIN$bgqB/QJkEJHgVQAAAAAAAQ==$0 TABLE

DEPT TABLE

SALGRADE TABLE

SQL> flashback table emp to before drop;

#還原emp表

Flashback complete.

SQL> flashback table bonus to before drop;

#還原bonus表

Flashback complete.

SQL> select * from tab;

#emp表和bonus表已還原

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

BONUS TABLE

DEPT TABLE

EMP TABLE

SALGRADE TABLE

SQL>

總結

以上是生活随笔為你收集整理的oracle notes,Oracle Notes的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。