Professional Documents
Culture Documents
references Producto(IdProducto));
alter table DetalleVenta
add (constraint DetalleVenta_IdVenta_FK
foreign key (IdVenta)
references Venta(IdVenta));
alter table Venta
add (constraint Venta_IdCliente_FK
foreign key (IdCliente)
references Cliente(IdCliente));
insert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)
values ('P01', 'cpu','lenovo','1000', '10','C01')
insert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)
values ('P02','laptop','sony','2500','15','C02')
insert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)
values ('P03','scanjet','epson','600','10','C03')
insert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)
values ('P04','laser1020','hp','800','20','C04')
insert into Producto(IdProducto,Nombre,Marca,Precio,Stock,IdCategoria)
values ('P05','S5mini','Samsung','3500','10','C05')
insert into Categoria(Id,Nombre) values ('C01','computadoras');
insert into Categoria(Id,Nombre) values ('C02','laptops');
insert into Categoria(Id,Nombre) values ('C03','scanner');
insert into Categoria(Id,Nombre) values ('C04','impresoras');
insert into Categoria(Id,Nombre) values ('C05','celulares');
insert into Cliente(IdCliente,Nombre,Direccion,Telefono)
values ('CLI01','Javier_caceres','calacoto','2771415')
insert into Cliente(IdCliente,Nombre,Direccion,Telefono)
values ('CLI02','jose_paye','periferica','2148597')
insert into Cliente(IdCliente,Nombre,Direccion,Telefono)
values ('CLI03','jose_valer','calacoto','2158744')
insert into Cliente(IdCliente,Nombre,Direccion,Telefono)
values ('CLI04','edgar_lopez','miraflores','222727')
insert into Cliente(IdCliente,Nombre,Direccion,Telefono)
values ('CLI05','guido_perez','Achachicala','77555555')
select
P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,D.Cantidad,D.Precio,D.I
dVenta,D.IdProducto
from Producto P,DetalleVenta D
where P.IdProducto=D.IdProducto
select D.cantidad,D.Precio,D.IdVenta,D.IdProducto,V.IdVenta,V.Fecha,V.IdCliente
from DetalleVenta D,Venta V
where D.IdVenta=V.IdVenta
select
V.IdVenta,V.Fecha,V.Detalle,V.IdCliente,Cl.IdCliente,Cl.Nombre,Cl.Direccion,Cl.telefon
o
from Venta V,Cliente Cl
where V.IdCliente=Cl.IdCliente
select P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,C.Id,C.Nombre
from Producto P
left join Categoria C
on P.IdCategoria=C.Id
select
P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,D.Cantidad,D.Precio,D.I
dVenta, D.IdProducto
from Producto P
select D.cantidad,D.Precio,D.IdVenta,D.IdProducto,V.IdVenta,V.Fecha,V.IdCliente
from DetalleVenta D
left join Venta V
on D.IdVenta=V.IdVenta
select
V.IdVenta,V.Fecha,V.Detalle,V.IdCliente,Cl.IdCliente,Cl.Nombre,Cl.Direccion,Cl.telefon
o
from Venta V
left join Cliente Cl
on V.IdCliente=Cl.IdCliente
select P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,C.Id,C.Nombre
from Producto P
right join Categoria C
on P.IdCategoria=C.Id
select
P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,D.Cantidad,D.Precio,D.I
dVenta, D.IdProducto
from Producto P
right join DetalleVenta D
on P.IdProducto=D.IdProducto
select D.cantidad,D.Precio,D.IdVenta,D.IdProducto,V.IdVenta,V.Fecha,V.IdCliente
from DetalleVenta D
right join Venta V
on D.IdVenta=V.IdVenta
select
V.IdVenta,V.Fecha,V.Detalle,V.IdCliente,Cl.IdCliente,Cl.Nombre,Cl.Direccion,Cl.telefon
o
from Venta V
right join Cliente Cl
on V.IdCliente=Cl.IdCliente
select P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,C.Id,C.Nombre
from Producto P
full join Categoria C
on P.IdCategoria=C.Id
select
P.IdProducto,P.Nombre,P.Marca,P.Precio,P.Stock,P.IdCategoria,D.Cantidad,D.Precio,D.I
dVenta, D.IdProducto
from Producto P
full join DetalleVenta D
on P.IdProducto=D.IdProducto
select D.cantidad,D.Precio,D.IdVenta,D.IdProducto,V.IdVenta,V.Fecha,V.IdCliente
from DetalleVenta D
full join Venta V
on D.IdVenta=V.IdVenta
select
V.IdVenta,V.Fecha,V.Detalle,V.IdCliente,Cl.IdCliente,Cl.Nombre,Cl.Direccion,Cl.telefon
o
from Venta V
full join Cliente Cl
on V.IdCliente=Cl.IdCliente
select IdProducto,Nombre
from Producto
union
select Id,Nombre
from Categoria
select Precio,IdProducto
from Producto
union
select Precio,IdProducto
from DetalleVenta
select IdVenta
from DetalleVenta
union
select IdVenta
from Venta
select IdCliente
from Venta
union
select IdCliente
from Cliente
select IdProducto,Nombre
from Producto
union all
select Id,Nombre
from Categoria
select Precio,IdProducto
from Producto
union all
select Precio,IdProducto
from DetalleVenta
select IdVenta
from DetalleVenta
union all
select IdVenta
from Venta
select IdCliente
from Venta
union all
select IdCliente
from Cliente
select Idcategoria
from Producto
intersect
select Id
from Categoria
select Precio,IdProducto
from Producto
intersect
select Precio,IdProducto
from DetalleVenta
select IdVenta
from DetalleVenta
intersect
select IdVenta
from Venta
select IdCliente
from Venta
intersect
select IdCliente
from Cliente
select IdProducto,Nombre
from Producto
minus
select Id,Nombre
from Categoria
select Precio,IdProducto
from Producto
minus
select Precio,IdProducto
from DetalleVenta
select IdVenta
from DetalleVenta
minus
select IdVenta
from Venta
select IdCliente
from Venta
minus
select IdCliente
from Cliente