tailieunhanh - OCA: Oracle Database 11g Administrator Certified Associate- P6

Tham khảo tài liệu 'oca: oracle database 11g administrator certified associate- p6', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Utilizing Aggregate Functions 181 F single 47 M single 92 married 180 F married 63 M married 117 More DBA Queries In the Exploring DBA Queries Using Aggregate Functions sidebar you saw some queries written to find out the space allocated by tablespace the space allocated by schema and the space allocated by tablespace and schema. These were written using three different SQL statements. You can see the power of CUBE in the following SQL. The results from all the three SQL statements you tried before are in this summary report showing the different levels of aggregation. SELECT tablespace_name owner SUM bytes 1048576 size_mb FROM dba_segments GROUP BY CUBE tablespace_name owner TABLESPACE_NAME OWNER SIZE_MB - Grand Total HR - Subtotal HR schema IX - Subtotal IX schema OE FLOWS - Subtotal FLOWS schema USERS - Subtotal USERS tablespace USERS HR .1875 - HR schema in USERS tablespace USERS OE - OE schema in USERS tablespace USERS SH 2 USERS SCOTT .375 USERS BTHOMAS SYSAUX - Subtotal SYSAUX tablespace SYSAUX FLOWS SYSTEM - Subtotal SYSTEM tablespace SYSTEM SYS 182 Chapter 3 Using Group Functions SYSTEM OUTLN .5625 SYSTEM SYSTEM EXAMPLE EXAMPLE HR As you can see in the result the space used by each schema in each tablespace is shown as well as the total space used in each tablespace and the total space used by each schema. The total space used in the database including all tablespaces is also shown in the very first line. Three functions come in handy with the ROLLUP and CUBE modifiers of the GROUP BY clause GROUPING GROUP_ID and GROUPING_ID. In the examples you have seen using the ROLLUP and CUBE modifiers there was no way of telling which row is a subtotal and which row is a grand total. You can use the GROUPING function to overcome this problem. Review the following SQL example SELECT gender marital_status count num_rec GROUPING gender g_grp GROUPING .

TỪ KHÓA LIÊN QUAN