联系邮箱:cloud_data@163.com

博客小站:

1、切换到oracle用户,登陆到数据库

[root@localhost Desktop]# su - oracle    # 切换到oracle用户[oracle@localhost ~]$ sqlplus  / as sysdba        # 以dba身份登录到数据库SQL*Plus: Release 11.2.0.1.0 Production on Sat Jun 22 19:51:58 2013Copyright (c) 1982, 2009, Oracle.  All rights reserved.Connected to an idle instance.     #  这里表明,数据库还未启动,需要启动数据库

2、启动数据库

SYS> startup    # 启动数据库ORACLE instance started.   #  实例启动Total System Global Area  795127808 bytes     # 分配内存等操作Fixed Size    1339456 bytesVariable Size  503320512 bytesDatabase Buffers  285212672 bytesRedo Buffers    5255168 bytesDatabase mounted.    #  数据库挂载Database opened.     #  数据库打开

3、打开数据库,有哪些命令,如何操作呢!下面就是命令索引

SYS> 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     SHOWSYS> help shutdown    #  这里以shutdown为列,查看命令帮助 SHUTDOWN -------- Shuts down a currently running Oracle Database instance, optionally closing and dismounting a database. SHUTDOWN [ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL [LOCAL]]

4、查看相关用户是否被锁,以及如何解锁

SYS> desc dba_users;    # 所有账户信息存在这张表中,可用desc查看表结构SYS> select USERNAME,ACCOUNT_STATUS from dba_users;  # 查看用户名和状态......SYS> alter user SCOTT identified by tiger account unlock;  # 解锁用户,设置密码User altered.

5、测试用户是否可用

SYS> conn scott/tiger   # 用conn来切换用户Connected.SCOTT> show user;    # 现在当前是哪个用户USER is "SCOTT"

6、查看当前用户下,有哪些表

SCOTT> select * from tab;    # 存在tab表中

7、重复执行上一条命令,用run 或 /

SCOTT> run

8、将命令报错到一个文件,默认只能保存1条

SCOTT> save 2.sql  # 用save命令保存Created file 2.sqlSCOTT> @2.sql  # 调用文件用 @

9、显然只保存1条命令无法满足需求,下面是多条:spool

SCOTT> spool 3.txt   #  打开,并保存到指定文件SCOTT> select * from tab;   #  执行几条查询语句SCOTT> select * from emp;SCOTT> spool off   # 关闭spool

10、查看文件,并查看内容

SCOTT> host ls   # 调用系统命令:用host,默认保存文件,都存放在当前目录1.sql  2.sql  3.txt  afiedt.buf  db.rspSCOTT> host cat 2.sql  # 查看内容

11、断开连接,用disc

SCOTT> discDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing option

12、关闭数据库:shutdown

> conn / as sysdba  # 以dba用户身份登录Connected.SYS> shutdown immediate;  # 立即关闭数据库,没有commit的回滚Database closed.Database dismounted.ORACLE instance shut down.

个人博客小站刚刚建立,期待各位多多光顾,博文如有错误,请各位多多包涵,并及时与我联系

联系邮箱:cloud_data@163.com

博客小站: