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相关推荐

  1. oracle 27504,ORACLE ORA-27504 ORA-27300 ORA-27301 ORA-27302 ORA-27303 问题处理

    环境: oracle + 10.2.0.4 rac 变成单机 make -f ins_rdbms.mk rac_off ioracle   --这个是关键点[oracle@RAC1 ~]$ sqlpl ...

  2. Linux下docker安装配置oracle,oracle创建用户并远程连接,实测可用!

    最近在给同学弄毕业设计的数据库,因为oracle在个人电脑上极不稳定,所以他的电脑数据库崩溃了,这时候我就在docker上为他拉了一个oracle,解决了问题. docker的安装共有以下几步,实测没 ...

  3. oracle自动化,Oracle 自动化备份脚本

    备份脚本,基于linux,windows环境需要适当修改. 主脚本,会调用2,3步骤的rman.sql&status.sql $ more main.sh #set env ######### ...

  4. it oracle 培训,Oracle数据库技术培训_OracleDBA数据库工程师_Oracle数据库在线学习视频教程_IT职业培训-51CTO学院_精培学院...

    第一阶段:企业级Oracle数据库实战入门与集群实施 特色:本阶段部分内容为OCP/OCM课程内容,以企业实战项目为主导讲解,实用性更强. 第1章 Oracle数据库高级工程师职业发展与学习方法 第2 ...

  5. 【oracle】oracle经典sql,exception,database link纠错

    [oracle]oracle经典sql,exception,database link纠错 1111-01 oracle经典sql,exception,database link纠错 1.给表tabl ...

  6. oracle v$system_event,45.Oracle杂记——Oracle常用动态视图v$system_event

    45.Oracle杂记--Oracle常用动态视图v$system_event 视图v$system_event 显示一个事件的总共等待. 如果不支持计时机制,那么TIME_WAITED和AVERAG ...

  7. oracle 202,Oracle Certification 1Z0-202题库

    Oracle Other Oracle Certification 1Z0-202 考题名称:Siebel 8 Consultant Exam 版本号:V2.40 更新时间:2011-09-14 考题 ...

  8. oracle安装就是home3,rhel3上安装Oracle(来自Oracle网站)

    http://www.oracle.com/technology/global/cn/pub/articles/smiley_10gdb_install.html 1.从网上下载redhat Ente ...

  9. php对应哪个oracle版本,Oracle 版本说明

    Oracle 的版本号很多,先看11g的一个版本号说明: 注意: 在Oracle 9.2 版本之后, oracle 的maintenance release number 是在 Oracle的版本号很 ...

最新文章

  1. Git复习(十)之常见报错和疑问
  2. 银行利率是5.45%,房贷是4.9%,有钱该提前还房贷还是存款?
  3. 干货分享!DevExpressv16.2最新版演示示例等你来收!(上)
  4. YOLOv4改进版重磅问世!Yolov4扩展版!Yolov4原班人马重磅推出Scaled-YOLOv4: Scaling Cross Stage Partial Network
  5. 那些在大厂做外包的测试工程师,后来发展怎么样了?
  6. 3月7日学习内容整理:restframework的解析器组件
  7. Easy-rules使用介绍
  8. oracle归档文件管理
  9. 拓端tecdat|R语言分位数回归预测筛选有上升潜力的股票
  10. 计算机应用基础专科在线考试,电子科技大学在线考试2019年春计算机应用基础专科(18页)-原创力文档...
  11. 接口文档模板,接口规范
  12. 微信图片怎么添加竖排文字_微信字体竖排怎么设置 微信怎样编辑竖排文字
  13. 双引号在python中什么意思_Python中单引号和双引号的作用
  14. layuiadmin配置mysql_layuiAdmin 后台管理模板
  15. u盘win7纯净版_如何制作纯净版WIN7启动U盘
  16. Linux内存管理(二):页面查询过程简述
  17. 算力网络发展中的若干关键技术问题分析
  18. Sigar获取网卡流量信息
  19. 公司董事长——50w年薪程序员从顶端到谷底,我是这样走过来的!
  20. Outlook 2010 电子邮件数字签名和加密指南

热门文章

  1. orcle抽数据到mysql_抽取oracle数据到mysql数据库的实现过程
  2. 1.7-06编程基础之字符串 字符翻转
  3. Java黑皮书课后题第5章:**5.32(游戏:彩票)修改程序清单3-8,产生一个两位数的彩票。这两位数是不同的
  4. linux下 命令 实验,实验一:Linux命令实验
  5. whiel oracle,Oracle中的for和while循环
  6. 从华为“鸿蒙”备胎看IT项目建设
  7. ImCash:币圈英文术语大全
  8. javascript中的replace方法
  9. Random方法:生成指定长度的随机数字
  10. win7 64+python2.7.12安装numpy+scipy+matplotlib+scikit-learn