sábado, 10 de diciembre de 2011

Instalación oracle express 11g + Oracle SQL Developer

Instrucciones para instalar Oracle Express 11g

Descargar:
Oracle Express 11g http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
Oralce SQL Developer http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html


Despues de instalar Oracle Express:

Para iniciar oracle express, ir a inicio, todos los programas, oracle database 11g express edition, entrar get started.

Oracle Sql Developer se ejecuta, y en los valores por defecto queda configurado para usarlo con oracle express.

miércoles, 5 de enero de 2011

Preparando el Examen 1Z0-051 Oracle Database 11g: SQL Fundamentals I

El examen 1Z0-051 corresponde al examen Oracle Database 11g: SQL Fundamentals I conducente a las siguientes certificaciones:

1. Retrieving Data Using the SQL SELECT Statement

· List the capabilities of SQL SELECT statements

· Execute a basic SELECT statement

2. Restricting and Sorting Data

· Limit the rows that are retrieved by a query

· Sort the rows that are retrieved by a query

· Use ampersand substitution to restrict and sort output at runtime

3. Using Single-Row Functions to Customize Output

· Describe various types of functions available in SQL

· Use character, number, and date functions in SELECT statements

4. Using Conversion Functions and Conditional Expressions

· Describe various types of conversion functions that are available in SQL

· Use the TO_CHAR, TO_NUMBER, and TO_DATE conversion functions

· Apply conditional expressions in a SELECT statement

5. Reporting Aggregated Data Using the Group Functions

· Identify the available group functions

· Describe the use of group functions

· Group data by using the GROUP BY clause

· Include or exclude grouped rows by using the HAVING clause

6. Displaying Data from Multiple Tables

· Write SELECT statements to access data from more than one table using equijoins and nonequijoins

· Join a table to itself by using a self-join

· View data that generally does not meet a join condition by using outer joins

· Generate a Cartesian product of all rows from two or more tables

7. Using Subqueries to Solve Queries

· Define subqueries

· Describe the types of problems that the subqueries can solve

· List the types of subqueries

· Write single-row and multiple-row subqueries

8. Using the Set Operators

· Describe set operators

· Use a set operator to combine multiple queries into a single query

· Control the order of rows returned


9. Manipulating Data

· Describe each data manipulation language (DML) statement

· Insert rows into a table

· Update rows in a table

· Delete rows from a table

· Control transactions

10. Using DDL Statements to Create and Manage Tables

· Categorize the main database objects

· Review the table structure

· List the data types that are available for columns

· Create a simple table

· Explain how constraints are created at the time of table creation

· Describe how schema objects work

11. Creating Other Schema Objects

· Create simple and complex views

· Retrieve data from views

· Create, maintain, and use sequences

· Create and maintain indexes

· Create private and public synonyms

martes, 13 de octubre de 2009

Triggers

Triggers
=========

El modificador FOR EACH ROW indica que el trigger se disparará cada vez que se desee hacer operaciones sobre una fila de la tabla. Si se acompaña del modificador WHEN, se establece una restricción; el trigger solo actuará, sobre las filas que satisfagan la restricción.

CREATE OR REPLACE TRIGGER "INSERCIONNUMEROMAYOR1000"
AFTER INSERT ON "PRUEBA"
FOR EACH ROW WHEN (new.CAMPO2 > 1000)
BEGIN
insert into resultadodisparador (fecha, aviso, tabla)
values (Sysdate, 'Registro con CAMPO2 superior a 1000','PRUEBA');
END;

Con este disparador, cuando un usuario inserte un registro en la tabla PRUEBA cuyo CAMPO2 tenga un valor superior a 1000 se insertará automáticamente (transparente para el usuario) otro registro en la tabla "resultadodisparador" con la fecha de la inserción (sysdate), el aviso "Registro con CAMPO2 superior a 1000" y el nombre de la tabla origen del disparador "PRUEBA".

