ORACLE中建立資料表空間,建立表,改動表,授權

來源:互聯網
上載者:User

標籤:bsp   word   number   admin   設定   auto   回收   create   dict   

建立資料表空間


/*分為四步 */
/*第1步:建立暫時資料表空間  */
create temporary tablespace user_temp  
tempfile ‘D:\oracle\oradata\Oracle9i\user_temp.dbf‘ 
size 50m  
autoextend on  
next 50m maxsize 20480m   //假設最大值沒有上限,則使用unlimited
extent management local;  //extent 表示區間  設定區間管理方式是本地方式   第二種方式是dictionary 字典方式  。extent能夠理解為表的擴充方式
 
/*第2步:建立資料資料表空間  */
create tablespace user_data  
logging    //表示建立日誌   nologging  表示不建立日誌  
datafile ‘D:\oracle\oradata\Oracle9i\user_data.dbf‘ 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第3步:建立使用者並指定資料表空間  */
create user username identified by password  
default tablespace user_data  
temporary tablespace user_temp;  
 
/*第4步:給使用者授予許可權  */
grant connect,resource,dba to username;
grant create table to username






1、首先。grant XXX to user;,grant是授權的作用,這裡的XXX能夠是一個角色role。也能夠是許可權。比如grant role to user;,或grant insert on table to user;。




MOS中給出的標準SQL語句:


建立角色:


create role <role name> [IDENTIFIED BY <password>/USING <package>/EXTERNALLY/GLOBALLY ];


賦予角色許可權:


grant <object/system privilege> to <role name>;


從角色收回許可權:


revoke <privilege> from <role name>;


將角色賦予還有一個角色或使用者:


grant <role> to <username or role> ;


2、其次,connect和resource是兩個系統內建的角色,和dba是並列的關係。


參考一些文章的說法,許可權能夠分為兩類:


系統許可權:系統規定使用者使用資料庫的許可權。(系統許可權是對使用者而言)。

 


實體許可權:某種許可權使用者對其他使用者的表或視圖的存取許可權。(是針對錶或視圖而言的)。


接下來看系統許可權,


DBA:擁有所有特權,是系統最高許可權。僅僅有DBA才幹夠建立資料庫結構。




RESOURCE:擁有Resource許可權的使用者僅僅能夠建立實體。不能夠建立資料庫結構。




CONNECT:擁有Connect許可權的使用者僅僅能夠登入Oracle。不能夠建立實體。不能夠建立資料庫結構。


對於普通使用者:授予connect, resource許可權。 


對於DBA系統管理使用者:授予connect。resource, dba許可權。


且系統許可權僅僅能由DBA使用者授出:sys, system(最開始僅僅能是這兩個使用者)。普通使用者通過授權能夠具有與system同樣的使用者權限,


但永遠不能達到與sys使用者同樣的許可權。system使用者的許可權也能夠被回收。


另外,對於WITH ADMIN OPTION級聯授權的問題,


1)假設使用WITH ADMIN OPTION為某個使用者授予系統許可權,那麼對於被這個使用者授予同樣許可權的全部使用者來說,取消該使用者的


系統許可權並不會級聯取消這些使用者的同樣許可權。 


2)系統許可權無級聯。即A授予B許可權。B授予C許可權,假設A收回B的許可權,C的許可權不受影響;系統許可權能夠跨使用者回收。即A能夠


直接收回C使用者的許可權。



建立表
 oracle中建立表:
create table users(
       id number(9) not null primary key,
       username varchar2(40) not null,
       age int  check(age>18 and age<50)    
)  


create table orders(
   oid varchar2(10) not null ,
   userid number(9) ,
   primary key (oid),
   foreign key(userid) references users(id)
)


刪除表 :drop table orders


改動表名:alter table orders
          rename  to orderss


加入列:  alter table orders
          add price number(9)


改動列的資料類型:alter table orders
                  modify price number(10)


刪除列 :alter table orders
         drop column price


改動列名:alter table orders
          rename  column price to pri


加入外鍵: alter table orders
           add constraint fkuid foreign key(userid) references users(id)


刪除約束:alter table orders
          drop constraint fkuid

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.