Академический Документы
Профессиональный Документы
Культура Документы
b12 7000
b15 9000
b12 5000
b70 5000
select salary*12 as anual from staff where anual > 10000 order by annual // invalif
identifier
compiler when execute
from -> where -> colname -> order by .. so edit the last statment:
select salary*12 as annual from staff where salary*12 > 10000 order by annual //
true
//exception
select max(salary), bno from staff groub by max(salary)>=12000 groub by bno;
//error because groub by visit tables by rows
select bno, max(Salary) from staff where Bno not in ('B3') having max(salary)>9000
group by bno // true
---Lecture---
initcap
number->char->date
number<-char<-date
number->date //false
date->number //false
//ddl
-creat
we must know master table and child table
here parent table is branch/comopney and the child is employee/staff -> because
the one ot many relation
company(id:number,name:varchar2(20),address:varchar2(40),tel:varchar2(7))
create table company(id number(5) primary key,
2 name varchar2(20),
3 address varchar2(40),
4 tel varchar2(7), constraint comp_tel_uq unique(tel),
5 constraint com_add_name_uq unique(name,address));
*****************************
delete tablename; or delete from tableName; // delete data from table // i can add
where
delete branch // can't because the is refrence refrences on branch
when we create the child and when we write the refrence , we can write refrences
branch on delete cascade // or on delete set null
<advanced query>
***************************
subquery => select fname,salary from staff where salary = (select max(salary) from
staff);
select fname,salary from staff where salary in (select max(salary) from staff group
by bno);
select fname,salary from staff where salary in (select max(salary) from staff group
by bno);
**********************
<sequence>
create sequence seq_name start with value increment by value maxvalue value min
[cycle]/[nocycle] //default no cycle
create sequence seq_name
seq_name.currval
seq_name.nextval
// to can use currval we must do nextval befor currval;
insert into emp values(seq.nextval,'Ibrahem');
// there all in table which name is user_sequences
select sequence_name from user_sequences;
drop sequence seq;
************************
<views>