一聚教程网:一个值得你收藏的教程网站

最新下载

oracle安装成功之后检查简单命令

时间:2016-07-10 00:00:00 编辑:简简单单 来源:原创

此篇文章来看下如果进入oracle的数据库.
[oracle@oracle01 tools]$ ps -elf | grep ora_ | grep orcl   #查看进程
0 S oracle    12438      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_pmon_orcl
0 S oracle    12440      1  0  80   0 - 185418 semtim 12:50 ?       00:00:01 ora_psp0_orcl
0 S oracle    12442      1  1  58   - - 185418 hrtime 12:50 ?       00:01:24 ora_vktm_orcl
0 S oracle    12446      1  0  80   0 - 185845 semtim 12:50 ?       00:00:00 ora_gen0_orcl
0 S oracle    12448      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_mman_orcl
0 S oracle    12452      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_diag_orcl
0 S oracle    12454      1  0  80   0 - 186666 semtim 12:50 ?       00:00:01 ora_dbrm_orcl
0 S oracle    12456      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_vkrm_orcl
0 S oracle    12458      1  0  80   0 - 186058 semtim 12:50 ?       00:00:04 ora_dia0_orcl
0 S oracle    12460      1  0  80   0 - 188392 semtim 12:50 ?       00:00:01 ora_dbw0_orcl
0 S oracle    12462      1  0  80   0 - 186745 semtim 12:50 ?       00:00:01 ora_lgwr_orcl
0 S oracle    12464      1  0  80   0 - 186489 semtim 12:50 ?       00:00:05 ora_ckpt_orcl
0 S oracle    12466      1  0  80   0 - 186413 semtim 12:50 ?       00:00:00 ora_smon_orcl
0 S oracle    12468      1  0  80   0 - 186674 semtim 12:50 ?       00:00:00 ora_reco_orcl
0 S oracle    12470      1  0  80   0 - 186332 ep_pol 12:50 ?       00:00:00 ora_lreg_orcl
0 S oracle    12472      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_pxmn_orcl
0 S oracle    12474      1  0  80   0 - 186206 semtim 12:50 ?       00:00:00 ora_rbal_orcl
0 S oracle    12476      1  0  80   0 - 186364 pipe_w 12:50 ?       00:00:00 ora_asmb_orcl
0 S oracle    12478      1  0  80   0 - 187523 semtim 12:50 ?       00:00:09 ora_mmon_orcl
0 S oracle    12482      1  0  80   0 - 185880 semtim 12:50 ?       00:00:04 ora_mmnl_orcl
0 S oracle    12484      1  0  80   0 - 187179 ep_pol 12:50 ?       00:00:00 ora_d000_orcl
0 S oracle    12486      1  0  80   0 - 200484 semtim 12:50 ?       00:00:00 ora_mark_orcl
0 S oracle    12488      1  0  80   0 - 185947 ep_pol 12:50 ?       00:00:00 ora_s000_orcl
0 S oracle    12516      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_tmon_orcl
0 S oracle    12518      1  0  80   0 - 185417 hrtime 12:50 ?       00:00:00 ora_tt00_orcl
0 S oracle    12520      1  0  80   0 - 185418 semtim 12:50 ?       00:00:00 ora_smco_orcl
0 S oracle    12522      1  0  80   0 - 187305 semtim 12:50 ?       00:00:00 ora_w000_orcl
0 S oracle    12524      1  0  80   0 - 189511 semtim 12:50 ?       00:00:01 ora_w001_orcl
0 S oracle    12526      1  0  80   0 - 186504 semtim 12:50 ?       00:00:00 ora_aqpc_orcl
0 S oracle    12530      1  0  80   0 - 185417 semtim 12:50 ?       00:00:00 ora_p000_orcl
0 S oracle    12532      1  0  80   0 - 185417 semtim 12:50 ?       00:00:00 ora_p001_orcl
0 S oracle    12534      1  0  80   0 - 185417 semtim 12:50 ?       00:00:00 ora_p002_orcl
0 S oracle    12536      1  0  80   0 - 185417 semtim 12:50 ?       00:00:00 ora_p003_orcl
0 S oracle    12541      1  0  80   0 - 188335 semtim 12:50 ?       00:00:02 ora_cjq0_orcl
0 S oracle    12552      1  0  80   0 - 185890 semtim 12:50 ?       00:00:00 ora_qm02_orcl
0 S oracle    12556      1  0  80   0 - 186797 semtim 12:50 ?       00:00:00 ora_q002_orcl
0 S oracle    12558      1  0  80   0 - 185918 semtim 12:50 ?       00:00:00 ora_q003_orcl
0 S oracle    12916      1  0  80   0 - 186506 semtim 13:06 ?       00:00:00 ora_w002_orcl
0 S oracle    12922      1  0  80   0 - 186416 semtim 13:06 ?       00:00:00 ora_w003_orcl
0 S oracle    12924      1  0  80   0 - 185547 semtim 13:06 ?       00:00:00 ora_w004_orcl
0 S oracle    13646      1  0  80   0 - 185999 semtim 13:50 ?       00:00:03 ora_o000_orcl
0 S oracle    13899      1  0  80   0 - 185545 semtim 14:05 ?       00:00:00 ora_w005_orcl
0 S oracle    13908      1  0  80   0 - 185417 semtim 14:05 ?       00:00:00 ora_w006_orcl
 
[oracle@oracle01 tools]$ export ORACLE_SID=orcl    #设置默认登录库
[oracle@oracle01 tools]$ which sqlplus
/data/app/oracle/product/12.1.0/dbhome_1/bin/sqlplus

进入oracle数据库:

Oracle PL/SQL

