oracle如何建立一個新使用者 附完整命令

就是在已有的資料庫例項上建立一個新的帳號,訪問一些新的表

操作步驟如下:

1、登入linux,以oracle使用者登入(如果是root使用者登入的,登入後用 su - oracle命令切換成oracle使用者)

2、以sysdba方式來開啟sqlplus,命令如下: sqlplus "/as sysdba"

3、檢視我們常規將使用者表空間放置位置:執行如下sql:

select name from v$datafile;

上邊的sql一般就將你的使用者表空間檔案位置查出來了。

4、建立使用者表空間:

CREATE TABLESPACE NOTIFYDB DATAFILE '/oracle/oradata/test/notifydb.dbf' SIZE 200M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

5、建立使用者,指定密碼和上邊建立的使用者表空間

CREATE USER hc_notify IDENTIFIED BY hc_password DEFAULT TABLESPACE NOTIFYDB;

6、賦予許可權

grant connect,resource to hc_notify; grant unlimited tablespace to hc_notify; grant create database link to hc_notify; grant select any sequence,create materialized view to hc_notify;

經過以上操作,我們就可以使用hc_notify/hc_password登入指定的例項,建立我們自己的表了

續:

建立臨時表空間:

create temporary tablespace test_temp tempfile 'F:/app/think/oradata/orcl/test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local;

建立表空間:

create tablespace test_data logging datafile 'F:/app/think/oradata/orcl/test_data01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local;

建立使用者:

create user jack identified by jack default tablespace test_data temporary tablespace test_temp;

為使用者賦予許可權:

GRANT create any table TO jack; GRANT resource,dba TO jack; GRANT select any table TO jack;

第一個是授予所有table有create許可權,第三是授予所有table有select許可權.

第二個就是賦予DBA的許可權,這才是最重要的,其實只要第二就可以了.

1.connect role(連線角色)2. resource role(資源角色)3. dba role(資料庫管理員角色)

四:刪除使用者表空間的步驟:

Alter tablespace 表空間名稱 offline; Drop tablespace 表空間名稱;(表空間無有資料時用)

或者

drop tablespace 表空間名稱 including contents;(表空間下有資料時候用)

temporary tablespace是oracle裡臨時表空間,臨時表空間主要用途是在資料庫進行排序運算、管理索引、訪問檢視等操作時提供臨時的運算空間,當運算完 成之後系統會自動清理。當oracle裡需要用到sort的時候,而pga又沒有足夠大的時候,將會把資料放入臨時表空間裡進行排序,同時如果有異常情況 的話,也會被放入臨時表空間,但是我們需要重建temporary tablespace,直接是不能drop預設的臨時表空間的,不過我們可以通過以下方法來做。

檢視目前的temporary tablespace

SQL> select name from v$tempfile;

整個的命令是:

create tablespace qiche logging datafile '/u01/oradata/orcl/qiche.dbf' size 320m autoextend on next 32m maxsize 2048m extent management local; create user qiche identified by qiche default tablespace qiche; grant connect,dba to qiche;