You are on page 1of 17

TABLESPACEMANAGEMENT

Oraclestoresdatalogicallyintablespaceandphysicallyindatafiles Tablespacecanbelongtoonlyonedatabaseatatime consistsofonearemoredatafiles Arefurtherdivideintologicalunitsofstorage Datafilescanbelongtoonlyonetablespaceandonedatabase Typesoftablespace Systemtablespace Createdwiththedatabase containsthedatadictionaryandsystemundosegment. Nonsystemtablespace seperatesegments,,seperatedatabybackuprequirements. Controlstheamountofspaceallocatedtotheuser'sobjects. Basedonextentmanagement.tablespacecanbeclassifiedinto2typesofextent allocationthatisLMTSANDDMTS differencebetweenLMTSANDDMTS DMTS> defaultfrom9i tablespacemanagingitstablesbydictionary forspaceitchecksdictionarytablesandthenallocates Intablespaceblocksarenotcontinousformatsuppose100mbofspacehasfilledwith 100mbofdatathenadevelopercameanddeletedsomedatathen20%willbefree wheneverclientinsertdataintotablespaceitdesplaysnodata. Freeextentsrmanagedbythedatadictionary theoracleserverupdatestheappropriatetablesinthedatadictionarywheneveran extentisallocatedordeallocated. herecoaleasidinghastobedonemanually EX>Altertablespacetablespace_namecolease;

LMTS > Introducedfrom8i Itisselfmanagement,notdependingondictionary Indatafilesheader(bits)whetherspaceisavailable/not.basedonthisisallocates extents IncaseofLMTSSMONcomesintopictureandcoleasehappensautomaticallyit convertsthose20%freeblockstolargeextentandtheseextentsareassignedas segments.


>Tablespacemanagementfulldependsuponhoworacleisallocatingspacetoa segmentintermsofextents >Wheneveruwanttomorespacetoasegmentitwillbeallocatedonextents.at

thetimeofspaceallocationSMONcomesintopictureandautomaticallycoalseding willhappen.

ASSM>Automaticsegmentspacemanagement

Introducedfrom9ianddefaultfrom10g.in10goraclecalculatesthefreelist hasalistoffreeblocks<FREELIST>(freelistgroups)>blocks>freespace. theseblocksarefilleditisfilleditwillbeoutoffreelistthisisreadbyusers. from10gOSreadsthisfreelist ifanyerroroccursthenfreelistcontentionoccurs. segmentspacemanagementAUTO(defaultfrom10g)in9i(auto/manual)


Tocreateadictionarymanagertablespace SQL>createtablespacedmtsdatafile'/u01/user112/prod/data/dmts.dbf'size5mextent managementdictionarydefaultstorage(minextents2maxextents20initial5knext10k pctincrease0); Tablespacecreated. Tocreatealocallymanagertablespace SQL>createtablespacelmtsdatafile'/u02/user19/dev/data/lmts.dbf'size5mextent managementlocaluniformsize50ksegmentspacemanagementauto; Tablespacecreated. Tocreateatablespacewithautoextendon SQL>createtablespacerajdatafile'/u02/user19/dev/data/raj.dbf'size10mautoextendon next5mmaxsize15m; Tablespacecreated. >Autoextenditreducesneedforimmediateintervensionwhenatablespacerunsoutof space. Tocreatetablespacewithoutautoextend SQL>createtablespaceabcdatafile'/u02/user19/dev/data/abc.dbf'size1m; Tablespacecreated. Toresizeadatafile SQL>alterdatabasedatafile'/u02/user19/dev/data/raj.dbf'resize18m; Databasealtered. resizingadatafileaddsmorespacewithoutaddingmoredatafiles. atablespacecanberesizedbychangingthesizeofthedatafile automaticallyusingautoextend. manuallyusingaltertablespace. Toaddadatafile SQL>altertablespacerajadddatafile'/u02/user19/dev/abc.dbf'size1m; Tablespacealtered. Torenameadatafile SQL>altertablespacerajoffline;

