SQL PLUS crear tablas desde cmd o SQL plus

Intruccion SQL PLUS

en cmd / sqlplus

sqlplus


SQL> disconn

Desconectar cualquier usuario de la base de datos
SQL> conn

introduzca el nombre de usuario: ejemplo
introduzca la contraseña; B12345

SQL> create table estudiantes 
(codest number(3) not null primary key, nomest varchar2(20) not null,
edad number(2) not null);

create table materias
(codmat number(3) not null primary key, 
nommat varchar 2(20) not null);

create table notas
(codest number(3) not null,
codmat number(3) not null, 
n1 number(3,1), n2 number(3,1));


alter table notas add constraint fk_cod_est
foreign key (codest)
references estudiantes(codest);

desc estudiantes;
desc materias;
desc notas;

insert into estudiantes values
(10,'hugo',54)
insert into estudiantes values
(20,'juan',20)
insert into estudiantes values
(30,'diana',20)
insert into estudiantes values
(40,'diana',19)

select nomest from estudiantes where nomest like '%s';
select nomest NOMBRE, edad from estudiantes where edad in(19,20);

insert into materias values (30,'ingles');
insert into materias values (20,'modelado');
insert into materias values (10,'calculo');



select*from materias;


select nommat from materias where nommat like '___e%';
insert into notas values (10,10,3.5,3.5);
insert into notas values (10,20,4.5,5);
insert into notas values (10,20,3.5,4.6);
insert into notas values (20,10,3.5,4.2);
insert into notas values (20,20,2.5,1);
insert into notas values (20,30,2,3);

select*from notas;

select e.nomest NOMBRE,  m.nommat
from estudiantes e join notas n on e.codest=n.codest
join materias m on m.codmat=n.codmat;



select e.nomest NOMBRE, e.EDADEST, m.NOMMAT FROM ESTUDIANTES e
INNER JOIN NOTAS n
ON e.codest =n.CODEST INNER JOIN MATERIAS m ON n.CODMAT = m.CODMAT
where m.CODMAT = 10;







SELECT e.nomest, m.nommat, (n,N1 +n.N2)/2 Notafinal FROM ESTUDIANTES e JOIN NOTAS n
ON e.codest =n.CODEST INNER JOIN MATERIAS m ON n.CODMAT = m.CODMAT WHERE (n.N1 + n.N2)/2 < 3;

Share this

Related Posts

Previous
Next Post »