Vous êtes sur la page 1sur 6

CONSULTAS ORACLE SQL DEVELOPER

PRESENTADO POR: YENNI BERMUDEZ PAOLA ZAMBRANO

PRESENTADO A: FLOR HERNANDEZ

ASIGNATURA: BASES DE DATOS

TECNOLOGA EN SISTEMAS EMPRESARIALES DE INFORMACIN INSTITUCIN UNIVERSITARIA TECNOLGICA DE COMFACAUCA POPAYAN_CAUCA 20 DE MARZO DEL 2012

Consultas Oracle SQL Developer Yenni Bermudez Paola ZAmbrano

1. Consultar datos en la tablas select * from aparato; select * from clase; select * from monitor; select * from sala; select * from socio;

select * from squash; 2. Consultar identificacion, nombre, apellido, preparacion, titulo del monitor select mon_dni, mon_nombre,mon_apellido, mon_preparacion, mon_titulo from monitor; 3. Consultar la medida de la sala en centimetros select SA_NUMERO, SA_UBICACION, SA_METROS*100 AS SALA_CENTIMETROS from SALA; 4. Consultar la profesin de los socios sin repetir ninguna select DISTINCT SO_PROFESION from SOCIO; 5. Consultar el cdigo del aparato, la descripcin cuando el estado sea disponible. select APA_CODIGO, APA_DESCRIPCION from APARATO where APA_ESTADO =UPPER('DISPONIBLE'); 6. Consultar el numero del socio, el nombre, el apellido cuando la profesin sea Medico select SO_NUMERO, SO_NOMBRE, SO_APELLIDO from SOCIO where SO_PROFESION=UPPER('MEDICO'); 7. Consultar el cdigo de la clase y el da cuando la clase se imparte a las 9 am select CLA_CODIGO, CLA_DIA from clase where CLA_HORA ='9 am'; 8. Consultar el numero de la sala cuando sus medidas estn entre 100 y 1000 metros select SA_NUMERO

from SALA where SA_METROS>100 AND SA_METROS<1000; 9. Consultar el nombre y apellido de los socios que son abogados u odontlogos select SO_NOMBRE, SO_APELLIDO from SOCIO where SO_PROFESION=UPPER('Abogado') OR SO_PROFESION=UPPER('Odontologo'); 10. Consultar el nombre, apellido y el titulo del monitor cuando su nombre empiece por la letra M select MON_NOMBRE, MON_APELLIDO, MON_TITULO from MONITOR where MON_NOMBRE LIKE UPPER('M%'); 11. Consultar el nombre, el apellido y el telfono del monitor cuando en su apellido la letra C se encuentre en tercer lugar de su apellido select MON_NOMBRE, MON_APELLIDO, MON_TELEFONO from MONITOR where MON_APELLIDO LIKE UPPER ('__C%'); 12. Consultar el nombre, el apellido, la profesin del monitor cuando su nombre comience por M, y su profesin sea Medico select MON_NOMBRE, MON_APELLIDO, MON_PROFESION from MONITOR where MON_NOMBRE LIKE UPPER ('M %') OR MON_PROFESION Medico; 13. Consultar el cdigo de la clase, el din del monitor cuando la hora es NULL select CLA_CODIGO, MON_DNI from CLASE where CLA_HORA IS NULL ; 14. Consultar nombre del monitor cuando su nombre es Sandra select MON_NOMBRE

from MONITOR where MON_NOMBRE IN ('Sandra'); 15. Consultar la descripcion del aparato cuando el estado del aparato es disponible y ocupado select APA_DESCRIPCION from APARATO where APA_ESTADO BETWEEN 'Disponible' AND 'Ocupado' 16. Para crear un tabla y sus campos debemos de utilizar esta sentencia create table INVITADO ("IN_IDE" VARCHAR2(15 BYTE), "IN_NOMBRE" VARCHAR2(15 BYTE)); 17. Consultar el nombre del socio, su direccin bancaria y su profesin pero ordenar de manera descendente la direccin bancaria. select SO_NOMBRE, SO_DIREBANCARIA, SO_PROFESION from SOCIO ORDER BY SO_DIREBANCARIA DESC; 18. Consultar el nmero de registros en nuestra tabla, todos lo que se encuentran dentro de ella select COUNT ('SO_TELEFONO') FROM SOCIO; 19. Consultar el numero de la sala con la condicin que d me muestre solo las que tengan ms de 100 metros, sin utilizar where, aqu utilizamos HAVING que se que se reserva para funciones de agregadas. select SA_NUMERO, SUM(SA_METROS) from SALA GROUP BY SA_NUMERO HAVING SUM(SA_METROS) > 100; 20. Para borrar todos los registros de la tabla utilizamos TRUNCATE TABLE INVITADO;

Para Modificar todos los registros de la tabla utilizamos UPDATE "INVITADO" SET "IN_DIN" = [NUEVO VALOR] WHERE {CONDITION}; Para borrar datos de una tabla, debemos utilizar la sentencia DELETE DELETE FROM DELETE FROM "INVITADOS" WHERE IN_NOMBRE= 'Juan'; Para eliminar una table utlizamos Drop Table DROP TABLE "INVITADO"; 21. Cuando queremos recortar un nmero determinado de caracteres en un campo utilizamos select left(CODIGO,3) FROM INVITADO 22. Cuando necesitamos trabajar con fechas utlizamos Select * from SOCIO where year(fecha) = 1981 23. El comando AVG nos sirve para sacar la media Select SA_NUMERO, avg(SA_METROS) from SALA group by SA_NUMERO;

Vous aimerez peut-être aussi