oracle使用sqlplus建立資料表空間

來源:互聯網
上載者:User

標籤:

一、開啟命令列視窗,輸入以下命令:sqlplus /nolog 斷行符號後,將出現提示符 SQL>,
 這時輸入conn / as sysdba 一般即可登入,如果失敗的話,可以試一下用conn sys/sys使用者的密碼 as sysdba來重試一下

二、查看當前的資料庫檔案一般都是放在哪裡的: 輸入:select name from v$datafile;
 NAME
 --------------------------------------------------------------------------------
 D:\oracle\oradata\orcl\system01.dbf

 D:\oracle\oradata\orcl\undotbs01.dbf

 D:\oracle\oradata\orcl\cwmlite01.dbf

 D:\oracle\oradata\orcl\drsys01.dbf

 D:\oracle\oradata\orcl\indx01.dbf

 D:\oracle\oradata\orcl\tools01.dbf

 說明您的資料檔案是放在 D:\oracle\/oradata\orcl\ 這個目錄下的

三、開始建立資料庫資料表空間,命令格式如下:
 create tablespace 資料表空間名 datafile ‘對應的檔案名稱‘ size 大小;
 舉例如下:
 create tablespace wbppcs datafile ‘D:\oracle\oradata\orcl\wbppcs.dbf‘ size 3000m;
 3000m指的是3000MB

四、開始建立使用者,命令格式如下:
 create user 使用者名稱 identified by 密碼 default tablespace 使用者預設使用哪一個資料表空間;
 修改使用者的許可權:
 grant 角色1,角色2 to 使用者名稱;
 舉例如下:
 create user wbppcs identified by wbppcs123 default tablespace wbppcs;
 grant dba, connect to wbppcs;

五、授予許可權
 1、預設的普通使用者scott預設未解鎖,不能進行那個使用,建立的使用者也沒有任何許可權,必須授予許可權
   /*管理員授權*/
   grant create session to zhangsan;//授予zhangsan使用者建立session的許可權,即登陸許可權
   grant unlimited session to zhangsan;//授予zhangsan使用者使用資料表空間的許可權
   grant create table to zhangsan;//授予建立表的許可權
   grante drop table to zhangsan;//授予刪除表的許可權
   grant insert table to zhangsan;//插入表的許可權
   grant update table to zhangsan;//修改表的許可權
   grant all to public;//這條比較重要,授予所有許可權(all)給所有使用者(public)
 2、oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的,需要互相授權
   /*oralce對許可權管理比較嚴謹,普通使用者之間也是預設不能互相訪問的*/
   grant select on tablename to zhangsan;//授予zhangsan使用者查看指定表的許可權
   grant drop on tablename to zhangsan;//授予刪除表的許可權
   grant insert on tablename to zhangsan;//授予插入的許可權
   grant update on tablename to zhangsan;//授予修改表的許可權
   grant insert(id) on tablename to zhangsan;
   grant update(id) on tablename to zhangsan;//授予對指定表特定欄位的插入和修改許可權,注意,只能是insert和update
   grant alert all table to zhangsan;//授予zhangsan使用者alert任意表的許可權
五、撤銷許可權
  基本文法同grant,關鍵字為revoke
六、查看許可權
  select * from user_sys_privs;//查看目前使用者所有許可權
  select * from user_tab_privs;//查看所用使用者對錶的許可權
七、動作表的使用者的表
  /*需要在表名前加上使用者名稱,如下*/
  select * from zhangsan.tablename
八、許可權傳遞
  即使用者A將許可權授予B,B可以將操作的許可權再授予C,命令如下:
  grant alert table on tablename to zhangsan with admin option;//關鍵字 with admin option
  grant alert table on tablename to zhangsan with grant option;//關鍵字 with grant option效果和admin類似
九、角色
  角色即許可權的集合,可以把一個角色授予給使用者
  create role myrole;//建立角色
  grant create session to myrole;//將建立session的許可權授予myrole
  grant myrole to zhangsan;//授予zhangsan使用者myrole的角色
  drop role myrole;刪除角色
  /*但是有些許可權是不能授予給角色的,比如unlimited tablespace和any關鍵字*/

oracle使用sqlplus建立資料表空間

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.