Download - Dbms file
General Commands for tables
Creating a tableCommand:
create table <table name> (<attribute1> data type, <attribute2> datatype,………………..<attribute N> data type);
Describing a tableCommand:
Descibe tablename;
Inserting values into tableCommand:
insert into <table name> values (<attribute1> , <attribute2> ,………………..<attributeN> data type);
Creating Table with Primary Key ConstraintCommand:
Create table tablename( <attribute1> datatype primary key);
Viewing the tableCommand:
select * from <table name>;
Viewing selected columns in tableCommand:
select * from <table name> where <attribute >=;
Altering the table to modifyCommand:
Alter table tablename modify(<attribute> datatype);
Altering the table to add a columnCommand:
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>;
To drop columns from a tableCommand:
Alter table tablename drop column columnname;
Deleting a specific entryCommand:
delete from <table name> where <attribute 1=att. Value>;
To change the name of existing tableCommand:
rename <old table name> to <new table name>;
Count FunctionCommand:
Select count(columnname) from tablename;
Count Distinct FunctionCommand:
Select count(distinct columnname) from tablename;
Maximum FunctionCommand:
Select max(columnname) from tablename;
Minimum FunctionCommand:
Select sum(columnname) from tablename;
Average FunctionCommand:
Select avg(columnname) from tablename;
Numeric Functions
Absolute FunctionCommand:
Select abs(value) from dual;
Cosine FunctionCommand:
Select cos(value) from dual;
Inverse Cosine FunctionCommand:
Select acos(value) from dual;
Hyperbolic CosineCommand:
Select cosh(value) from dual;
Sine FunctionCommand:
Select sin(value) from dual;
Inverse Sine FunctionCommand:
Select asin(value) from dual;
Hyperbolic Sine FunctionCommand:
Select sinh(value) from dual;
Tangent FunctionCommand:
Select tan(value) from dual;
Inverse Tangent FunctionCommand:
Select atan(value) from dual;
Hyperbolic Tangent FunctionCommand:
Select tanh(value) from dual;
Exponenetial FunctionCommand:
Select exp(value) from dual;
Mod FunctionCommand:
Select mod(num1 , num2) from dual;
Power FunctionCommand:
Select power(num1 , num2) from dual;
Natural Log FunctionCommand:
Select ln(value) from dual;
Log FuctionCommand:
Select log(num , base) from dual;
Ceiling FunctionCommand:
Select ceil(value) from dual;
Floor FunctionCommand:
Select floor(value) from dual;
Greatest Value FunctionCommand:
Select greatest(num1 , num2) from dual;
Least Value FunctionCommand:
Select least(num1 , num2) from dual;
Sign FunctionCommand:
Select sign(num) from dual;
Square root of any valueCommand:
Select sqrt(value) from dual;
Date Functions
To determine the system date of a computerCommand:
Select sysdate from dual;
To add months in a dateCommand:
Select add_months(sysdate , monthnum) from dual;
To determine months between two datesCommand:
Select months_between(sysdate , ‘new date’) from dual;
To round off the month/year of a dateCommand:
Select round(sysdate, ‘month/year) from dual;
To round off the month/year of a date using truncateCommand:
select trunc(‘date’, ‘month/year’) from dual;
To determine the next day of the dateCommand:
select next_day(‘date’, ‘day’) from dual;
CHARACTER FUNCTION
To change the lower case of a string to upper caseCommand:
select upper(‘string’) from dual;
To change the upper case of a string to lower caseCommand:
select lower(‘string’) from dual;
To change the first case of a string to upper caseCommand:
select initcap(‘string’) from dual;
To take out the substring from a stringCommand:
select substr(‘string’ start, end) from dual;
To find the position of character in a stringCommand:
select instr(‘string’, ‘character’) from dual;
To find the length of a stringCommand:
select length(‘string’) from dual;
To concatenate the two stringsCommand:
select concat(‘string 1’, ‘string 2’) from dual;
To insert symbol on left side in a stringCommand:
select lpad(‘string’,size,’symbol’) from dual;
To insert symbol on right side in a stringCommand:
select rpad(‘string’,size,’symbol’) from dual;
To trim the characters from left side in a stringCommand:
select ltrim(‘string’,’characters’) from dual;
To trim the characters from right side in a stringCommand:
select rtrim(‘string’,’characters’) from dual;
To replace the characters from a stringCommand:
select replace(‘string’, ‘characters’, ’replacing characters’) from dual;