It2EDU

Saturday, November 19, 2016

Oracle - Tutorial Part -1




Know the database management concept is essential to everyone, as a fresher must
have knowledge in any database like MySql, Oracle..etc.



Now I am using Oracle to give brief explanation about the creation
deletion updating of the database table.


Oracle provides Enterprise, mobile Express editions. Express edition is
light weight and free





History
of Oracle
: Oracle Corporation is an American Multinational Computer technology
corporation, headquartered in Redwood shores, California. The company
primarily specializes in developing and marketing  data base software and technology. In 2015 Oracle was the second largest software marker by revenue,after Microsoft.


Oracle was originally developed by Lawrence Ellison (Larry
Ellision) and his two friends Bob Miner and Ed Oates with name Software Development
laboratories in 1977.  Ellison consider
the Edgar Codd’s paper on relational database management system.  Oracle DB runs on the most major platforms
like Windows, UNIX, Linux and Mac OS.





Create a table Employe:





SQL> create table Employe(


  2  emp_id number(5) not null,


  3  emp_name varchar2(30) not null,


  4  address varchar2(30) not null,


  5  primary key(emp_id));





Table created.









To view table Employe:


Use the below command


Syntax: SQL> desc tablename;


Example : SQL>desc employe;







 Desc means describe the
table.







Insert the data into the table syntax.





SQL> INSERT INTO table (column1,column2,……column) values
(value1,vlaue2,….valuen);





Example: SQL> insert into Employe
values(1001,'santosh','visakhapatnam');





1 row created.





SQL> insert into Employe values(1002,'ram','Hyderabad');





1 row created.





SQL> insert into Employe values(1003,'pavan','Mumbai');





1 row created.





















 ALTER table:





Modifying the existing table in oracle:


ALTER is a command in oracle to modify the existing table.


By using ALTER we can add, rename, modify, drop the columns in the
table.





Add a column existing table:


Syntax:  ALTER TABLE table_name   ADD column_name column-definition;  


Add a phone column to the employe
table;





SQL> ALTER TABLE employe ADD phone
number(10) ;










Modify the column in the table.


SQL> ALTER TABLE table_name MODIFY column_name
column_definition;


Modify the address column size in the employe
table.


SQL> ALTER TABLE employe MODIFY
address 
varchar2(50);










Drop the column in table.


SQL> ALTER TABLE table_name DROP  COLUMN Column_name ;


Drop the address2 column in the
employe table.


SQL> ALTER TABLE employe DROP
COLUMN
address2;










Rename the column name in the table.


Syntax: SQL> ALTER TABLE table_name
RENAME COLUMN old_column_name to new_column_name;


SQL>ALTER TABLE employe RENAME
COLUMN
address to emp_address;


















0 comments:

Post a Comment