[user19@server3data]$mvraj.dbfRAJ.DBF SQL>altertablespacerajrenamedatafile'/u02/user19/dev/data/raj.dbf'to '/u02/user19/dev/data/RAJ.DBF'; Tablespacealtered. SQL>altertablespaceRAJUonline; Tablespacealtered. Todropadatafile SQL>altertablespacerajdropdatafile'/u02/user19/test/data/raj1.dbf'; Tablespacealtered. (ifatablespacehavingonlyonedatafilethenwecantdropthedatafile) Todropatablespace SQL>droptablespaceRAJincludingcontentsanddatafiles; Tablespacedropped. includingcontents:Dropsallthesegmentsinthetablespace. anddatafiles:Deletestheassociatedoperatingsystemfiles.

Tofindoutcurrentpermanenttablespaceforyourdatabase.
SQL>selectproperty_valuefromdatabase_propertieswhere property_name='DEFAULT_PERMANENT_TABLESPACE'; PROPERTY_VALUE USERS

Toassignadefaulttablespacetoadatabase
SQL>alterdatabasedefaulttablespaceusers; Databasealtered. Totaketablespaceoffline SQL>altertablespaceabcoffline; Tablespacealtered. notavailablefor.dataaccess tbsthatcannotbetakenofflinesystemtbstbswithactiveundosegmentsdefaulttemp tbs. Totaketablespaceonline SQL>altertablespaceabconline; Tablespacealtered. whenatbsgoesofflineorcomesbackonline,theeventisrecordedinthedatadictionary andinthecontrolfile. Toputtablespacereadonly SQL>altertablespaceabcreadonly; Tablespacealtered.

>dataavailableonlyforreadoperations. tomakeareadonlytablespacewritable,allofthedatafilesinthetablespacemustbe online. Toputtablespacereadwrite SQL>altertablespaceabcreadwrite; Tablespacealtered. Tosetstorageparameterstoatables SQL>createtableemploy(empnonumber(4),enamevarchar2(20),jobvarchar2(8),mgr number(4),deptnonumber(2))storage(initial200knext200kpctincrease0minextents1) tablespaceabc; Tablecreated. Storageparametersformanagingtables Everytablespacehasdefaultstorageparameters. Ausercanspecifytheparameterswhilecreatingtheobjects. INITIALthesizeinbytesofthefirstextentallcatedwhenasegementiscreated.default systemvaluesrgivendatablocks.(default5datablocks,,min2datablocks,,maxOS specific) NEXTthesizeofthenextextenttobeallcatedforasegment.thesecondextentisequalto theoriginalsettingfornext.fromthirdextentonwords'NEXT'issettoprevioussizeofnext multiplyby(1+pctincrease/100).(default5datablocks,,min1db,,maxOSspecific) MAXEXTENTSthetotalno.ofextents.includingthefirst.caneverbeallocatedforthe segment.(defaultdependingondatablocksizeandOS,,min1db,,maxOS) PCTINCREASEthepercentbywhicheacjincrementalextentgrowsoverthelastincremental extentallocatedforasegment.ifpctincreaseis0.thenallincrementalextentsarethesame size.ifpctincreaseisgreaterthen0,thentimethenextiscalculated.itgrowsbypctincrease.it cannotbenegative.itisspecifiedinpercentage. PCTFREEitisusedtosetpercentageofablocktobereservedforfurtherupdate.ifitis fullitisnotpossibletoinsertanewrows. PCTUSEDitisusedtoallowablocktobereconsideredfortheinsertionofnewrow. INITTRAINSitreservespreallocationamountofspaceforinitialnumbertransactionentries toaccessrowsinthedatablockconcurrentlyspacereservedintheheaderofalldatablocks. LOGGINGspecifiesthat,bydefault,alltables,indexes,andpartitionswithinthetablespace haveallchangeswrittentoredoLOGGINGisdefault NOLOGGINGspecifiesthat,bydefault,alltables,indexesandpartitionswithinthe tablespacedonothaveallchangeswrittentoredo.NOLOGGINGaffectsonlysomeDMLand DDLcommands

