时间:2021-05-24
1. 查询本节点及本节点以下的所有节点:
select * from table1 c start with c.p_id='0000000' connect by prior c.id=c.p_id and c.use_yn='Y' order by id ;2. 查询节点中所有的层级关系
SELECT RPAD( ' ', 2*(LEVEL-1), '-' ) || DEPNAME "DEPNAME",CONNECT_BY_ROOT DEPNAME "ROOT",CONNECT_BY_ISLEAF "ISLEAF",LEVEL ,SYS_CONNECT_BY_PATH(DEPNAME, '/') "PATH" FROM DEP START WITH UPPERDEPID IS NULL CONNECT BY PRIOR DEPID = UPPERDEPID;1> CONNECT_BY_ROOT 返回当前节点的最顶端节点 2> CONNECT_BY_ISLEAF 判断是否为叶子节点,如果这个节点下面有子节点,则不为叶子节点 3> LEVEL 伪列表示节点深度 4> SYS_CONNECT_BY_PATH函数显示详细路径,并用“/”分隔3. 对数据库表结构的操作
alter table taxasset add (NEXTDATE varchar2(30));alter table tax_dep_manager modify FDDBRXM varchar2(120);alter table test1 drop column name;4. 其他查询
select 'alter system kill session '''||sid||','||serial#||''';' from v$session where username = 'USERS';select * from user_tablespaces;select username,default_tablespace from dba_users where username='ZZS'select count(*) from user_views; --yb53 zzs 53select count(*) from user_tables; --yb413 zzs 413--查询表空间使用情况SELECT Upper(F.TABLESPACE_NAME) "表空间名",D.TOT_GROOTTE_MB "表空间大小(M)",D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), '990.99')|| '%' "使用比",F.TOTAL_BYTES "空闲空间(M)",F.MAX_BYTES "最大块(M)" FROM (SELECT TABLESPACE_NAME,Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES,Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F,(SELECT DD.TABLESPACE_NAME,Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MBFROM SYS.DBA_DATA_FILES DDGROUP BY DD.TABLESPACE_NAME) DWHERE D.TABLESPACE_NAME = F.TABLESPACE_NAMEORDER BY 1--查询表空间的free spaceselect tablespace_name,count(*) AS extends,round(sum(bytes) / 1024 / 1024, 2) AS MB,sum(blocks) AS blocksfrom dba_free_spacegroup BY tablespace_name;--查询表空间的总容量select tablespace_name, sum(bytes) / 1024 / 1024 as MB from dba_data_files group by tablespace_name;--表空间容量查询SELECT TABLESPACE_NAME "表空间",To_char(Round(BYTES / 1024, 2), '99990.00')|| '' "实有",To_char(Round(FREE / 1024, 2), '99990.00')|| 'G' "现有",To_char(Round(( BYTES - FREE ) / 1024, 2), '99990.00')|| 'G' "使用",To_char(Round(10000 * USED / BYTES) / 100, '99990.00')|| '%' "比例"FROM (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,Floor(A.BYTES / ( 1024 * 1024 )) BYTES,Floor(B.FREE / ( 1024 * 1024 )) FREE,Floor(( A.BYTES - B.FREE ) / ( 1024 * 1024 )) USEDFROM (SELECT TABLESPACE_NAME TABLESPACE_NAME,Sum(BYTES) BYTESFROM DBA_DATA_FILESGROUP BY TABLESPACE_NAME) A,(SELECT TABLESPACE_NAME TABLESPACE_NAME,Sum(BYTES) FREEFROM DBA_FREE_SPACEGROUP BY TABLESPACE_NAME) BWHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME)ORDER BY Floor(10000 * USED / BYTES) DESC;6. loop 的使用
DECLAREcon number;BEGINcon :=1;LOOPDBMS_OUTPUT.PUT_LINE(con);con:=con+1;EXIT WHEN con>100;END LOOP;DBMS_OUTPUT.PUT_LINE('完了');END;7. 存储过程的书写
create or replace procedure InsertBranch(tablename in varchar2) ascounts number;num number;begincreate table tempdata (column1 nvarchar2,column2 nvarchar2,column3 nvarchar2);insert tempdata num := 1;select count(*) into counts from tablename;dbms_output.put_line('数据总数'+counts);while num <= counts loopdbms_output.put_line('循环开始:');dbms_output.put_line('第'+num+'条数据');select column1into column1from (select tablename.*, rownum as con from tablename)where con = num;select column2into column2from (select tablename.*, rownum as con from tablename)where con = num;select column3into column3from (select tablename.*, rownum as con from tablename)where con = num;insert into COM_DEPARTMENTvalues(brno,brname,upbrno,upbrno,'N',null,null,null,'1',null,'Y','2',null,null,null,2,'N',null,null,null,'N',brno,upbrno,null,null,null,'A','N','N',0,0,3,null,null,null,'0','0',0,null,null,null,null,null,null,null);num := num + 1;end loop;end;以上所述是小编给大家介绍的Oracle 数据库特殊查询总结,希望对大家有所帮助!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文介绍了在Oracle10g中利用列值掩码技术隐藏敏感数据的方法。Oracle的虚拟私有数据库特性(也称作细颗粒度存取控制)对诸如SELECT等数据管理语言D
Oracle数据库中查询重复数据:select*fromemployeegroupbyemp_namehavingcount(*)>1;Oracle查询可以删除
电子商务网站数据库特殊账号管理。在电子商务网站建设过程中,数据库的安全控制部门一定要对特殊性的账号管理工作给予高度重视,能够保障特殊性账号的安全性。例如在建设电
本篇文章给大家介绍在oracle9i中使用闪回查询恢复数据库误删问题,涉及到数据库增删改查的基本操作,对oracle数据库闪回查询感兴趣的朋友可以一起学习下本篇
正在看的ORACLE教程是:Oracle数据库快照的使用。oracle数据库的快照是一个表,它包含有对一个本地或远程数据库上一个或多个表或视图的查询的结果。正因