Oracle Queries

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

You can execute many queries in oracle database such as insert, update, delete, alter table, drop, create and select.

1) Oracle Select Query

Oracle select query is used to fetch records from database. For example:

  1. SELECT * from customers;  


2) Oracle Insert Query

Oracle insert query is used to insert records into table. For example:

  1. insert into customers values(101,'rahul','delhi');  


3) Oracle Update Query

Oracle update query is used to update records of a table. For example:

  1. update customers set name='bob', city='london' where id=101;  

4) Oracle Delete Query

Oracle update query is used to delete records of a table from database. For example:

  1. delete from customers where id=101;  

5) Oracle Truncate Query

Oracle update query is used to truncate or remove records of a table. It doesn't remove structure. For example:

  1. truncate table customers;  


6) Oracle Drop Query

Oracle drop query is used to drop a table or view. It doesn't have structure and data. For example:

  1. drop table customers;  


7) Oracle Create Query

Oracle create query is used to create a table, view, sequence, procedure and function. For example:

  1. CREATE TABLE customers    
  2. ( id number(10) NOT NULL,    
  3.   name varchar2(50) NOT NULL,    
  4.   city varchar2(50),  
  5. CONSTRAINT customers_pk PRIMARY KEY (id)      
  6. );    


8) Oracle Alter Query

Oracle alter query is used to add, modify, delete or drop colums of a table. Let's see a query to add column in customers table:

  1. ALTER TABLE customers   
  2. ADD age varchar2(50);