Tocreatenologgingtablespace. SQL>createtablespaceraj_logdatafile'/u02/user19/dev/data/raj_log.dbf'size5m nologging; Tablespacecreated.


Tocreateadatafilewithblocksize2k SQL>altersystemsetdb_2k_cache_size=16m;

Systemaltered. SQL>createtablespaceraj_2kdatafile'/u02/user19/vivid/data/raj_2k.dbf'size10mblocksize 2k; Tablespacecreated. Torenameatablespace SQL>altertablespaceabcrenametoaaa; Tablespacealtered.

BIGFILETABLESPACES Tofindyourdatabaseusingbigfileorsmallfile
SQL>selectPROPERTY_VALUEfromdatabase_propertieswhere property_name='DEFAULT_TBS_TYPE'; PROPERTY_VALUE SMALLFILE Tocreateabigtablespace SQL>createbigfiletablespacebigdatafile'/u02/user19/dev/data/big.dbf'size2m; Tablespacecreated. Toresizeabigfile SQL>altertablespacebigresize4m; Tablespacealtered. Toenableautoextendon SQL>altertablespacebigautoextendonnext5m; Tablespacealtered. TEMPORARYTABLESPACEMANAGEMENT

Holdsdatatemporarlybasicallyforsorting,joiningandmergingprocess nopermanentschemaobjectcanresideinatemptbs. tempfilesralwayssettoNOLOGGINGmode ucannotmaketempfilereadonly,renameandcannotcreateatempfilewithalter databasecommand. tempfilesrrequiredforreadonlydatabase mediarecoverydoesnotrecovertempfiles...


Tocreatetemporarytablespace SQL>createtemporarytablespacertemptempfile'/u02/user19/dev/data/rtemp.dbf'size5m; Tablespacecreated.

Tocreatetemporarytablespacewithautoextendon
SQL>createtemporarytablespacetemp_01tempfile '/u02/user19/dev/data/temp_01.dbf'size20mautoextendon; Tablespacecreated.

Toaddadefaulttempoarytablespace
SQL>createtemporarytablespacetemp_02tempfile'/u02/user19/dev/data/temp_02.dbf'size 20mautoextendon; Tablespacecreated. SQL>alterdatabasedefaulttemporarytablespacetemp_02; Databasealtered.

Tofindthedefaulttemporarytablespaceforadatabase
SQL>selectproperty_name,property_valuefromdatabase_propertieswhere property_name='DEFAULT_TEMP_TABLESPACE'; PROPERTY_NAMEPROPERTY_VALUE ___________________________________________ DEFAULT_TEMP_TABLESPACETEMP_02

Todropatemporarytablespace
SQL>alterdatabasetempfile'/u02/user19/dev/data/temp_01.dbf'dropincluding datafiles; Databasealtered. *>Ifaqueryhasmoresorting,mergingoperationstheuserhasaccesstoonlyone temptablespace,ifitgetfilledupthentoovercomethiswehavetemptbs groupwhernuserhasaccesstomultipletemptbs.thisiscalledtemp.tbsgroup(itis from10g)
Tocreatetemporarytablespacewithgroup SQL>createtemporarytablespacetemp04tempfile'/u02/user19/dev/data/temp04.tmp'size 5mtablespacegrouptg1; Tablespacecreated.

Assigningagroupasthedefaulttemporarytablespaceforthedatabase
SQL>alterdatabasedefaulttemporarytablespacetg1; Databasealtered. Assigningatemporarytablespacetoagroup SQL>altertablespacertemptablespacegrouptg1; Tablespacealtered. SQL>select*fromdba_tablespace_groups; Todropatablespacefromagroup SQL>altertablespacertemptablespacegroup''; Tablespacealtered.

#cannotdropdefaulttemporarytablespace butwecanresizedefaulttemporarytablespace Toresizeatemporarytablespace SQL>alterdatabasetempfile'/u01/user112/prod/data/temp1.tmp'resize210m; Databasealtered. Toaddatempfiletoatemporarytablespace SQL>altertablespacetempaddtempfile'/u01/user112/prod/data/temp2.tmp'size10m; Tablespacealtered. #wecantputtemporarytablespaceonline,offline,readonly

