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

# Functions Numeric Functions Character Functions Date Fn. Group / Aggregate Fn. 1. Numeric Functions 1. ABS(n) 2.

Ceil (n) 3. Floor ( n) 4. Mod(m,n) 5. Power(m,n) 6. Sign(n) will return -1 if n<0 , 1 if n >0 , 0 if n=0 7. Sqrt(n) 8. Trunc(m,n) for decimal 9. Round(m,n) 10. Exp(n) 11.Greatest( n1,n2,n3,n....) 12.Least(n1,n2,n3,n....)

2. Character Functions 1. Initcap(string field) will convert first char. to Capital Letter 2. Lower(string) 3. Upper(string) 4. Lpad(string , n , char) Lpad('Ora' , 10,'*') =*******Ora 5. Rpad(string , n,char) Rpad('Ora', 10,'*') = Ora******* 6. Ltrim(string) 7. Rtrim(string) 8. Substr(string , start pos., no. of characters to extract ) eg. Su bstr('computer',3,3) = put 9. Length (string) 10. Instr ( string , char to search ) will return first occurence of the char. from string 11. Instr ( string , char to search , Starting Pos. , pos. of occurence ) 12. Trim(string) Trim(' Ora ') 13. Trim(leading 'x' from string ) 14. Trim(Both 'x' from string ) 15. Decode ( field to check , value to compare,True , False) same as if condition if (field to compare , True value , Fals e value ) if (field to compare , True value, field to compare , True Value , field to compare ,True , False ) e.g. select decode(job,'CLERK',11,'SALESMAN',12,'MANAGER',13,14 ) ,JOB FROM EMP;

same as

16. Translate (string , 'String to translate' , 'String to replace' ) Find and Replace e.g. Translate ( '456Oracle123' , '423' , '796' ) output : 756Oracle196

3. Date Functions

1. 2. 3. 4. 5. 6.

Sysdate will return system date Add_months (date , no.) Months_between(date1 , date2) Last_day(date) Next_day(date , day ) e.g Next_day (sysdate , 'Friday') Extract ( year from datefield) will extract year from date Extract( month from datefield) Extract(day from datefield) Extract(minute from datefield)

4. Group / Aggregate Functions ( It affects to whole table ) 1. 2. 3. 4. 5. Count ( ) Max( ) Min( ) Avg( ) Sum( ) e.g 1. Select count(*) as 'Total Emp' from Emp; 2. Select max(Salary) as 'Max Sal' from Emp; 3. Select min(Salary ) as 'Min Sal' from Emp; 4. Select Avg(Salary) as 'Average ' from Emp; 5. Select Sum(Salary ) as ' Total Salary' from Emp; -------------- All group fn. in one --------------Select Count(*) as 'Count' , max(salary ) as 'Max Salary ' , min(salary ) as 'Min Salary' as 'Average Salary' , sum (salary) as 'Total Salary ' from Emp; , Avg(salary) will count no. of records in table will return maximum amount from numeric field will return minimum amount from numeric field will return Average value from numeric field will do summation of numeric field

******************************** ****** 1. 2. 3. 4. 5. 6. Not Null Check Default Primary key Foreign Key Unique

Constraints

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

Constraint can be defined at column level and table level *** Giving multiple constraint Create Table myTab ( no name number(4) Not Null Primary key, varchar2(30) ,