[oracle@oracle01 tools]$ sqlplus / as sysdba    #本地oracle用户验证方式,不需要密码
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 2 14:31:06 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
SQL> conn hr/hr 
ERROR:
ORA-28000: the account is locked
Warning: You are no longer connected to ORACLE.
SQL> alter user hr account unlock;    #解锁hr账号
SP2-0640: Not connected
SQL> show user;
USER is ""    #黑洞
SQL> alter user hr account unlock;    #解锁hr账号
User altered.
SQL> alter user hr indentified by hr;
alter user hr indentified by hr
              *
ERROR at line 1:
ORA-00922: missing or invalid option
SQL> alter user hr identified by hr;    #修改hr密码为hr
User altered.
SQL> conn hr/hr
Connected.
SQL> show user;
USER is "HR"
SQL> conn / as sysdba
Connected.
SQL> show user;
USER is "SYS"
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> help index    #命令帮助
 
Enter Help [topic] for help.
 
 @             COPY         PAUSE                    SHUTDOWN
 @@            DEFINE       PRINT                    SPOOL
 /             DEL          PROMPT                   SQLPLUS
 ACCEPT        DESCRIBE     QUIT                     START
 APPEND        DISCONNECT   RECOVER                  STARTUP
 ARCHIVE LOG   EDIT         REMARK                   STORE
 ATTRIBUTE     EXECUTE      REPFOOTER                TIMING
 BREAK         EXIT         REPHEADER                TTITLE
 BTITLE        GET          RESERVED WORDS (SQL)     UNDEFINE
 CHANGE        HELP         RESERVED WORDS (PL/SQL)  VARIABLE
 CLEAR         HOST         RUN                      WHENEVER OSERROR
 COLUMN        INPUT        SAVE                     WHENEVER SQLERROR
 COMPUTE       LIST         SET                      XQUERY
 CONNECT       PASSWORD     SHOW
 
SQL> conn scott/admin123
Connected.
SQL> show user;
USER is "SCOTT"
SQL> select * from scott.dept'
  2  ;
ERROR:
ORA-01756: quoted string not properly terminated
 
SQL> select * from scott.dept;
 
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
SQL> list    #上个命令
  1* select * from scott.dept
SQL> l    #list简写
  1* select * from scott.dept
SQL> /    #执行上个命令
 
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
 
SQL> ? list
 
 LIST
 ----
 
 Lists one or more lines of the most recently executed SQL command
 or PL/SQL block which is stored in the SQL buffer. Enter LIST with
 no clauses to list all lines. In SQL*Plus command-line you can also
 use ";" to list all the lines in the SQL buffer. The buffer has no
 command history list and does not record SQL*Plus commands.
 
 L[IST] [n | n m | n  * | n LAST | * | * n | * LAST | LAST]
 
SQL> define _editor=vi
SQL> ed
SQL> ed 
Wrote file afiedt.buf
 
  1  select * from scott.emp
  2* where ename='SCOTT'
SQL> /
 
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
---------- ---------- --------- ---------- --------- ---------- ----------
    DEPTNO
----------
      7788 SCOTT      ANALYST         7566 19-APR-87       3000
        20
SQL> select * from scott.emp;
SQL> save /tmp/2016.07.02.sql
Created file /tmp/2016.07.02.sql
SQL> host
[oracle@oracle01 tools]$ cat /tmp/2016.07.02.sql
select * from scott.emp
/
[oracle@oracle01 tools]$ quti
bash: quti: command not found
[oracle@oracle01 tools]$ exit
exit
SQL> host pwd
/byrd/tools
SQL> @ /tmp/2016.07.02.sql    #远程脚本调用
SQL> get /tmp/2016.07.02.sql
  1* select * from scott.emp
SQL> spool /tmp/oracle.log    #日志记录
SQL> select * from scott.dept;
SQL> spool off   #结束
SQL> host cat /tmp/oracle.log
SQL> shutdown immediate;
ORA-01031: insufficient privileges
SQL> show user; 
USER is "SCOTT"
SQL> conn / as sysdba
Connected.
SQL> show user;
USER is "SYS"
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> show users;
SP2-0158: unknown SHOW option "users"
 
 
[grid@oracle01 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details      
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       oracle01                 STABLE
ora.FRA.dg
               ONLINE  ONLINE       oracle01                 STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle01                 STABLE
ora.LISTERER2.lsnr
               ONLINE  OFFLINE      oracle01                 STABLE
ora.asm
               ONLINE  ONLINE       oracle01                 Started,STABLE
ora.ons
               OFFLINE OFFLINE      oracle01                 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       oracle01                 STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       oracle01                 STABLE
ora.orcl.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------
SQL> startup
ORACLE instance started.
 
Total System Global Area  402653184 bytes
Fixed Size                  2924928 bytes
Variable Size             260050560 bytes
Database Buffers          134217728 bytes
Redo Buffers                5459968 bytes
Database mounted.
Database opened.
[grid@oracle01 ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 02-JUL-2016 19:52:41
 
Copyright (c) 1991, 2014, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                02-JUL-2016 10:13:16
Uptime                    0 days 9 hr. 39 min. 25 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/app/grid/product/12.1.0/grid/network/admin/listener.ora
Listener Log File         /data/app/grid/diag/tnslsnr/oracle01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle01.db.hangzhou.t4x.org)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=oracle01.db.hangzhou.t4x.org)(PORT=5500))(Security=(my_wallet_directory=/data/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "orcl.t4x.org" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.t4x.org" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle01 tools]$ netca
 
Oracle Net Services Configuration:
Stopping Oracle Net Listener:
    Listener stopped successfully.
    Deleted listener: LISTERER2
Oracle Net Services configuration successful. The exit code is 0

文章评论

热门栏目