UNDOTABLESPACEMANAGEMENT

>PreviousimageofDMLoperationstoredinundotalespace >Undotablespacecontainundo/rollbacksegments >Atanypointoftimedatabasewillgiveonlyoneundotabs >currentlyweareusingigbundotbsatmonthenddatabaserequiresmorespace .herewewillnotaddundodatafiletoaundotbs. >Justwehavetocreateanotherundotbswith3gbofspace >Ifdatabasehasnoundotbsdefaultweusesystemtbsforundooperations.deffered rollbacksegmentsinsystemtbswilluse >ifundotbsofflinethetransactiongoestodefferedrollbacksegments. >DSA(Dynamicspaceallocation)>itwillputalltransactonbacktoundotbsfrom deffered_roll_back >previous9iwecancreaterollbacksegmentswithproperestimation.ifestimationis wrongtransactionwillfail.hererollbacksegmentisnotutiliseDSAconceptis availablein9ionwords. >9ionwordsoraclewillcreateundosegmentautomaticbysetparameter undo_management=auto&DSAisenabled undo_retention:in9iretentionparameterisnoguarentee

in10gretentionparameterisguarentee,undo_retention=900(15min). >beforeundosegmentitwasrollbackiein8ithismanagementismanual. >from9i/10g/11g undo_management=auto undo_tablespace=undotbs undo_retention=900 >wecanhavemorethanoneundotbsbutatatimeoneshouldbeactivedepending onusertransaction. >oldtableshouldnotbedroppedandwecreateonemoreundotbsjusttoincrease thesizeofundotbs newtransactionwilluseactiveone oldtransactionwilluseoldundotbs v$transaction>transactioninformationofundotbs v$undostat>undostatistics v$rollstat>rollbacksegmentinformation Before9iundo_management=manual from9iundo_management=auto from10gundo_management=autoismanditory Before9idatabaseoracleversionisanyDMLOpeartiongoingondatabase.herefirst wehavetoestimateundosizeandwehavetocreate.before9ithereisnoconcepton dynamicspaceallocation. ifthereisnospaceincorrespondingundotbsevenspaceisavailableinotherundo tbsthenthespacewillnotaddedtootherundotbs
Tocreateundotablespace SQL>createundotablespaceundotbs2datafile'/u01/user112/prod/data/undotbs2.dbf'size 20m; Tablespacecreated. Toknowactiveundotablespace SQL>shoparameterundo_table NAMETYPEVALUE undo_tablespacestringUNDOTBS1 Toswitchfromoneundotablespacetoanotherundotbs. SQL>altersystemsetundo_tablespace=undotbs2scope=both; Systemaltered. SQL>shoparameterundo_table NAMETYPEVALUE undo_tablespacestringUNDOTBS2 Toaddauntodatafiletotablespace SQL>altertablespaceundotbs2adddatafile'/u01/user112/prod/data/undotbs3.dbf'size2m; Tablespacealtered.

Toresizeaundotablespace SQL>alterdatabasedatafile'/u01/user112/prod/data/undotbs2.dbf'resize15m; Databasealtered. Todropadatafilefromundotablespace SQL>altertablespaceundotbs2dropdatafile'/u01/user112/prod/data/undotbs3.dbf'; Tablespacealtered. Torenameaundotablespace SQL>altertablespaceundotbs2renametoundotbsraj; Tablespacealtered. 1>Tocheckthesizeofthedatabase SQL>selectsum(bytes)/1024/1024"DBSIZEINMB'S"fromdba_data_files; DBSIZEINMB'S 740 2>Tocheckfreespaceindatabase SQL>selectsum(bytes)/1024/1024"DBSIZEINMB'S"fromdba_free_space; DBSIZEINMB'S 23.6875 3>Tocheckusedspaceindatabase SQL>select74023.6875fromdual; 74023.6875 716.3125 4>Tocheckusedspaceindatabase SQL>selectsum(bytes)/1024/1024fromdba_segments; SUM(BYTES)/1024/1024 716.125 5>Tochecksizeofundotablespace SQL>selectfile_name,bytes/1024/1024fromdba_data_fileswhere tablespace_name='UNDOTBS1'; DBSIZEINMB'S 666.070313 6>Tofindsizeoftheeachtablespace SQL>selecttablespace_name,sum(bytes)/1024/1024"SIZEOFTABLESPACEINMB'S"from dba_data_filesgroupbytablespace_name; TABLESPACE_NAMESIZEOFTABLESPACEINMB'S SYSAUX260 UNDOTBS1615

