1.[oracle@zh888 ~]$ sqlplus /nolog //启动oracle数据库实例

SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 11 00:29:00 2013

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

SQL> conn / as sysdba//作为sysdba登录

Connected to an idle instance.

SQL> startup //启动startup,1、shutdown normal   正常方式关闭数据库。 2、shutdown immediate   立即方式关闭数据库。   在SVRMGRL中执行shutdown immediate,数据库并不立即关闭,   而是在Oracle执行某些清除工作后才关闭(终止会话、释放会话资源),   当使用shutdown不能关闭数据库时,shutdown immediate可以完成数据库关闭的操作。 3、shutdown abort   直接关闭数据库,正在访问数据库的会话会被突然终止,   如果数据库中有大量操作正在执行,这时执行shutdown abort后,重新启动数据库需要很长时间。

ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size             100664912 bytes
Database Buffers          180355072 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.//启动成功

 

2.[oracle@zh888 ~]$ lsnrctl start //启动监听需要一定的时间。

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-MAY-2013 00:30:55

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /usr/local/oracle/product/10201/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /usr/local/oracle/product/10201/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zh888)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                11-MAY-2013 00:30:55
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /usr/local/oracle/product/10201/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zh888)(PORT=1521)))
The listener supports no services
The command completed successfully

 

3.[oracle@zh888 ~]$ lsnrctl status //查看数据监听状态

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 11-MAY-2013 00:31:43

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                11-MAY-2013 00:30:55
Uptime                    0 days 0 hr. 0 min. 48 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /usr/local/oracle/product/10201/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zh888)(PORT=1521)))
Services Summary...
Service "zh888" has 1 instance(s).
  Instance "zh888", status READY, has 1 handler(s) for this service...
Service "zh888XDB" has 1 instance(s).
  Instance "zh888", status READY, has 1 handler(s) for this service...
Service "zh888_XPT" has 1 instance(s).
  Instance "zh888", status READY, has 1 handler(s) for this service...
The command completed successfully //sid zh888实例名启动成功。

 

4.[oracle@zh888 ~]$ emctl start dbconsole//启动oracle em web管理oracle10g界面,登录http://ip:1158/em
TZ set to PRC
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0 
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://oracle.example.com:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 10g Database Control ....

 

5.sqlplus创建表空间和临时表空间

SQL> create tablespace qc_data datafile '/usr/local/oracle/oradata/zh888/qc_data.dbf' size 200m autoextend on next 200m maxsize 1000m extent management local;

Tablespace created. //创建qc_data名字的表,指定oracle数据库文件所在的目录,大小为200m,自动增加空间200m,最大为1000m如果1000m替换为unlimited就是无限制,最后为本地管理。

 

SQL> create temporary tablespace qc_temp tempfile '/usr/local/oracle/oradata/zh888/qc_temp.dbf' size 100m autoextend on next 100m maxsize 2000m extent management local;//创建临时表空间


6.SQL> select username from dba_users; //查看所有oracle用户

QCSITEADMIN_DB
DEFAULT_QC_TEST_DB
MGMT_VIEW
SYS
SYSTEM
DBSNMP
SYSMAN
SCOTT
OUTLN
MDSYS
ORDSYS
CTXSYS
ANONYMOUS

EXFSYS
DMSYS
WMSYS
XDB
ORDPLUGINS
SI_INFORMTN_SCHEMA
OLAPSYS
MDDATA
DIP
TSMSYS

23 rows selected.


7.SQL> select *from v$instance; 查看sid实例名zh888

              1 zh888
zh888
10.2.0.1.0        10-MAY-13 OPEN         NO           1 STOPPED
ALLOWED    NO  ACTIVE            PRIMARY_INSTANCE   NORMAL    NO

 

8.SQL> select *from v$tablespace; //查看实例名zh888所有表空间

         0 SYSTEM                         YES NO  YES
         1 UNDOTBS1                       YES NO  YES
         2 SYSAUX                         YES NO  YES
         4 USERS                          YES NO  YES
         3 TEMP                           NO  NO  YES
         6 QC_DATA                        YES NO  YES
         7 QC_TEMP                        NO  NO  YES


9.SQL> select *from v$controlfile; //查看控制文件。

/usr/local/oracle/oradata/zh888/control01.ctl
NO       16384            430

/usr/local/oracle/oradata/zh888/control02.ctl
NO       16384            430

/usr/local/oracle/oradata/zh888/control03.ctl
NO       16384            430

7 rows selected.

 

10.SQL> show error; //查看是否有错误

 

11.SQL> show user; //查看当前登录的用户
USER is "SYS"


12.SQL> alter user scott account lock; //锁住scott账户。

User altered.

13.SQL> create user zh identified by zh123456; //创建zh用户密码为zh123456

User created.

14.SQL> alter user zh identified by zh123;//修改zh密码或者conn zh/zh123456进入后password修改密码。

User altered.

15.SQL> grant create session,create table to zh; //给zh用户授权

Grant succeeded.

16.SQL> alter user zh default tablespace QC_DATA;//分配qc_data表空间给zh用户

User altered.


17.SQL> grant unlimited tablespace to zh; //授权表空间给用户。
GRANT create any table TO zh;
GRANT resource,dba TO zh;
GRANT select any table TO zh;
第一个是授予所有table有create权限,第三是授予所有table有select权限.
第二个就是赋予DBA的权限,这才是最重要的,其实只要第二就可以了.

Grant succeeded.

18.SQL> conn zh/zh123456; //登录zh用户。
Connected.
SQL> show user;
USER is "ZH"

19.SQL> select name from v$tempfile; //查看临时表空间

NAME
--------------------------------------------------------------------------------
/usr/local/oracle/oradata/zh888/temp01.dbf
/usr/local/oracle/oradata/zh888/qc_temp.dbf

20.删除用户表空间的步骤:
Alter tablespace 表空间名称 offline;
Drop tablespace 表空间名称;(表空间无有数据时用)
或者
drop tablespace 表空间名称 including contents;(表空间下有数据时候用)

temporary tablespace是oracle里临时表空间,临时表空间主要用途是在数据库进行排序运算、管理索引、访问视图等操作时提供临时的运算空间,当运算完成之后系统会自动清理。当oracle里需要用到sort的时候,而pga又没有足够大的时候,将会把数据放入临时表空间里进行排序,同时如果有异常情况的话,也会被放入临时表空间,但是我们需要重建temporary tablespace,直接是不能drop默认的临时表空间的,不过我们可以通过以下方法来做。查看目前的temporary tablespace

21.SQL> select name from v$datafile;//查看数据库表空间存放的路径。


NAME
--------------------------------------------------------------------------------
/usr/local/oracle/oradata/zh888/system01.dbf
/usr/local/oracle/oradata/zh888/undotbs01.dbf
/usr/local/oracle/oradata/zh888/sysaux01.dbf
/usr/local/oracle/oradata/zh888/users01.dbf
/usr/local/oracle/oradata/zh888/qc_data.dbf