Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Basic SQL commands: Table creation: create table student( roll_no number(2), reg_no varchar2(2), name varchar2(2)); Retrieve all the data from the table: select * from student
14464
Insert values in a table: insert into student values('a1001',101,'mona'); Table updation Update student set roll_no=101 where city=gurgaon; Delete command Delete from emp Where gross<2200.00;
14464 EXPERIMENT NO.2 To study database creation and table creation statements Introduction:
A database system provides a data definition language to specify the database schema and a data manipulation language to express database queries and updates. A query is a statement requesting the retrieval of information . Table creation: create table student( roll_no number(2), reg_no varchar2(2), name varchar2(2)); Retrieve all the data from the table: select * from student;
Retrieve specific column from the table: select <column name> from student; Retrieve specific row from the table: select * from student where roll_no=101; Insert values in a table: insert into student values('a1001',101,'mona'); create table using primary constraints: create table student( reg_no varchar2(7)PRIMARY KEY, name varchar2(9)NOT NULL); Retrieve specific row and specific column: Select name from student
14464
where branch=it; To view column and its definition: exec SP_ column from <table name>; Rename table name: exec SP_renamestudent,student1; View records by given character: select * from student where city likea%; Ascending order: select * from student orderby name; Descending order: select * from student orderby name desc; See the record of top of table: Select top15 from student; To see all the tables in the database: select * from sys.table Print name between a and r select * from student where name between a and r; Table updation Update student set roll_no=101 where city=gurgaon;
14464
create table client_master( clientno varchar2(10) primary key, name varchar2(20), city varchar(20),pincode number(6),state varchar2(15),baldue number(10,2)); insert into client_master values('c006','shiv ,'manglore',560050,karnataka,0); select * from client_master; create table product_master( productno varchar2(6) primary key,description varchar2(15),profit number(4,2),unit_measure varchar2(6),quantity_on_hand number(6),reorder_level number(8),sell_price number(6),cost_price number(8)); insert into product_master values('p005','suit ',5 ,'Rs',400,40,800,400); select * from product_master; create table salesman_master( salesmanno varchar2(6),salesmanname varchar2(6),address varchar2(20),city varchar2(10),pincode number(6),state varchar(10),salary number(10),target_to_get number(10),yesterday_sale number(6,2),remark varchar2(10)); insert into salesman_master values('s005','hari','B.9','mumbai',400001,'maharastra',3000,100,50,'good'); select * from salesman_master; select name from client_master; select * from client_master; select name,city,state from client_master; select * from client_master where city='mumbai'; select * from salesman_master where salary=30000;
14464
update client_master set city='bangalore' where clientno='c005'; update client_master set balancedue=1000 where clientno='c001'; update product_master set cost_price=950 where description=trouser; update salesman_master set city='pune' where pincode=400042; delete from salesman_master where saleamt=3500; delete from client_master where state='Tamil Nadu';
create table orders( order_id varchar2(6)PRIMARY KEY, odate date, id varchar2(20)references customer, amount number(6));
insert into orders values('o003','28 feb 2013','c@gmail.com',4000); select * from orders select name,amount,salary from customer inner join orders on customer.id=orders.order_id; select name from customer right join orders on customer.id=orders.order_id; select salary from customer left join order on customer.id=order.id; select name,amount,order_id from customer full join order on customer.id=order.id; select * from customer
14464
14464
select avg(roll_no) from student2 group by branch; select branch,count(roll_no) from student2 group by branch; select branch,count(roll_no) from student2; select * from student2 where sdate < '12 march 2013';
14464
14464