Oracle PL/SQL Tutorial/SQL PLUS Session Environment/Usename

Материал из SQL эксперт
Перейти к: навигация, поиск

Count user name

SQL>
SQL> SELECT COUNT(username) users, default_tablespace
  2  FROM dba_users
  3  where rownum<50
  4  GROUP BY default_tablespace
  5  /
     USERS DEFAULT_TABLESPACE
---------- ------------------------------
         6 SYSAUX
         2 USERS
         7 SYSTEM
SQL>


SELECTs using the GROUP BY clause.

SQL>
SQL> SELECT username, default_tablespace
  2  FROM dba_users
  3  where rownum<50
  4  GROUP BY default_tablespace, username;
USERNAME                       DEFAULT_TABLESPACE
------------------------------ ------------------------------
SYS                            SYSTEM
SYSTEM                         SYSTEM
CTXSYS                         SYSAUX
sqle                         SYSTEM
OUTLN                          SYSTEM
DIP                            SYSTEM
HR                             USERS
ANONYMOUS                      SYSAUX
PLSQL                          USERS
TSMSYS                         SYSTEM
FLOWS_FILES                    SYSAUX
XDB                            SYSAUX
MDSYS                          SYSTEM
DBSNMP                         SYSAUX
FLOWS_020100                   SYSAUX
15 rows selected.
SQL>