Вы находитесь на странице: 1из 11

********************************************************************************

*******************
#### Daily Activity ####
********************************************************************************
*******************
02/02/08:-- We got a Sev1 on Saturday ,2nd Feb for File System usage increased b
eyond 98% on
pokxopi9 websphere file system.
Robert Whaley Called me around 9:00 am IST. I worked for that
,searched few huge files and
compressed them.I decreased usage upto 75%. MN ticket number was #34
553927. I have closed that
ticket.I compressed following logs from year 2007
-rw-r--r-- 1 opicmadm opicadmg 52709398 Aug 28 09:13 ./installedApps/pokxopi
9/eacm.ear/bui.war/temp/CtoSbb20070828091159.123
-rw-rw-rw- 1 opicmadm opicadmg 53096006 Aug 30 07:41 ./installedApps/pokxopi
9/eacm.ear/bui.war/temp/CtoSbb20070830073948.123
......................
......................
......................
************************************************************
*********

************************************************************
*********
cat9tail
while true
do
clear;
echo;echo;echo;
date;
echo;
rpt;
echo;echo;echo;
date
sleep 1800;
done

while true
do
clear;
echo;echo;echo;
date;
echo;
mon;
echo;echo;echo;
date
sleep 1800;
done

while true
do
clear;
echo;echo;echo;
date;
echo;
df -g ./;
df -g|grep opicmdb2;
echo;echo;echo;
date
sleep 1800;
done

ea4-PROD-/home/opicmadm=>find . -size +50549203c -exec ls -ltr {} \;|grep -iv "z


$"
\-rwx------ 1 opicmadm opicadmg 75349265 Jun 08 2007 ./pad/Prd_Migration/AC
TA_data_exp_imp_Load/char_value.ixf
-rw-r----- 1 opicmadm opicadmg 53698560 Jun 04 2007 ./bigcat/bigcat.tar
-rw------- 1 opicmadm opicadmg 75288399 Jun 06 2007 ./bertil/eAnnv12/id/All
.ixf.tar.Z.060607.ProdIDBckup
-rw-r----- 1 opicmadm opicadmg 65708658 Jun 27 2007 ./CATNAV1.ixf
-rw------- 1 opicmadm opicadmg 60897748 Dec 11 15:24 ./x
-rw-r----- 1 opicmadm opicadmg 51469138 Jun 09 2007 ./catdb/ddl/wwcto1.del
-rw-r----- 1 opicmadm opicadmg 51469138 Jun 09 2007 ./catdb/ddl/wwcto.del
-rw------- 1 opicmadm opicadmg 58552105 Jun 26 2007 ./catdb/ccto2
-rw------- 1 opicmadm opicadmg 86061849 Aug 29 2007 ./catdb/WWProdCompatCol
lection.200708281353
-rw-r----- 1 opicmadm opicadmg 77147362 Dec 05 13:19 ./catdb/trsnetterpass1b
.del
ea4-PROD-/home/opicmadm=>gzip ./catdb/trsnetterpass1b.del
ea4-PROD-/home/opicmadm=>o.del ./catdb/ddl/wwcto1.del ./x ./CATNAV1.ixf
<
ea4-PROD-/home/opicmadm=>df -g ./
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/opicmadmlv 19.47 6.48 67% 12296 1% /home/opicmadm
ea4-PROD-/home/opicmadm=>gzip ./catdb/WWProdCompatCollection.200708281353

02032301169
********************************************************************************
*******************************
************************************************** AIX ************************
****************************
********************************************************************************
*******************************
### Links ###

********************************************************************************
*******************************
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9][0-9]%/ {print "Used FS is : "
$4}'
Used FS is : 60%