USERS5 SYSTEM560 7>Tofindfreespaceecahtablespace SQL>selecttablespace_name,bytes/1024/1024fromdba_free_space; SYSTEM33.78125 UNDOTBS.0625 SYSAUX153.9375 USERS199.9375 7>Tochecksizeofapurticularuserdata. SQL>selectowner,segment_name,bytes/1024/1024fromdba_segmentswhereowner='SCOTT'; 8>Tochecksizeofalogfile SQL>selectsum(bytes)/1024/1024fromv$log; SUM(BYTES)/1024/1024 16 9>Tofindthesizeoftemporarytablespace SQL>selectsum(bytes)/1024/1024fromdba_temp_files; SUM(BYTES)/1024/1024 200 10>TOCHECKUNDOTABLESPAESIZE SQL>selectfile_name,bytes/1024/1024fromdba_data_fileswhere tablespace_name='UNDOTBS'; BYTES/1024/1024 ___________________ 200 SQL>selecttablespace_name,min_extentsfromdba_tablespaces; SQL>selecttablespace_name,MIN_EXTLENfromdba_tablespaces; SQL>selectfile#,namefromv$tempfile; SOMEVIEWSTOMONITORTHETABLESPACEINFO DESCDBA_DATA_FILES DBA_TABLESPACES USER_TABLESPACES V$TABLESPACE DBA_DATA_FILES DBA_FREE_SPACE DBA_SEGMENTS DBA_TABLESPACE_GROUPS V$DATAFILE V$FILESTAT V$DATABASE DATABASE_PROPERTIES

USERMANAGEMENT Tocreateauser . SQL>createuserrajeshidentifiedbyrajesh defaulttablespaceraj temporarytablespacerajtemp quotaunlimitedonraj passwordexpire accountlock profiledefault; Usercreated. Toalteruserquotas SQL>alteruserrajesh quota50monraj; Useraltered. Connecttousergivethisrole SQL>grantconnect,resourcetorajesh; Grantsucceeded. SQL>connrajesh/rajesh ERROR: ORA28000:theaccountislocked SQL>conn/assysdba Connected. SQL>alteruserrajeshaccountunlock; Useraltered. SQL>connrajesh/rajesh ERROR: ORA28001:thepasswordhasexpired(hereatthetimeofusercreation passwordasexpired) Changingpasswordforrajesh Newpassword: Retypenewpassword:

Passwordchanged Connected. Tochangeuserpassword SQL>alteruserrajeshidentifiedbywelcome; Useraltered. Todropauser SQL>dropuserrajeshcascade; Userdropped. >cascadewilldeleteuserobjectsalreadyexistingwithschema Tolockauseraccountandunlock. SQL>alteruserrajeshaccountlock; Useraltered. SQL>alteruserrajeshaccountunlock; Useraltered. Creatingprofileforuser Beforesettingprofilesuneedtosetthisparameterinparameterfiletoeffcttheresource limitssetbytheprofilewilleffect SQL>altersystemsetresoure_limit=true; Ifadbawanttoassignsyspriviliagetoanyuser firstcreateapasswordfileatoslevel [user200@server3dbs]$orapwdfile=orapwprodpassword=managerforce=y wehavetosetthisparameter inpfileremote_login_passwordfile=exclusive Inpfileremote_login_passwordfile=shared (ifmultipleinstancesaccesingonlyonedatabase) >whenasysdbaprivilegeisgrantedtoaspecifieduser,thatusercanbequeriedinthe v$pwfile_users ex::>select*fromv$pwfile_userswhereusername='RAJESH'; >systemresourcelimitsaremanagedwithusersprofiles.Aprofileisanamedsetof resourcelimitsthatcanbemanagedtoauser.theseresourcecangenerallybeestablishedat thesessionandstatementlevel.asessioniscreatedeverytimeadatabaseuserconnectsto thedatabase.ifasessionlevelresourcelimitisexceded.thecurrentstatementisrelledback anderrormessageisreturnedtotheuser. >failed_login_attempts=no.offailedattemptsafterwhichaccountisgoingtolocked. >password_lock_time=no.ofdayspasswordgoingtobelocked. >password_life_time=no.ofdaysthepasswordisvalid >password_grace_time=no.ofdaysitisgoingtopromptforpasswordexpiry. >password_reuse_time=specifiestheno.ofdaysbeforeapasswordcanbereused. >password_reuse_max=no.oftimespasswordcanbechanged. SQL>createprofilerithulimit failed_login_attempts3 password_lock_time3 password_life_time25 password_grace_time2

