You are on page 1of 2

connect system/secreto(password); create user u identified by u; grant connect,resource to unac; create tablespace unac01 datafile 'c:/ken/unac01.

ora' size 3m extent management local autoallocate; connect u/u; create table categoria( idCategoria number(20), nomCategoria varchar2(50), descripcion varchar2(70), constraint pk_idcategoria primary key (idCategoria) ); create table pedido( idPedido number(20), fecha_pedido date default sysdate, fecha_entrega date, constraint pk_idPedido primary key (idPedido) );

create table producto( idProducto number(20), nomProducto varchar2(50), idCategoria number(20), cantidaXunidad number(20), precioUnidad number(10,2), stock number(20), constraint pk_idproducto primary key(idProducto), constraint fk_idcategoria_producto foreign key (idCategoria) references categoria(idCategoria) on delete cascade ); create table detalle_pedido_producto( idPedido number(20), idProducto number(20), precioUnidad number(20), cantidad number(20), descuento number(10,2), constraint pk_idpedido_idproducto_detalle primary key (idPedido,idProducto), constraint fk_idpedido_detalle foreign key (idPedido) references pedido(idPedido) on delete cascade, constraint fk_idproducto_detalle foreign key (idProducto) references producto(idProducto) on delete cascade ); create or replace procedure agregarCategoria(cod number,nom varchar2, desc varchar2)

is begin insert into categoria values(cod,nom,desc); commit; end;

You might also like