2008年11月25日 星期二

Solaris Command

Finding Large Directories

to output the 10 largest directories in /var, sorted in ascending size order, use the following command:

  • du -ko /var|sort -n |tail -10
  • du -kod /var|sort -n |tail -10

Finding Large Files

1. Example 1: To find all plain files (not block, character, symbolic links, and so on) in a file system larger than 200,000 512-byte blocks (approximately 100 Mbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:

  • find / -size +200000 -type f -ls |sort -k 7,7 -n

2. To find all plain files (not block, character, symbolic links, and so on) in a /var file system larger than 1,000 512-byte blocks (approximately 500 Kbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:

  • find /var -size +1000 -type f -ls |sort -k 7,7 -n

2008年11月16日 星期日

Using DBMS_SYS_SQL Package to grant Privilege

SQL> declare
2 sqltext varchar2(200);
3 c integer;
4 begin
5 for userlist in (select user_id,username from all_users where username not in ('SYS','SYSTEM','EYGLE')) loop
6 for tablelist in (select owner,table_name from dba_tables where owner = userlist.username) loop
7 sqltext := 'grant all on '||tablelist.owner||'.'||tablelist.table_name ||' to eygle with grant option';
8 c := sys.dbms_sys_sql.open_cursor();
9 sys.dbms_sys_sql.parse_as_user( c,sqltext,dbms_sql.native,userlist.user_id);
10 sys.dbms_sys_sql.close_cursor(c);
11 end loop;
12 end loop;
13 end;
14 /

PL/SQL procedure successfully completed.

SQL>
SQL> set pause on
SQL> select owner,table_name,privilege,grantable from dba_tab_privs where grantee='EYGLE' and owner='SCOTT';
OWNER TABLE_NAME PRIVILEGE GRA
------------------------------ ------------------------------ ---------- ---
SCOTT BONUS ALTER YES
SCOTT BONUS DELETE YES
SCOTT BONUS INDEX YES
SCOTT BONUS INSERT YES
SCOTT BONUS SELECT YES
SCOTT BONUS UPDATE YES
SCOTT BONUS REFERENCES YES
SCOTT DEPT ALTER YES
SCOTT DEPT DELETE YES
SCOTT DEPT INDEX YES
SCOTT DEPT INSERT YES

OWNER TABLE_NAME PRIVILEGE GRA
------------------------------ ------------------------------ ---------- ---
SCOTT DEPT SELECT YES
SCOTT DEPT UPDATE YES
SCOTT DEPT REFERENCES YES
SCOTT EMP ALTER YES
SCOTT EMP DELETE YES
SCOTT EMP INDEX YES....