数据库oracle学习之路.docx
《数据库oracle学习之路.docx》由会员分享,可在线阅读,更多相关《数据库oracle学习之路.docx(39页珍藏版)》请在优知文库上搜索。
1、数据库oracle学习之路1 .数据库基础2 .数据库主键生成SelectSubstr(To_char(dbms_random.value),2,22)IIgetUUID.NextvalFromdual;3 .数据库空间查询表空间在什么空间下selectdf.tablespace_name表空间名,totalspace总空间M,freespace”剩余空间M,zround(l-freespacetotalspace)*100,2)from(selecttablespace-name,rond(sum(bytes)10241024)totalspacefromdba_data_filesgrou
2、pbytablespace_name)df,(selecttablespace-name,rond(sum(bytes)10241024)freespacefromdba_free_spacegroupbytablespace_name)fswheredf.tablespace_name=fs.tablespace_name;一查用户下所用空间SELECTowner,tablespace,namezROUND(SUM(BYTES)/1024/1024,2)USED(M)FROMdba_segmentsGROUPBYowner,tablespace_nameORDERBYSUM(BYTES)DE
3、SC;-查用户下所有表所占空间selectOWNER,t.segment_name,t.segment-typ/sum(t.bytes/1024/1024)mmmfromdba_segmentstwheret.owner=JIANGSU,andt.segment-type=TABLE,groupbyOWNER,t.segment_name,t.segment_typeorderbymmmdesc;4. oracle之删除重复数据selecta.rowid,a.*from表名awherea.rowid!=(selectmax(b.rowid)from表名bwherea.字段1=b.字段1anda
4、.字段2=b.字段2)一删除deletefrom表名awherea.rowid!=(selectmax(b.rowid)from表名bwherea.字段1=b.字段1anda.字段2=b.字段2)5. oracle之查询数据第一条记录select*fromtabrownum.regexp_substr函数,与substr类似,用于拾取合符正则表达式描述的字符子串,语法如下:REGEXPSUBSTRIJroecrregexpjnstr函数,与instr类似,用于标定符合正则表达式的字符子串的开始位置,语法如下:T REGEXPNSTR f)our8/仙*patterDregexp_replace
5、函数,与replace类似,用于替换符合正则表达式的字符串,语法如下:REGEXPREPIACEPattemAegexp-replace FZrGTXepb8.String)2rsqlplsZnologSQL*Plus:Release9.2.0.4.0-ProductiononFriJan2002:29:372006Copyright(c)1982,2002,OracleCorporation.Allrightsreserved.SQLconnect/assysdbaConnectedtoanidleinstance.SQLstartupORACLEinstancestarted.TotalS
6、ystemGlobalArea135352820bytesFixedSize455156bytesVariableSize109051904bytesDatabaseBuffers25165824bytesRedoBuffers679936bytesDatabasemounted.2)关闭数据库:OraeIeSLlSe92sqlplusnologSQL*Plus:Release9.2.0.4.0-ProductiononFriJan2002:29:372006Copyright(c)1982,2002,OracleCorporation.Allrightsreserved.SQLconnect
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 oracle 学习