password_reuse_time3 password_reuse_maxunlimited; Profilecreated. Toalteraprofile SQL>alterprofilerithulimitfailed_login_attemptsunlimited 2password_life_timeunlimited 3password_reuse_timeunlimited; Profilealtered. Assigningaprofiletoapurticularuser SQL>alteruserrajeshprofilerithu; Useraltered. Todropaprofile; SQL>dropprofilerahulcascade; Profiledropped. Creatingaprofileforresourcelimit SQL>createprofilerajulimit sessions_per_user2 cpu_per_session100 idle_time60 connect_time100; Profilecreated. >sessionsper_user=limitstheno.ofconcurrentsessionsfortheuser. >cpu_per_session=limitsthecputimeforsession.thisisexpressedinhundredthsofseconds. >idle_time=definesthemaximumamountofcontinousinactivetimespan >connect_time=limitsthetotalelapsedconnecttimeofasession Profilecreated. Sessionsanduserlicensing >ifursiteislicensedbyconcurrentusuage.youcantrackandlimitthenumberofsessions concurrentlyconnectedtoadatabase.ifyoursiteislicensedbynameduseryoucallimitthe numberofnameduserscreatedinadatabase. SQL>altersystemsetlicense_max_sessions=64license_sessions_warning=54; Systemaltered. Assigningprofile.touser. SQL>alteruserrajeshprofileraju; Useraltered. Grantingsystemprivilegestouser SQL>grantconnect,resourcetorajesh; Grantsucceeded. SQL>grantcreatesessiontorajesh; Grantsucceeded.

SQL>grantcreatesessiontorajeshwithadminoption; Grantsucceeded. SQL>grantsysdbatorajesh; Grantsucceeded. SQL>grantallprivilegestorajesh; Grantsucceeded. SQL>grantdeleteonbonustorajeshwithgrantoption; Grantsucceeded. SQL>grantinsertanytabletorajeshwithadminoption; Grantsucceeded.

Tochangeruserpassword SQL>createuserrajeshidentifiedbyrajesh; nowcheckthepasswordforrajeshindba_userstablewhichisinencriptedformatandnote downit SQL>conn/assysdba Connected. SQL>selectusername,passwordfromdba_userswhereusername='RAJESH'; USERNAMEPASSWORD RAJESH247DAC6906878340 SQL>alteruserrajeshidentifiedbymanager; Useraltered. nowthedbacanperformsomeoperationandagainthedbawanttoassignthesame passwordtothatuser. tosetthesamepassword SQL>alteruserrajeshidentifiedbyvalues'247DAC6906878340'; Useraltered. SQL>connrajesh/rajesh Connected. 1.Tocheckuseraccountstatus SQL>selectusername,user_id,account_status,expiry_datefromdba_userswhereusername= 'RAJESH'; USERNAMEUSER_IDACCOUNT_STATUS EXPIRY_DA RAJESH55OPEN SQL>colUSERNAMEfora20; SQL>colACCOUNT_STATUSfora20; SQL>selectusername,user_id,account_status,expiry_datefromdba_userswhereusername= 'RAJESH'; USERNAMEUSER_IDACCOUNT_STATUSEXPIRY_DA