e25ciapp004-/home/opicmadm/ajay=>df ./
Filesystem 512-blocks Free %Used Iused %Iused Mounted on
/dev/lv01 26214400 10647328 60% 6673 1% /home/opicmadm
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '{print $3}'
Free
10647328
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '{print $4}'
%Used
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9][0-9]/ {print $4}'
%Used
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '{print "Used FS is : " $4}'
Used FS is : %Used
Used FS is : 60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/*%/ {print "Used FS is : " $4}'
awk: 0602-521 There is a regular expression error.
*?+ not preceded by valid expression
The source line number is 1.
The error context is
>>> /*%/ <<< {print "Used FS is : " $4}
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9][0-9]%/ {print "Used FS is : "
$4}'
Used FS is : 60%
e25ciapp004-/home/opicmadm/ajay=>n=df ./|awk '/[0-9][0-9]%/{print $4}';echo 'Val
ue is $n';
ksh: ./: cannot execute
Value is $n
e25ciapp004-/home/opicmadm/ajay=>n=df ./|awk '/[0-9][0-9]%/{print $4}';echo "Val
ue is $n";
ksh: ./: cannot execute
Value is
e25ciapp004-/home/opicmadm/ajay=>echo 'n=df ./|awk '/[0-9][0-9]%/{print $4}'';ec
ho "Value is $n";
n=df ./|awk /[0-9][0-9]%/{print }
Value is
e25ciapp004-/home/opicmadm/ajay=>echo "n=df ./|awk '/[0-9][0-9]%/{print $4}'";ec
ho "Value is $n";
n=df ./|awk '/[0-9][0-9]%/{print }'
Value is
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9]+%/{print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9]+%/ $4>=60 {print $4}'
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9]+%/ $4>=50 {print $4}'
e25ciapp004-/home/opicmadm/ajay=>df ./|awk '/[0-9]+%/ $4>50 {print $4}'
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4>50 {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4>60 {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4>70 {print $4}'
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4>61 {print $4}'
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4>59 {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4 > /59/ {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4 > /64/ {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4 > /^6/ {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>df ./|awk ' $4 > /^7/ {print $4}'
60%
e25ciapp004-/home/opicmadm/ajay=>who
opicmadm pts/0 Oct 16 07:34 (adashore.in.ibm.com)
opicmadm pts/2 Oct 15 15:59 (9.50.67.97)
you have mail in /usr/spool/mail/opicmadm
e25ciapp004-/home/opicmadm/ajay=>echo "There are ($who|wc -l) users on the syste
m"
There are (|wc -l) users on the system
e25ciapp004-/home/opicmadm/ajay=>echo "There are $(who|wc -l) users on the syste
m"
There are 2 users on the system
e25ciapp004-/home/opicmadm/ajay=>

********************************************************************************
*******************************
************************************************** ORACLE *********************
*******************************
********************************************************************************
*******************************
### Links ###
http://sqlbible.tar.hu/sqlbible0076.html#604
http://www.oracle-base.com/articles/8i/CostBasedOptimizerAndDatabaseStatistics.p
hp
http://www.oracle.com/oramag/oracle/01-jan/o11sql.html
http://www.dbazine.com/oracle/or-articles/
http://www.dbazine.com/oracle/or-articles/foot4
http://www.dbazine.com/oracle/or-articles/foot5
http://www.oracle.com/technology/oramag/oracle/02-sep/o52ocp.html
http://www.oracle.com/oramag/oracle/02-jul/o42ocp.html
All Oracle Magazine Editions are available here
http://www.oracle.com/oramag/oracle/index.html
PL/SQL best practice from ORACLE.
http://www.oracle.com/technology/oramag/oracle/plsql/index.html
All publication's pdf and html
http://www.akadia.com/html/publications.html#Oracle%20Publications%20(PDF)
********************************************************************************
*******************************
##Second largest value from list
select * from ( select a.*, ROWNUM rnum
from ( select first_name,salary from employees
order by salary desc ) a
where ROWNUM <= 10 )
where rnum =2
********************************************************************************
*******************************
Long--> Var len char data upto 2GB.
timestamp<0-9/6>
timestamp<0-9/6> with time zone (time zone displacement in hr,mm)
timestamp<0-9/6> with local time zone (data stored as db time zone)
BLOB/BFILE---> unstructured binary data (max 4GB)
CLOB --- Char data
ANALYZE TABLE ORDERS VALIDATE STRUCTURE;
If Oracle encounters bad rows, it inserts them into the INVALID_ROWS table.
To specify a different table name, use the following syntax.
ANALYZE TABLE ORDERS VALIDATE STRUCTURE
INTO SCOTT.CORRUPTED_ROWS;
You can also validate the blocks of the indexes associated with the table by
specifying the CASCADE clause.
ANALYZE TABLE ORDERS VALIDATE STRUCTURE CASCADE;
A row is migrated if the row is moved from its original block to another
block because there was not enough free space available in its original block
to accommodate the row, which was expanded due to an update.
A row is chained if the row is bigger than the block size of the database.
Analyze the table to find migrated rows.Only the ROWIDs are listed in the CHAINE
D_ROWS table
ANALYZE TABLE ORDERS LIST CHAINED ROWS;
You can calculate
the exact statistics (COMPUTE) of the table or sample a few rows and
estimate the statistics (ESTIMATE).
ANALYZE command to collect statistics:
The total number of rows in the table and the number of chained rows
The total number of blocks allocated, the total number of unused
blocks, and the average free space in each block
The average row length
ANALYZE TABLE ORDERS COMPUTE STATISTICS;
When using the ESTIMATE option, you can either specify a certain number
of rows or specify a certain percentage of rows in the table. If the rows specif
ied are more than 50 percent
of the table, Oracle does a COMPUTE. If you do not specify the SAMPLE clause, Or
acle samples 1064 rows.
ANALYZE TABLE ORDERS ESTIMATE STATISTICS SAMPLE 200 ROWS;
ANALYZE TABLE ORDERS ESTIMATE STATISTICS SAMPLE 20 PERCENT;
ANALYZE TABLE ORDERS DELETE STATISTICS;

Cost Based Optimizer (CBO) and Database Statistics


Whenever a valid SQL statement is processed Oracle has to decide how to retrieve
the necessary data. This decision can be made using one of two methods:
Rule Based Optimizer (RBO) - This method is used if the server has no internal s
tatistics relating to the objects referenced by the statement. This method is no
longer favoured by Oracle and will be desupported in future releases.
Cost Based Optimizer (CBO) - This method is used if internal statistics are pres
ent. The CBO checks several possible execution plans and selects the one with th
e lowest cost, where cost relates to system resources.
The foreign key is the column or columns in the table (child table) in which
the constraint is created; the referenced key is the primary key, the unique
key column, or columns in the table (parent table) that is referenced by the
constraint.
The ON DELETE clause specifies the action to be taken when a row in
the parent table is deleted and child rows exist with the deleted parent
primary key. You can delete the child rows (CASCADE) or set the foreign
key column values to NULL (SET NULL). If you omit this clause,
Oracle will not allow you to delete from the parent table if child
records exist.
You have seen how to enable and disable a constraint. ENABLE and DISABLE
affect only future data that will be added/modified in the table. In contrast,
the VALIDATE and NOVALIDATE keywords in the ALTER TABLE command act
on the existing data. Therefore, a constraint can have four states:
ENABLE VALIDATE This is the default for the ENABLE clause. The
existing data in the table is validated to verify that it conforms to
the constraint.
ENABLE NOVALIDATE This constraint does not validate the existing
data, but enables the constraint for future constraint checking.
DISABLE VALIDATE The constraint is disabled (any index used to
enforce the constraint is dropped), but the constraint remains valid.
No DML operation is allowed on the table because future changes
cannot be verified.
DISABLE NOVALIDATE This is the default for the DISABLE clause. The
constraint is disabled, and no checks are done on future or existing dat
a.
Oracle does not allow any inserts/updates/deletes on a table with a DISABLE
VALIDATE constraint. Changing the constraint status to DISABLE VALIDATE is
a quick way to make a table read-only.
A database is an organized collection of information.
To manage databases, you need database management systems (DBMS). A DBMS is a pr
ogram that
stores, retrieves, and modifies data in the database on request. There are four
main types of databases:
hierarchical, network, relational, and more recently object relational.
The relational model consists of the following:
Collection of objects or relations
Set of operators to act on the relations
Data integrity for accuracy and consistency
BETWEEN AND is actually translated by Oracle server to a pair of AND conditions:
(a >=
lower limit) AND (a <= higher limit). So using BETWEEN AND has no
performance benefits
IN ( ... ) is actually translated by Oracle server to a set of OR conditions: a
=
value1 OR a = value2 OR a = value3. So using IN ( ... ) has no performance
benefits
SELECT employee_id, last_name, job_id
FROM employees
WHERE job_id LIKE %SA\_% ESCAPE \ ;
Override rules of precedence by using parentheses.
Order Evaluated Operator
1 Arithmetic operators
2 Concatenation operator
3 Comparison conditions
4 IS [NOT] NULL, LIKE, [NOT] IN
5 [NOT] BETWEEN
6 NOT logical condition
7 AND logical condition
8 OR logical condition
SELECT last_name, job_id, salary
FROM employees
WHERE job_id = SA_REP
OR job_id = AD_PRES
AND salary > 15000;
Select the row if an employee is a president and earns more than $15,000, or if
the employee is a
sales representative.
The order of execution for a SELECT statement is as follows:
FROM clause
WHERE clause
SELECT clause
ORDER BY clause
***You can sort by a column that is not in the SELECT list.
INSTR(column|expression, string , [,m], [n] )
LPAD(column|expression, n, string )
RPAD(column|expression, n, string )
TRIM(leading|trailing|both, trim_character FROM trim_source)
REPLACE(text,search_string,replacement_string)
How to enter "Rajiv's" in a column? or update by this value?
SELECT ROUND(45.923,2)=45.92, ROUND(45.923,0)=46,
ROUND(45.923,-1)=50
FROM DUAL;
SELECT TRUNC(45.923,2)45.92, TRUNC(45.923)=45,
TRUNC(45.923,-2)=0
FROM DUAL;
********************************************************************************
*******************
SELECT CUST_GENDER gender
,NVL(cust_marital_status,'unknown') marital_status
,COUNT(*)
FROM sh.customers
GROUP BY cust_gender,ROLLUP(NVL(cust_marital_status,'unknown'));
GENDER MARITAL_STATUS COUNT(*)
------ -------------- ----------
F married 4701
F single 5898
F unknown 5716
F 16315 (subtotal)
M married 9328
M single 12868
M unknown 11489
M 33685 (subtotal)
The Field which is in rollup will be rolled and sum for filed outside rollup in
group by clause will be dispalyed.
for in example above cust_gender is in GROUP BY but out side of ROLLUP there for
group some for each gender (value)
cust_gender is displayed.
SELECT CUST_GENDER gender
,NVL(cust_marital_status,'unknown') marital_status
,COUNT(*)
FROM sh.customers
GROUP BY ROLLUP(cust_gender,NVL(cust_marital_status,'unknown'));
GENDER MARITAL_STATUS COUNT(*)
------ -------------- ----------
F married 4701
F single 5898
F unknown 5716
F 16315 (subtotal)
M married 9328
M single 12868
M unknown 11489
M 33685 (subtotal)
50000 (grand total)

SELECT CUST_GENDER gender


,NVL(cust_marital_status,'unknown') marital_status
,COUNT(*)
FROM sh.customers
GROUP BY ROLLUP(NVL(cust_marital_status,'unknown'),cust_gender);
GENDER MARITAL_STATUS COUNT(*)
------ -------------------- ----------
F married 4701
M married 9328
married 14029 (subtotal)
F single 5898
M single 12868
single 18766 (subtotal)
F unknown 5716
M unknown 11489
unknown 17205 (subtotal)
50000 (grand total)
JOIN:---->>
To execute a join of three or more tables, Oracle takes these steps:
1. Oracle joins two of the tables based on the join conditions, comparing thei
r columns.
2. Oracle joins the result to another table, based on join conditions.
3. Oracle continues this process until all tables are joined into the result.
An outer join (containing the (+) operator) cannot be combined with another cond
ition using the OR or IN logical
operators. For example, the following query is not valid.
SQL> SELECT c.country_name, l.city
2 FROM countries c, locations l
3 WHERE c.country_id = l.country_id (+)
4* OR l.city (+) LIKE 'B%';
The following query works, because the outer-join operator is used on the LOCATI
ONS table and the IN condition
is on the column from COUNTRIES table.
SQL> SELECT c.country_name, l.city
2 FROM countries c, locations l
3 WHERE c.country_id = l.country_id (+)
4* AND c.country_name IN ('India','Israel');
FULL OUTER JOIN
=============
SELECT e.employee_id, e.last_name,
d.department_id, d.department_name
FROM employees e FULL OUTER JOIN departments d
ON e.department_id = d.department_id;
Trying to perform a similar query with the outer-join operator will producean er
ror:
SQL> SELECT e.employee_id, e.last_name, d.department_name
2 FROM employees e, departments d
3* WHERE e.department_id (+) = d.department_id (+)
SQL> /
WHERE e.department_id (+) = d.department_id (+)
*
ERROR at line 3:
ORA-01468: a predicate may reference only one outer-joined table
SQL>
The full outer join can be achieved using the UNION operator and the outer-join
operator, as in the following query:
SELECT e.employee_id, e.last_name, d.department_name
FROM employees e, departments d
WHERE e.department_id (+) = d.department_id
UNION
SELECT e.employee_id, e.last_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id (+);

CONSTRAINT:-- A constraint can be considered as a rule or policy defined in the


database to enforce data
integrity and business rules.
Table:-Defined with columns and stores rows of data. A table should have at leas
t one column.You can also create
object tables and temporary tables. Temporary tables are used to hold t
emporary data specific to a transaction
or session.
View:- A customized representation of data from one or more tables and/ or views
. Views are used as a window
to show information from tables in a certain way or to restrict the in
formation. Views are queries stored in
the database that select data from one or more tables.
Sequence:- A way to generate continuous numbers. Sequences are useful for genera
ting unique serial numbers
or key values. The sequence definition is stored in the data dict
ionary.
Synonym:- An alias for any table, view, sequence, or other accessible database o
bject. Because a synonym is
simply an alias, it requires no storage other than its definition in t
he data dictionary. Synonyms are
useful because they hide the identity of the underlying object. T
he object can even be part of another
database. A public synonym is accessible to all users of the datab
ase; and a private synonym is accessible
only to its owner.
Index:- A structure associated with tables used to speed up the queries. An inde
x is an access path to reach the
desired row faster. Oracle has B-tree and bitmap indexes. Creating and d
ropping indexes does not affect the storage
of data in the underlying tables. You can create unique or nonunique ind
exes. In most cases unique indexes are
created automatically by Oracle when you create a primary key or a uniqu
e key constraint in a table.
A composite index has more than one column in the index.
FOREIGN KEY Establishes a parent-child relationship between tables by using comm
on columns. The foreign key
defined on a table refers to the primary key or unique key o
f another table.
A foreign key constraint protects one or more columns in a table by ensuring t
hat for each non-NULL value there is
data available elsewhere in the database with a primary or unique key. The fore
ign key is the column or columns in
the able (child table) where the constraint is created. The referenced key is t
he primary key or unique key column or
columns in the table (parent table) that is referenced by the constraint. The c
olumn data types in parent table and
child table should match.
ENABLE and DISABLE affect only future data that will be added or modified in the
table.
In contrast, the VALIDATE and NOVALIDATE keywords in the ALTER TABLE statement a
ct on the existing data.
Therefore, a constraint can have four states:
1) ENABLE VALIDATE This is the default for the ENABLE clause. The existing data
in the table is validated to verify
that it conforms to the constraint.
2) ENABLE NOVALIDATE This does not validate the existing data, but enables the c
onstraint for future constraint
checking.
3) DISABLE VALIDATE The constraint is disabled (any index used to enforce the co
nstraint is also dropped),
but the constraint is kept valid. No DML operation is allowed on the table b
ecause future changes cannot be
verified.
4) DISABLE NOVALIDATE This is the default for the DISABLE clause. The constraint
is disabled, and no checks are
done on future or existing data.

WorldWideProductCollection.200711131307.gz
FeatureCollection.200711121230.gz
WWProdCompatCollection.200711132030.gz
WWProdCompatCollection.200711122030.gz

http://www.oracle-base.com/articles/9i/Case9i.php

Вам также может понравиться