Obviamente, para que este disparador funcione correctamente deberán existir las tablas PRUEBA (origen del disparador) y "resultadodisparador" (donde se insertará el registro si se cumple la condición CAMPO2 > 1000.

La consulta SQL necesaria para crear la tabla "PRUEBA":

CREATE TABLE "PRUEBA" (
"CAMPO1" VARCHAR2(10) NOT NULL,
"CAMPO2" NUMBER)

La consulta SQL necesaria para crear la tabla "resultadodisparador":

CREATE TABLE "RESULTADODISPARADOR" (
"FECHA" DATE NOT NULL,
"AVISO" VARCHAR2(100) NOT NULL,
"TABLA" VARCHAR2(50) NOT NULL)

insert into PRUEBA values ('Primer', 100);
insert into PRUEBA values ('Segundo', 110);
insert into PRUEBA values ('Tercero', 1001);
insert into PRUEBA values ('Cuarto', 1200);

ALGUNAS CONSULTAS SQL PARA MODIFICAR EL ESTADO DE UN TRIGGER
=============================================================

para conocer los triggers creados

select trigger_name
from user_triggers;

Para eliminar un trigger mediante SQL:

drop trigger nombretrigger

Para deshabilitar temporalmente un trigger (dejará de realizar su función):

alter trigger nombretrigger disable

Para habilitar un trigger deshabilitado:

alter trigger nombretrigger enable

Para deshabilitar todos los triggers asociados a una tabla:

alter table nombretabla disable all triggers

Para habilitar todos los triggers asociados a una tabla:

alter table nombretabla enable all triggers



Este trigger impide que se agregue o modifique un empleado con el sueldo mayor o menor que los valores maximo y minimo respectivamente para su cargo. Se agrega la restricción de que el trigger no se dispararán si el cargo es PRESIDENTE.



CREATE TRIGGER salary_check
BEFORE
INSERT OR UPDATE OF sal, job
ON employee
FOR EACH ROW
WHEN (new.job <> 'PRESIDENT')
DECLARE
minsal NUMBER
maxsal NUMBER
BEGIN
/* Se obtienen los valores minimo y maximo para el salario de */
/* un cargo determinado, usando la tabla sal_guide */
SELECT minsal, maxsal
INTO minsal, maxsal
FROM sal_guide
WHERE job = :new.job
/* Si el salario del empleado a insertar/modificar esta por */
/* debajo del minimo, o por encima del maximo, se genera */
/* un error. */
IF (:new.sal <> maxsal)
THEN raise_application_error(-20601, 'Salary '||:new.sal||
' out of range for job '||:new.job||' for employee '||
:new.ename);
END IF;
END;


" Programar un disparador que calcule el campo código de pieza (P#) cada vez que se inserte una nueva pieza"

Disponenos de tres tablas que son:

Suministrador
---------------
S# NombreS Dirección Ciudad
2 Juan C/ Pelayo Málaga
3 Luis C/ Pato Málaga
4 Pablo C/Alfonso X Granada

Pieza
-----
P# NombreP Peso Cantidad
2 Tornillo 16 20
4 Tuerca 8 20
8 Clavos 7 30

Sumimistros
-----------
S# P#
2 4
2 8
4 2
3 2

CREATE OR REPLACE TRIGGER NuevaPieza
BEFORE INSERT ON Pieza FOR EACH ROW
BEGIN
-- Establecer el nuevo número de pieza:
SELECT MAX(P#)+1 INTO :new.P# FROM Pieza;
IF :new.P# IS NULL THEN
:new.P# := 1;
END IF;
END NuevaPieza;

Hay muchas circunstancias en las que el uso de un trigger PL/SQL puede ser extremadamente útil, por ejemplo:

- Cuando los datos de una tabla son generados desde otro tipo de procedimientos y se necesita controlar los valores que toman algunos campos determinados de la tabla en cuestión.

- Para duplicar los contenidos de una tabla automáticamente y en tiempo real.

- Para implementar complejas restricciones sobre los valores que pueden tomar los campos de una tabla Oracle, es decir, cuando los CONSTRAINTS que se pueden definir sobre una tabla son insuficientes.

- Para controlar las modificaciones de los valores de los campos de una tabla (auditorías).

- Para incrementar automáticamente los valores de un campo.

- Para realizar actualizaciones de una tabla en cascada.

- Para modificar campos o registros de una tabla que un usuario no puede modificar directamente.

Los triggers PL/SQL constituyen una potente herramienta para mantener la integridad de la base de datos, ya que pueden llevar a cabo cualquier acción que sea necesaria para el mantenimiento de dicha integridad.

Los triggers PLSQL pueden llamar a otros procedimientos y disparar otros triggers, pero no admiten parámetros y no pueden ser invocados desde otros procedimientos PLSQL.

Los triggers están almacenados en la tabla catálogo del sistema como parte de las propiedades de una tabla.

Tipos de triggers PLSQL

Los triggers PLSQL pueden actuar antes o después de que se realice una inserción, un borrado o una actualización de un registro de la tabla Oracle involucrada.

Se pueden definir triggers PL/SQL diferentes para cada tipo de evento (INSERT, UPDATE, DELETE) pero lo más lógico es crear un único trigger para todos los eventos y usar una sentencia IF para distinguir que acción realizar dependiendo del evento.

Por otro lado los triggers pueden ser a nivel de registro (row) o a nivel de sentencia (statement).

- A nivel de registro o fila el trigger PL/SQL se ejecuta cada vez que un registro es actualizado, insertado o borrado.

- A nivel de sentencia, el trigger se ejecuta una vez que la sentencia PL/SQL INSERT, UPDATE o INSERT se completa. Obviamente en este caso el trigger sólo puede ser ejecutado después (AFTER) de que se ejecute dicha sentencia.

Ejemplo

CREATE or replace TRIGGER tr1_empleado
BEFORE INSERT OR UPDATE OF salario
ON empleado
FOR EACH ROW
WHEN (new.salario > 5000)
BEGIN
UPDATE empleado
SET salario = 5000
WHERE numEmpleado = :new.numEmpleado;
END;







Otro ejemplo:


create table Autor (
idAutor integer,
nomAutor varchar2(30)
)

Insert into Autor values (1, 'Juan');
insert into autor values (2, 'pedro');
insert into autor values (3, 'Diego');

create table libro (
idAutor integer,
idlibro integer,
nomLibro varchar2(25)
)

Insert into Libro values (1, 1, 'Salmo 25');
Insert into Libro values (1, 2, 'La iliada');
Insert into Libro values (1, 3, 'El Quijote');
Insert into Libro values (2, 4, 'La Araucana');
Insert into Libro values (2, 5, 'Damian');
Insert into Libro values (3, 6, 'Sidharta');


CREATE TRIGGER t1
Before DELETE
ON Autor
FOR EACH ROW
Begin
Delete Libro
where Libro.IdAutor = :old.IdAutor;

End;


Otro Ejemplo
============

Create table Compra(
idCompra Integer,
fecCompra Date
);

Insert into Compra values (1, '25-01-2009');
Insert into Compra values (2, '28-02-2009');
Insert into Compra values (3, '24-03-2009');

Create table Producto(
idProducto integer,
nombreProducto varchar2(25),
Stockactual integer
);

insert into Producto values (1, 'Tornillo', 0);
insert into Producto values (2, 'Tuerca', 0);
insert into Producto values (3, 'Golilla', 0);


Create table detalleCompra(
idcompra Integer,
idProducto integer,
cantidad integer
);


Create trigger ActualizaStockCompra
before insert
ON DetalleCompra
FOR EACH ROW
Begin
Update Producto
Set StockActual = StockActual + :new.Cantidad
where Producto.IdProducto = :new.IdProducto;

End;

insert into detalleCompra values (1, 1, 10);
insert into detalleCompra values (1, 2, 100);
insert into detalleCompra values (1, 3, 1000);
insert into detalleCompra values (2, 1, 20);
insert into detalleCompra values (2, 2, 10);
insert into detalleCompra values (3, 1, 10);



Create table Merma(
idMerma integer,
fecmerma date,
idProducto integer,
cantidad integer
);


Create trigger ActualizaStockMerma
before insert
ON Merma
FOR EACH ROW
Begin
Update Producto
Set StockActual = StockActual - :new.Cantidad
where Producto.IdProducto = :new.IdProducto;

End;


insert into merma values (1, '25-09-2009', 1, 10);
insert into merma values (2, '28-09-2009', 1, 1);
insert into merma values (3, '25-10-2009', 2, 10);


Otro triggers

create table Person (age int);

CREATE or replace TRIGGER PersonCheckAge
BEFORE INSERT OR UPDATE OF age
ON Person
FOR EACH ROW
WHEN (new.age < 0)
BEGIN
RAISE_APPLICATION_ERROR(-20000, 'No se permiten edades negativas');
END;

CREATE or replace TRIGGER PersonCheckAge
BEFORE INSERT OR UPDATE OF age
ON Person
FOR EACH ROW
BEGIN
if (:new.age < 0) then
RAISE_APPLICATION_ERROR(-20000, 'No se permiten edades negativas');
end if;
END;


Si intentamos ejecutar la inserción:

insert into Person values (-3);

miércoles, 19 de agosto de 2009

Para la Creación de Usuarios en Oracle

Previo a la creación de los usuarios es recomendable crear un TABLESPACE para mantener los archivos de los estudiantes. Esto debe hacerlo en Enterprise Manager (EM).

La creación de los usuarios en la cuenta Oracle, se realiza con el siguientes script:

drop user "RUT-DV" cascade;
CREATE USER "RUT-DV" PROFILE "DEFAULT" IDENTIFIED BY "RUT-DV" DEFAULT TABLESPACE "CURSOSBD2009" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK;
GRANT "CONNECT" TO "RUT-DV";
GRANT "RESOURCE" TO "RUT-DV";

viernes, 18 de julio de 2008

Para practicar SQL

Usar MySQL YA en http://www.mysqlya.com.ar/problemas/problema.php?cod=3&punto=3

tambien arreglar los datos de DreamHome preocupandose de las Letras en el nombre de las tablas , hay un arreglo para Empleado y Oficina:

drop table if exists Oficina;
drop table if exists Empleado;

create table Oficina (
NUMOficina CHAR(4) not null,
CALLE CHAR(30),
CIUDAD CHAR(25),
CODIGOPOSTAL CHAR(10),
constraint PK_Oficina primary key (NUMOficina));

create table Empleado (
NUMEmpleado CHAR(4) not null,
NOMBRE CHAR(30),
APELLIDO CHAR(30),
CARGO CHAR(35),
SEXO CHAR(1),
FECHNAC DATE,
SALARIO FLOAT,
NUMOficina CHAR(4),
constraint PK_Empleado primary key (NUMEmpleado));

alter table Empleado
add constraint FK_EMPLEADO_REFERENCE_OFICINA foreign key (NUMOFICINA)references Oficina (NUMOFICINA);

insert into Oficina values('B005','16 Holhead','Aberdeem','AB7 5SU');
insert into Oficina values('B007','6 Argvill St.','London','NW2');
insert into Oficina values('B003','164 Main street','Glasgow','G119Qx');
insert into Oficina values('B004','2 Manor Rd','Glasgow','G114Qx');
insert into Oficina values('B001','10 Dale Rd','bristol','G12');
insert into Oficina values('B002','17 Holhead','Aberdeem','AB7 5SU')
;insert into Oficina values('B008','7 Argvill St.','London','NW21');
insert into Oficina values('B006','163 Main street','Glasgow','G11');
insert into Oficina values('B010','2 Manor Rd','Glasgow','G114x');
insert into Oficina values('B011','14 Dale Rd','bristol','G2');
insert into Oficina values('B017','6 Argvill St.','London','W2');
insert into Oficina values('B013','166 Main street','Glasgow','9Qx');
insert into Oficina values('B014','3 Manor Rd','Glasgow','Qx');
insert into Oficina values('B012','11 Dale Rd','bristol','GH2');
insert into Oficina values('B015','Costanera 25','Valdivia','0324');
insert into Oficina values('B115','Picarte 124','Valdivia','0324');
insert into Oficina values('B215','El Morro 110','Arica','10300');
insert into Oficina values('B315','El Vergel 1500','Arica','123123');
insert into Oficina values('B415','Av. Walker Martinez 1360','Santiago','W101');
insert into Oficina values('B515','Av. Antonio Varas 929','Santiago','W101');
insert into Empleado values('SL21','Jhon','White','Gerente','M', '1945/10/01',300000,'B005');
insert into Empleado values('SG37','Peter','Denver','Asistente','M', '1960/11/10',120000,'B006');
insert into Empleado values('SG14','David','Ford','Supervisor','M', '1958/09/09',180000,'B003');
insert into Empleado values('SA9','Mary','Lee','Asistente','F', '1959/09/17',90000,'B007');
insert into Empleado values('SG5','Susan','Sarandon','Gerente','F', '1960/03/21',240000,'B003');
insert into Empleado values('SL41','Julie','Roberts','Asistente','F', '1963/06/13',90000,'B005');
insert into Empleado values('SL22','Juan','Blanco','Gerente','M', '1944/10/01',300000,'B005');
insert into Empleado values('SG36','Luis','Jara','Asistente','M', '1961/11/10',120000,'B003');
insert into Empleado values('SG13','David','Gates','Supervisor','M', '1958/09/09',180000,'B003');
insert into Empleado values('SA8','Maria','Bombal','Asistente','F', '1959/09/17',90000,'B007');
insert into Empleado values('SG4','Susana','Sarandons','Gerente','F', '1960/03/21',240000,'B003');
insert into Empleado values('SL40','James','Bond','Asistente','F', '1963/06/13',90000,'B005');
insert into Empleado values('SL50','Juan','Perez','Vendedor','M', '1963/06/13',151000,'B015');
insert into Empleado values('SL60','Jaime','Soto','Vendedor','M', '1983/06/14',350000,'B115');
insert into Empleado values('SL70','Julia','Berne','Vendedor','F', '1953/01/23',200000,'B215');
insert into Empleado values('SL55','Jorge','Fernandez','Vendedor','M','1963/06/13',151000,'B015');
insert into Empleado values('SL65','Jose','Isla','Vendedor','M', '1983/06/14',350000,'B115');

miércoles, 18 de julio de 2007

Dream home completo

Aquí una descripción resumida del Modelo de datos de Dream Home



/*==============================================================*/
/* BORRADO DE TABLAS */
/*==============================================================*/

drop table TotPropEmpleado cascade constraints;

drop table ARRIENDO cascade constraints;

drop table CLIENTE cascade constraints;

drop table EMPLEADO cascade constraints;

drop table OFICINA cascade constraints;

drop table PROPIEDAD cascade constraints;

drop table PROPIETARIO cascade constraints;

drop table VISITA cascade constraints;
/*==============================================================*/
/* Tabla: ARRIENDO */
/*==============================================================*/

create table ARRIENDO (
NUMARRIENDO INTEGER not null,
NUMPROPIEDAD CHAR(4),
NUMCLIENTE CHAR(4),
RENTA FLOAT,
FORMAPAGO CHAR(10),
DEPOSITO FLOAT,
PAGADO CHAR(1),
INICIORENTA DATE,
FINRENTA DATE,
constraint PK_ARRIENDO primary key (NUMARRIENDO)
);

/*==============================================================*/
/* Tabla: CLIENTE */
/*==============================================================*/
create table CLIENTE (
NUMCLIENTE CHAR(4) not null,
NOMBRE CHAR(30),
APELLIDO CHAR(30),
DIRECCION CHAR(35),
TELEFONO CHAR(10),
TIPOPREF CHAR(25),
MAXRENT FLOAT,
constraint PK_CLIENTE primary key (NUMCLIENTE)
);

/*==============================================================*/
/* Tabla: EMPLEADO */
/*==============================================================*/
create table EMPLEADO (
NUMEMPLEADO CHAR(4) not null,
NOMBRE CHAR(30),
APELLIDO CHAR(30),
CARGO CHAR(35),
SEXO CHAR(1),
FECHNAC DATE,
SALARIO FLOAT,
NUMOFICINA CHAR(4),
constraint PK_EMPLEADO primary key (NUMEMPLEADO)
);

/*==============================================================*/
/* Tabla: OFICINA */
/*==============================================================*/
create table OFICINA (
NUMOFICINA CHAR(4) not null,
CALLE CHAR(30),
CIUDAD CHAR(25),
CODIGOPOSTAL CHAR(10),
constraint PK_OFICINA primary key (NUMOFICINA)
);

/*==============================================================*/
/* Tabla: PROPIEDAD */
/*==============================================================*/
create table PROPIEDAD (
NUMPROPIEDAD CHAR(4) not null,
CALLE CHAR(30),
CIUDAD CHAR(25),
CODIGOPOSTAL CHAR(10),
TIPO CHAR(25),
HAB INTEGER,
RENTA FLOAT,
NUMPROPIETARIO CHAR(4),
NUMEMPLEADO CHAR(4),
constraint PK_PROPIEDAD primary key (NUMPROPIEDAD)
);

/*==============================================================*/
/* Tabla: PROPIETARIO */
/*==============================================================*/

create table PROPIETARIO (
NUMPROPIETARIO CHAR(4) not null,
NOMBRE CHAR(30),
APELLIDO char(30),
DIRECCION CHAR(30),
TELEFONO CHAR(10),
constraint PK_PROPIETARIO primary key (NUMPROPIETARIO)
);

/*==============================================================*/
/* Tabla: VISITA */
/*==============================================================*/
create table VISITA (
NUMCLIENTE CHAR(4) not null,
NUMPROPIEDAD CHAR(4) not null,
FECHA DATE not null,
COMENTARIO VARCHAR2(30),
constraint PK_VISITA primary key (NUMCLIENTE, NUMPROPIEDAD, FECHA)
);

/*==============================================================*/
/* Tabla TotPropEmpleado */
/* Se utiliza para insertar desde otra tabla
/*==============================================================*/

create table TotPropEmpleado (
NUMEMPLEADO CHAR(4) not null,
totProp INTEGER,
constraint PK_TotPropEmpleado primary key (NUMEMPLEADO)
);

alter table TotPropEmpleado
add constraint FK_TotProp_REFERENCE_EMPLEADO foreign key (NUMEMPLEADO)
references EMPLEADO (NUMEMPLEADO);

alter table EMPLEADO
add constraint FK_EMPLEADO_REFERENCE_OFICINA foreign key (NUMOFICINA)
references OFICINA (NUMOFICINA)
on delete Cascade;

alter table PROPIEDAD
add constraint FK_PROPIEDA_REFERENCE_EMPLEADO foreign key (NUMEMPLEADO)
references EMPLEADO (NUMEMPLEADO)
on delete set null;

alter table VISITA
add constraint FK_VISITA_REFERENCE_CLIENTE foreign key (NUMCLIENTE)
references CLIENTE (NUMCLIENTE);

alter table VISITA
add constraint FK_VISITA_REFERENCE_PROPIEDA foreign key (NUMPROPIEDAD)
references PROPIEDAD (NUMPROPIEDAD);


/*==============================================================*/
/*= P o b l a m i e n t o d e t a b l a s =*/
/*==============================================================*/

/*==============================================================*/
/* datos: oficina */
/*==============================================================*/
insert into oficina values('B005','16 Holhead','Aberdeem','AB7 5SU');
insert into oficina values('B007','6 Argvill St.','London','NW2');
insert into oficina values('B003','164 Main street','Glasgow','G119Qx');
insert into oficina values('B004','2 Manor Rd','Glasgow','G114Qx');
insert into oficina values('B001','10 Dale Rd','bristol','G12');
insert into oficina values('B002','17 Holhead','Aberdeem','AB7 5SU');
insert into oficina values('B008','7 Argvill St.','London','NW21');
insert into oficina values('B006','163 Main street','Glasgow','G11');
insert into oficina values('B010','2 Manor Rd','Glasgow','G114x');
insert into oficina values('B011','14 Dale Rd','bristol','G2');
insert into oficina values('B017','6 Argvill St.','London','W2');
insert into oficina values('B013','166 Main street','Glasgow','9Qx');
insert into oficina values('B014','3 Manor Rd','Glasgow','Qx');
insert into oficina values('B012','11 Dale Rd','bristol','GH2');
insert into oficina values('B015','Costanera 25','Valdivia','0324');
insert into oficina values('B115','Picarte 124','Valdivia','0324');
insert into oficina values('B215','El Morro 110','Arica','10300');
insert into oficina values('B315','El Vergel 1500','Arica','123123');
insert into oficina values('B415','Av. Walker Martinez 1360','Santiago','W101');
insert into oficina values('B515','Av. Antonio Varas 929','Santiago','W101');

/*==============================================================*/
/* datos: cliente */
/*==============================================================*/
insert into cliente values('CR76','Jhon','Kay','56 High ST,Londonn,SW14EH','0207774563','Departamento',450);
insert into cliente values('CR56','Aline','Stewart','64 Fern Dr, Glasgow G42 OBL','0141324182','Departamento',350);
insert into cliente values('CR74','Mike','Ritchie','63 Well St, Glasgow,G42','0141943742','Casa',750);
insert into cliente values('CR62','Mary','Tregear','12 Park PI, Glasgow, G40QR','0141225742','Departamento',600);
insert into cliente values('CR78','Juan','Kayser','55 High ST,Londonn,SW14EH','0207774564','Departamento',450);
insert into cliente values('CR57','Alicia','Soto','63 Fern Dr,. GlasgowG42 OBL','0141324183','Departamento',350);
insert into cliente values('CR72','Miguel','Torres','62 Well St, Glasgow,G42','0141943740','Casa',750);
insert into cliente values('CR63','Maria','Perez','13 Park PI, Glasgow,G4 0QR','0141225741','Departamento',600);

/*==============================================================*/
/* datos: empleado */
/*==============================================================*/
insert into empleado values('SL21','Jhon','White','Gerente','M','01/10/45',300000,'B005');
insert into empleado values('SG37','Peter','Denver','Asistente','M','10/11/60',120000,'B006');
insert into empleado values('SG14','David','Ford','Supervisor','M','09/09/58',180000,'B003');
insert into empleado values('SA9','Mary','Lee','Asistente','F','17/09/59',90000,'B007');
insert into empleado values('SG5','Tina','Sarandon','Gerente','F','21/03/60',240000,'B003');
insert into empleado values('SL41','Julie','Roberts','Asistente','F','13/06/63',90000,'B005');
insert into empleado values('SL22','Juan','Blanco','Gerente','M','01/10/44',300000,'B005');
insert into empleado values('SG36','Luis','Jara','Asistente','M','10/11/61',120000,'B003');
insert into empleado values('SG13','David','Gates','Supervisor','M','09/09/58',180000,'B003');
insert into empleado values('SA8','Maria','Bombal','Asistente','F','17/09/59',90000,'B007');
insert into empleado values('SG4','Susana','Sarandons','Gerente','F','21/03/60',240000,'B003');
insert into empleado values('SL40','Jose','Bond','Asistente','F','13/06/63',90000,'B005');
insert into empleado values('SL50','Juan','Perez','Vendedor','M','13/06/63',151000,'B015');
insert into empleado values('SL60','Jaime','Soto','Vendedor','M','14/06/83',350000,'B115');
insert into empleado values('SL70','Julia','Berne','Vendedor','F','23/01/53',200000,'B215');
insert into empleado values('SL55','Jorge','Fernandez','Vendedor','M','13/06/63',151000,'B015');
insert into empleado values('SL65','Jose','Isla','Vendedor','M','14/06/83',350000,'B115');

/*==============================================================*/
/* datos: Propietario */
/*==============================================================*/
insert into propietario values('C046','Joe','Keogh','2 Fergus Dr, AberdeenAB 7SX','0122486121');
insert into propietario values('C087','Carol','Farrel','6 Achray St.Glasgow, G32 9DX','0141357741');
insert into propietario values('C040','Tina','Murphy','63 Well St, Glasgow, G42','0141943742');
insert into propietario values('C093','Tony','Shaw','12 Park PI, Glasgow, G40QR','0141225742');
insert into propietario values('C047','Jose','Casanova','El Volvan 123, Santiago AB 7SX','0122486125');
insert into propietario values('C088','Carolina','Fernandez','Macul 1800. Santiago, G32 9DX','0141357741');
insert into propietario values('C041','Cristina','Mora','Av. Matta 1800, Santiago, G42','0141943752');
insert into propietario values('C094','Jorge','Figueroa','Av. Macul 120, Santiago, G40QR','0141225542');

/*==============================================================*/
/* datos: PROPIEDAD */
/*==============================================================*/
insert into PROPIEDAD values('PA14','16 Holhead','Aberdeem','AB7 5SU','Casa','6','650','C046','SL21');
insert into PROPIEDAD values('PL94','6 Argvill St.','London','NW2','Departamento','4','400','C087','SL21');
insert into PROPIEDAD values('PG4' ,'6 Lawrence St','Glasgow','G119QX','Departamento','3','350','C040','SA9');
insert into PROPIEDAD values('PG36','2 Manor Rd','Glasgow','G114QX','Departamento','3','375','C093','SA9');
insert into PROPIEDAD values('PG21','AV. Matta 150','Santiago','G12','Casa','5','600','C087','SG5' );
insert into PROPIEDAD values('PR01','Macul 120 ','Santaigo','G129AX','Departamento','4','450','C093','SA8');
insert into PROPIEDAD values('PR02','Macul 220','Santiago','G129AX','Departamento','5','550','C093','SG13');
insert into PROPIEDAD values('PR03','Macul 420','Santiago','G129AX','Departamento','6','650','C093','SG14');
insert into PROPIEDAD values('PR04','Macul 620','Santiago','G129AX','Departamento','3','350','C093','SG36');
insert into PROPIEDAD values('PR05','Loa 100','Santiago','G129AX','Departamento','2','250','C093','SG4');
insert into PROPIEDAD values('PG16','Arturo Prats 250','Santiago','G129AX','Departamento','4','450','C047','SL22');
insert into PROPIEDAD values('PR07','Gorbea 200','Santiago','G129AX', 'Departamento','6','650','C047','SL40');
insert into PROPIEDAD values('PR08','Gomez 230','Santiago','G129AX', 'Departamento','2','250','C041','SL41');
insert into PROPIEDAD values('PR09','Garibaldi 1500','Santiago','G129AX', 'Departamento','6','650','C041','SL50');
insert into PROPIEDAD values('PR10','Las Urbinas 210','Santiago','G129AX', 'Departamento','6','650','C094','SL55');
insert into PROPIEDAD values('PR11','Lastarria 1400','Santiago','G129AX', 'Departamento','3','350','C094','SL60');
insert into PROPIEDAD values('PR12','Las Giraldas 200','Santiago','G129AX','Departamento','4','450','C093','SL70');

/*==============================================================*/
/* datos: VISITA */
/*==============================================================*/
insert into visita values('CR56','PA14','24-11-1999','muy pequeño');
insert into visita values('CR62','PA14','14-11-1999','no tiene salón');
insert into visita values('CR76','PG4','20-10-1999','muy lejos');
insert into visita values('CR72','PG16','24-06-2007','Bakan');
insert into visita values('CR72','PG36','24-06-2007','Super');
insert into visita values('CR62','PG16','25-06-2007','Cool');
insert into visita values('CR62','PG4','25-06-2007', NULL);
insert into visita values('CR62','PG36','25-06-2007','No salva');
insert into visita (numCliente, numPropiedad, fecha) values ('CR72','PG4','25-06-2007');
insert into visita (numCliente, numPropiedad, fecha) values('CR56','PG36','28-10-1999');
insert into visita (numCliente, numPropiedad, fecha) values('CR56','PG4','26-11-1999');

/*==============================================================*/
/* datos: ARRIENDO*/
/*==============================================================*/
insert into arriendo values('10024','PA14','CR62','650','Visa','1300','Y','01-06-2005','31-05-2006');
insert into arriendo values('10075','PL94','CR76','400','Contado','800','N','01-08-2005','31-01-2006');
insert into arriendo values('10012','PG21','CR74','600','Cheque','1200','Y','01-07-2005','30-06-2006');
/*==============================================================*/