oracle 資料表空間

來源:互聯網
上載者:User

標籤:oracle   user   資料表空間   

  1. 建立資料表空間
    --查看所有使用者,以及對應的永久資料表空間,暫存資料表空間
    select username,default_tablespace,temporary_tablespace from dba_users

    where username=‘SYSTEM‘;


    1.1 建立暫存資料表空間
        CREATE TEMPORARY TABLESPACE DB_TEMP

             TEMPFILE ‘D:appAdministratororadataNewDBDB_TEMP.DBF‘

             SIZE 32M

             AUTOEXTEND ON

             NEXT 32M MASIZE UNLIMITED

             EXTENT MANAGEMENT LOCAL;



    1.2 建立資料資料表空間
        
        create tablespace 資料表空間名  
            datafile ‘ 路徑(要先建好路徑)\***.dbf  ‘ size *M  
                   ( ‘ 路徑\***.dbf ‘ size *M  )--這裡可以建立多個dbf檔案
            autoextend on    --自動成長  
        next 5M          --增長梯度
        maxsize 3000M;   --最大範圍
            --還有一些定義大小的命令,看需要  
             default storage(  
             initial 100K,  
             next 100k,  
            );  


    ----非自動成長的資料表空間進行擴充

    alter tablespace <tablespace_name> add datafile ‘<file>‘ size <size> autoextend off;



    第三步:建立使用者並制定資料表空間
        CREATE USER NEWUSER IDENTIFIED BY BD123

             ACCOUNT UNLOCK

             DEFAULT TABLESPACE DB_DATA

             TEMPORARY TABLESPACE DB_TEMP;



    第四步:給使用者授予許可權


    SQL> GRANT CONNECT,RESOURCE TO NEWUSER;  --表示把 connect,resource許可權授予news使用者

    SQL> GRANT DBA TO NEWUSER;  --表示把 dba許可權授予給NEWUSER使用者

        授權成功。

        OK! 資料庫使用者建立完成,現在你就可以使用該使用者建立資料表了!



    --案例:
    create tablespace mytest datafile ‘/home/oracle/dbdates/mytest.dbf‘ SIZE 20M;

    --建立使用者
    create user zzg identified by zzg123;

    --建立使用者並指定資料表空間
    create user demo identified by demo  default tablespace std;

    --修改使用者的資料表空間,到指定的資料表空間
    ALTER user ewell DEFAULT tablespace mytest;

    --刪除資料表空間(暫存資料表空間)
    drop tablespace mytest;刪除後dbf檔案還在,可以通過下面語句找回
    (create tablespace name datafile ‘刪除資料表空間dbf路徑‘;)
    drop tablespace mytest including contents;刪除資料表空間和段,dbf檔案還在

    drop tablespace mytest including contents and datafiles;將刪除資料表空間和段以及資料檔案

    --修改使用者的密碼.
    alter user zzg identified by unis;

    --使用者授權
    grant create session to 使用者名稱;  

    ---查看目前使用者的所有許可權
    select *from session_privs;


    --刪除使用者以及相關對象

    文法:drop user 使用者名稱;

    例子:drop user test;

    若使用者擁有對象,則不能直接刪除,否則將返回一個錯誤值。指定關鍵字cascade,可刪除使用者所有的對象,然後再刪除使用者。

    文法:
    drop user 使用者名稱 cascade;

    例子:drop user test cascade;


oracle 資料表空間

聯繫我們

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