步骤二_ORACLE相关的操作命令
1. 创建表空间、用户以及对用户进行授权
-----创建表空间(unicom)
create tablespace unicom datafile '/opt/oracle/oradata/MIS/unicom.dbf' size 600M;
-----创建用户 /授权
create user hollycrm identified by hollycrm default tablespace unicom;
SQL> grant connect,resource to hollycrm;
--- resource 指的是授予开发人员的权限,包括
CREATE CLUSTER --建立聚簇
CREATE PROCEDURE --建立过程
CREATE SEQUENCE --建立序列
CREATE TABLE --建表
CREATE TRIGGER --建立触发器
CREATE TYPE --建立类型
---- connect 授予最终用户的典型权利,最基本的,包括
ALTER SESSION --修改会话
CREATE CLUSTER --建立聚簇
CREATE DATABASE LINK --建立数据库链接
CREATE SEQUENCE --建立序列
CREATE SESSION --建立会话
CREATE SYNONYM --建立同义词
CREATE VIEW --建立视图
Grant succeeded.
SQL> grant create session,dba to hollycrm; ---- 将dba的权限赋予用户 hollycrm
Grant succeeded.
2. 查看表空间的大小
select a.tablespace_name,
round((total/1024)/1024,4)total ,
round((free/1024)/1024,4)free,
round(((total-free)/1024) /1024,4)use,
round((total-free)/total,4)*100 userage
from (
select tablespace_name,sum(bytes) free
from dba_free_space group by tablespace_name
) a ,
(
select tablespace_name,sum(bytes) total
from dba_data_files group by tablespace_name
) b
where a.tablespace_name = b.tablespace_name;
结果如图:
现实的次序是: TOTAL--总的表空间大小,FREE--剩余的空间,USE--已经使用的空间,USERAGE--使用的百分比,单位--M
3. 起动数据库的监听
lsnrctl start | stop | status
-----------------------------------------------------------------------
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-SEP-2009 22:58:38
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.222)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 26-SEP-2009 22:58:40
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.222)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
4. 起动/停止oracel数据库
sqlplus /nolog -- 登陆数据库
conn / as sysdba -- 以管理员身份连接
startup/shutdown -- 起动/停止数据库服务
-----------------------------------
SQL> startup
ORACLE instance started.
Total System Global Area 247463936 bytes
Fixed Size 1218772 bytes
Variable Size 75499308 bytes
Database Buffers 167772160 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
-----------------------------------
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
5. ORACLE数据库的几个基本概念
/opt/oracle/product/10.2.0/db_1/network/admin
该目录下的三个主要文件,决定了客户端连接数据库的相关参数
listener.ora sqlnet.ora tnsnames.ora
具体见这里下面的详细介绍
http://blog.chinaunix.net/u/21218/showart_137768.html