1. General Commands for tables
Creating a table
Command:
create table <table name> (<attribute1> data type, <attribute2> data
type,………………..<attribute N> data type);
Describing a table
Command:
Descibe tablename;
Inserting values into table
Command:
insert into <table name> values (<attribute1> , <attribute2> ,………………..<attribute
N> data type);
2. Creating Table with Primary Key Constraint
Command:
Create table tablename( <attribute1> datatype primary key);
Viewing the table
Command:
select * from <table name>;
Viewing selected columns in table
Command:
select * from <table name> where <attribute >=;
3. Altering the table to modify
Command:
Alter table tablename modify(<attribute> datatype);
Altering the table to add a column
Command:
Alter table tablename add(<attribute> datatype);
To arrange data in some particular order in table
(sorting)
Command:
select * from <table name> order by <col 1>, <col 2>;
4. To drop columns from a table
Command:
Alter table tablename drop column columnname;
Deleting a specific entry
Command:
delete from <table name> where <attribute 1=att. Value>;
To change the name of existing table
Command:
rename <old table name> to <new table name>;
5. Count Function
Command:
Select count(columnname) from tablename;
Count Distinct Function
Command:
Select count(distinct columnname) from tablename;
Maximum Function
Command:
Select max(columnname) from tablename;
9. Hyperbolic Sine Function
Command:
Select sinh(value) from dual;
Tangent Function
Command:
Select tan(value) from dual;
Inverse Tangent Function
Command:
Select atan(value) from dual;
10. Hyperbolic Tangent Function
Command:
Select tanh(value) from dual;
Exponenetial Function
Command:
Select exp(value) from dual;
Mod Function
Command:
Select mod(num1 , num2) from dual;
11. Power Function
Command:
Select power(num1 , num2) from dual;
Natural Log Function
Command:
Select ln(value) from dual;
Log Fuction
Command:
Select log(num , base) from dual;
12. Ceiling Function
Command:
Select ceil(value) from dual;
Floor Function
Command:
Select floor(value) from dual;
Greatest Value Function
Command:
Select greatest(num1 , num2) from dual;
13. Least Value Function
Command:
Select least(num1 , num2) from dual;
Sign Function
Command:
Select sign(num) from dual;
Square root of any value
Command:
Select sqrt(value) from dual;
14. Date Functions
To determine the system date of a computer
Command:
Select sysdate from dual;
To add months in a date
Command:
Select add_months(sysdate , monthnum) from dual;
To determine months between two dates
Command:
Select months_between(sysdate , ‘new date’) from dual;
15. To round off the month/year of a date
Command:
Select round(sysdate, ‘month/year) from dual;
To round off the month/year of a date using truncate
Command:
select trunc(‘date’, ‘month/year’) from dual;
To determine the next day of the date
Command:
select next_day(‘date’, ‘day’) from dual;
16. CHARACTER FUNCTION
To change the lower case of a string to upper case
Command:
select upper(‘string’) from dual;
To change the upper case of a string to lower case
Command:
select lower(‘string’) from dual;
To change the first case of a string to upper case
Command:
select initcap(‘string’) from dual;
17. To take out the substring from a string
Command:
select substr(‘string’ start, end) from dual;
To find the position of character in a string
Command:
select instr(‘string’, ‘character’) from dual;
To find the length of a string
Command:
select length(‘string’) from dual;
18. To concatenate the two strings
Command:
select concat(‘string 1’, ‘string 2’) from dual;
To insert symbol on left side in a string
Command:
select lpad(‘string’,size,’symbol’) from dual;
To insert symbol on right side in a string
Command:
select rpad(‘string’,size,’symbol’) from dual;
19. To trim the characters from left side in a string
Command:
select ltrim(‘string’,’characters’) from dual;
To trim the characters from right side in a string
Command:
select rtrim(‘string’,’characters’) from dual;
To replace the characters from a string
Command:
select replace(‘string’, ‘characters’, ’replacing characters’) from dual;