anwser for image

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

create database rr

create table customer


(
cust_id varchar (34)primary key,
fname char (23),
lname char (20),
city varchar (20),
industry_type char(30),
)
create table salesperson
(
sp_id varchar(10) primary key,
name char(20),
gender char(6),
salary money
)
create table orders
(
no varchar(10)primary key,
orderdate datetime,
sp_id varchar(10)foreign key references salesperson(sp_id)on delete cascade on
update cascade,
cust_id varchar (34)foreign key references customer(cust_id)on delete cascade
on update cascade,
amounrt money
)
insert into customer values('201','hailu','teshome','bd','p');
insert into customer values('202','aster','abebe','gonder','p');
insert into customer values('203','azeb','belete','markos','h');
insert into customer values('204','rechard','bale','desie','h');
select * from customer
insert into salesperson values('101','hailu','male','1400');
insert into salesperson values('102','aster','female','2400');
insert into salesperson values('103','azeb','female','2000');
insert into salesperson values('104','muluken','male','2500');
insert into salesperson values('105','tigist','female','1500');
insert into salesperson values('106','meseret','female','2800');

select * from salesperson


insert into orders values('1','05/2/2000','102','201',540);
insert into orders values('2','01/30/2000','105','204',1800);
insert into orders values('3','07/14/2001','101','204',460);
insert into orders values('4','01/29/2003','102','203',2400);
insert into orders values('5','02/03/2003','104','202',600);
insert into orders values('6','03/02/2003','104','202',720);
insert into orders values('7','05/6/2003','104','204',150);

select * from orders

alter table salesperson add age int


update salesperson set age='28'
where sp_id='106'

select * from salesperson where salary>='2400' and gender='female'


select name from salesperson where salesperson not in(select * from orders
where orders.sp_id=salesperson.sp_id)

select salesperson.name,salesperson.sp_id,salesperson.gender,
salesperson.salary from salesperson inner join orders on
orders.sp_id=salesperson.sp_id
where orders.sp_id>=2
select * from course
select * from student
select int('a')
select 'alemu' + 'abebe' as 'full name'
select ascii('B')as'ascii of a'
SELECT CHAR(66)
SELECT UNICODE('B')AS'UINCODE OF A'
SELECT LOWER('ABEBE')
select lower('alemu')
select replace('alemu','e','s')as'replace e with m'
select (10+10)as 'sum of two no'
select len('the cpitale city of etiopia is addis abeba')as 'lengthe of char'
use aster
select * from agrement

select * from room


alter table room add totalpyment int
insert into room(romno,totalpyment)
values('roo1',168096.00)

select romno,totalpyment from room


ALTER TABLE ROOM ADD PRICE INT
UPDATE ROOM SET PRICE='2340'WHERE ROMNO='ROO3'
SELECT ROMNO,price FROM ROOM WHERE ROMNO='ROO3' AND PRICE='2340'
select *from custmer
alter table custmer add constraint custmer_romno_fk foreign key (romno)

You might also like