RAJESH55OPEN

Howtofindthedefaulttablespacesforadatabase
SQL>select*fromdatabase_propertieswherePROPERTY_NAMElike'%DEFAULT%'; SQL>connrajesh/rajesh Connected. SQL>select*fromsession_privs; SQL>select*fromsession_roles; SQL>select*fromv$pwfile_users; ROLE CONNECT RESOURCE

Ifauserwanttochangeuserpassword
SQL>connravi/ravi Connected. SQL>password ChangingpasswordforRAVI Oldpassword: Newpassword: Retypenewpassword: Passwordchanged

Howtocreatearole
SQL>createrolerole1; Rolecreated.

Toassignprivilegestorole1

SQL>grantconnect,createtable,createtablespace,createproceduretorole1; Grantsucceeded.

Assignaroletopurticulatuser.
SQL>grantrole1toravi; Grantsucceeded. SQL>select*fromdba_roles; Tosetapasswordtoarole1 SQL>alterrolerole1identifiedbyrole1; Rolealtered. Toknowwhatrtheprivshavebeenassignedtorole1 SQL>select*fromrole_sys_privswhererole='ROLE1'; Howtoremoveprivs SQL>revokecreatetablefromrole1; Revokesucceeded.

Assigningsysdbaprivilagetouser.andtheusercanshutdownandstartup database.
SQL>conn/assysdba Connected. SQL>grantsysdbatorajesh; Grantsucceeded. [user19@server3dbs]$rmorapwprod SQL>grantsysdbatoravi; ORA01994:GRANTfailed:passwordfilemissingordisabled [user19@server3dbs]$orapwdfile=orapwprodpassword=managerforce=y SQL>grantsysdbatoravi; [user19@server3~]$sqlplusravi/rajeshassysdba SQL>startup,SQL>shutimmediate

2.Tofinddefaulttablespaceforallusers. SQL>selectusername,default_tablespacefromdba_users; 3.toshowthestatusofauserwhethertheaccountislockedropen SQL>selectusername,account_statusfromdba_users; 4.tofindhowmuchamountofspacethatausercanuseintbs SQL>selectusername,tablespace_name,DROPPED,MAX_BLOCKSfromdba_ts_quotas; 5.tolistallusersandassociatedinformation SQL>selectusername,account_status,default_tablespace,temporary_tablespace,created,profile fromdba_users; 6.listingallprofilesandassignedlimits; SQL>select*fromdba_profilesorderbyprofile; 7.tocheckgrantedrolesandtheirprivilegesto<username>user SQL>selecta.grantee,a.granted_role,b.privilegefromdba_role_privsa,dba_sys_privsbwhere a.granted_role=b.granteeanda.grantee='rahul'; 8.tocheckthegrantedsystempriviligestouser<username>; SQL>select*fromdba_sys_privswheregrantee='ramu'; Assigningprivilegestoroles SQL>grantconnecttorole2; Grantsucceeded. SQL>grantselectanytabletorole2; Grantsucceeded. SQL>grantupdateanytabletorole2; Grantsucceeded.

SQL>grantexp_full_databasetorole2; Grantsucceeded. SQL>grantimp_full_databasetorole2; Grantsucceeded. SQL>showuser USERis"SYS" SQL>createuserrajidentifiedbyraj; Usercreated. SQL>grantrole2toraj; Grantsucceeded. SQL>connraj/raj; Connected. SQL>select*fromsession_privs; DBAVIEWSFORMANAGINGUSERS,ROLES,PRIVILEGES DBA_USERS DBA_ROLES DBA_COL_PRIVS DBA_ROLE_PRIVS DBA_SYS_PRIVS DBA_TAB_PRIVS ROLE_ROLE_PRIVS ROLE_SYS_PRIVS ROLE_TAB_PRIVS SESSION_PRIVS SESSION_ROLES V$PWFILW_USERS .DBA_TS_QUOTAS USER_TS_QUOTAS V$SESSION V$PROCESS USER_USERS

You might also like