資源描述:
《oracle_創(chuàng)建create_user_及授權(quán)grant_查看登陸的用戶及更改用戶默認表空間》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、oracle創(chuàng)建createuser及授權(quán)grant查看登陸的用戶:以下都可以:showuser;selectsys_context('userenv','session_user')fromdual;selectuserfromdual;查看所有登錄的用戶必須為DBA用戶:selectusernamefromv$session;sys、system等DBA用戶查看其他用戶(test)中的對象(表):SQL>select*fromtest.student;創(chuàng)建一個普通用戶都把該用戶用起來的流程:1、創(chuàng)建用戶
2、SQL>createusertestindentifiedbytest;這樣就創(chuàng)建了一個用戶名密碼都為test的用戶但這個時候test還是不能登陸成功的,我們需要賦予相應(yīng)的權(quán)限2、賦予createsession的權(quán)限SQL>grantcreatesessiontotest;這樣test用戶就能成功登陸進去但是此時用戶還是不能創(chuàng)建表我們需要賦予用戶創(chuàng)建表的權(quán)限:SQL>grantcreatetabletotest;但是用戶此時還不能創(chuàng)建表因為需要有使用表空間的權(quán)限(相當于用戶有了進房間的鑰匙但是沒有進大門的鑰
3、匙。。。)所以也應(yīng)該賦予相應(yīng)的權(quán)限SQL>grantunlimitedtablespacetotest;這個時候用戶就擁有了創(chuàng)建表的權(quán)限由于表是用戶test的相應(yīng)的他就擁有了對創(chuàng)建的表的增刪查改的權(quán)限了3、查看用戶擁有什么權(quán)限可以通過查詢一個系統(tǒng)的視圖(數(shù)字字典)SQL>select*fromuser_sys_privs;這樣就可以知道當前用戶的權(quán)限4、撤銷權(quán)限SQL>revokecreatetablefromtest;-----------------------------一些常用視圖的區(qū)分dba_ta
4、blesdba_all_tablesuser_tablesuser_all_tablesall_tablesall_all_tables當前用戶所屬的所有表(注意大寫)SQL>selecttablespace_name,table_namefromuser_all_tableswheretable_name='STUDENT';SQL>selecttable_name,tablespace_namefromuser_tableswheretable_name='STUDENT';TABLE_NAMETABL
5、ESPACE_NAME------------------------------------------------------------STUDENTUSERSsys要查看dba_all_tables,ALL_ALL_TABLES才能查看到test用戶的表。SQL>selectowner,table_name,tablespace_namefromdba_all_tableswhereowner='TEST';SQL>selectowner,table_name,tablespace_namefrom
6、all_all_tableswhereowner='TEST';SQL>selectowner,table_name,tablespace_namefromdba_tableswhereowner='TEST';SQL>selectowner,table_name,tablespace_namefromALL_tableswhereowner='TEST';OWNERTABLE_NAMETABLESPACE_NAME----------------------------------------------
7、--------------------------------------------TESTSTUDENTUSERS1.DBA_ALL_TABLESdescribesallobjecttablesandrelationaltablesinthedatabase.Itscolumnsarethesameasthosein
ALL_ALL_TABLES.2.ALL_ALL_TABLESdescribestheobjecttablesandrelationaltablesaccessibletothecurr
8、entuser.3.USER_ALL_TABLESdescribestheobjecttablesandrelationaltablesownedbythecurrentuser.Itscolumns(exceptforOWNER)are
thesameasthoseinALL_ALL_TABLES.---------------------------------------------------------