linux下oracle建立新使用者和資料庫

來源:互聯網
上載者:User
1.su - oracle


2.登入sys使用者
sqlplus 'sys/Or#K017$dDB001 as sysdba'


3.建立暫存資料表空間:


--查詢暫存資料表空間檔案的絕對路徑。如果需要的話,可以通過查詢來寫定絕對路徑。一般用${ORACLE_HOME}就可以了  
select name from v$tempfile;  
create temporary tablespace mpg_temp98 tempfile '${ORACLE_HOME}\oradata\mpg_temp98.bdf' size 100m reuse autoextend on next 20m maxsize unlimited;  


4.建立資料表空間:


--查詢使用者資料表空間檔案的絕對路徑:
select name from v$datafile;
create tablespace MPG_DATA98 datafile '${ORACLE_HOME}\oradata\MPG_DATA98.dbf' size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);




5.建立使用者和密碼,指定上邊建立的暫存資料表空間和資料表空間


create user mpg_admin98 identified by mpg_admin98 default tablespace MPG_DATA98 temporary tablespace mpg_temp98;


6.給使用者授予許可權  要給dba許可權*/
grant create session, create any table, create any view ,create any index, 
create any procedure,alter any table, alter any procedure,drop any table, 
drop any view, drop any index, drop any procedure,select any table, create any trigger,create table,
insert any table, update any table, delete any table ,unlimited tablespace,connect,resource,dba to mpg_admin98;




7.退出
exit;
8.匯入資料庫
imp mpg_admin98/mpg_admin98@mpgdb01 fromuser=mpg_admin98 touser=mpg_admin98 file=/data/orcl090201.dmp ignore=y;


6.系統許可權回收:系統許可權只能由DBA使用者回收
命令:SQL> Revoke connect, resource,dba from mpg_admin98;


1.刪除某個使用者
drop user mpg_admin98 cascade;




/*刪除暫存資料表空間 */




--查看暫存資料表空間檔案
select name from v$tempfile;
--查看使用者和資料表空間的關係
select USERNAME,TEMPORARY_TABLESPACE from DBA_USERS;
--如果有使用者的預設暫存資料表空間是NOTIFYDB_TEMP的話,建議變更
alter user xxx temporary tablespace tempdefault;
---設定tempdefault為預設暫存資料表空間
alter database default temporary tablespace tempdefault;
--刪除資料表空間NOTIFYDB_TEMP及其包含資料對象以及資料檔案
drop tablespace mpg_temp13 including contents and datafiles; 




alter user mpg_admin13 temporary tablespace mpg_temp13;
 drop user mpg_admin13 cascade;


select sid,serial# from v$session where username='mpg_admin13';
--修改使用者資料表空間
alter user mpg_admin13 default tablespace MPG_DATA13  ;--建立時候指定資料表空間


--刪除暫存資料表空間(刪除之前要確定沒用在使用)
drop tablespace MPG13_TEMP including CONTENTS and datafiles; 
--刪除資料表空間
drop tablespace MPG13_DB including CONTENTS and datafiles; 
 
 
 
 --ORACLE中關於CONNECT,RESOURCE,DBA的授權
    CONNECT,RESOURCE,DBA是Oracle系統的三個內建角色,角色許可權如下:
    CONNECT:擁有Connect許可權的使用者只可以登入oracle,不可以建立實體,不可以建立資料庫結構。
    RESOURCE:擁有Resource許可權的使用者只可以建立實體,不可以建立資料庫結構。
    DBA:擁有全部特權,是系統最高許可權,只有DBA才可以建立資料庫結構。
    一般來說,對於普通使用者,授予CONNECT, RESOURCE許可權。 對於管理使用者,則授予CONNECT,RESOURCE, DBA許可權。


--預存程序調試時需要有如下許可權
GRANT debug any procedure, debug connect session TO scott

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.