Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Consultas base de datos en SQL

103,487 views

Published on

Consultas de Base de Datos en SQL

Published in: Education
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • like
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Se descarga y se consulta. Se agradece el aporte ¡saludos!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Consultas base de datos en SQL

  1. 1. cristiansalazar@uach.cl
  2. 2. ¿Qué es SQL?• Lenguaje de consulta estructurado (SQL: Structured Query Languague) .• Es un lenguaje de base de datos normalizado.• Utilizado para consultar, modificar o eliminar datos en una Base de Datos.
  3. 3. Componentes• Comandos• Claúsulas• Operadores• Funciones
  4. 4. Comandos• Existen 2 tipos: – DLL (definición de datos): Permiten crear y definir nuevas bases de datos, campos e índices. • CREATE • DROP • ALTER – DML (manipulación de datos): Permiten generar consultas para ordenar, filtrar y extraer datos. • SELECT • INSERT • UPDATE • DELETE
  5. 5. Cláusulas• FROM• WHERE• GROUP BY• HAVING• ORDER BY
  6. 6. Operadores• Lógicos: – AND – OR – NOT• Comparación: <, >, <>, <=, >=
  7. 7. Funciones• COUNT• SUM• MAX• MIN• AVG
  8. 8. Consulta básicaSELECT AFROM BDonde A son los datos que requiero (columnas) y B es de donde obtengo esos datos.
  9. 9. EjemploSELECT nombre, apellidos, edadFROM estudiantes
  10. 10. WHERE• A veces NO se necesitan obtener datos tan generales, y es cuando se aplican filtros, con la clausula WHERE. SELECT A FROM B WHERE CDonde C, es una o más condiciones.
  11. 11. EjemploSELECT nombres, apellidos, edadFROM estudiantesWHERE edad > 21
  12. 12. Alias• Los alias son un nombre de asignación que se le dan a los recursos, en este caso las tablas.• Luego se pueden llamar a sus atributos desde ese alias, continuados con un punto (“.”) .
  13. 13. EjemploSELECT c.nombres, f.nombresFROM campus c, funcionarios fWHERE c.id_campus = f.id_campus
  14. 14. Alias 2• Es posible dar un alias (nombre) al titulo de las columnas de una tabla, que no es el mismo que posee en la Base de Datos.• Ejemplo sin Alias: Select l.titulo, l.agno From libros l TITULO AGNO Matemáticas 2007 Lenguaje y Comunicaciones 1998 Cs. Biológicas 2003
  15. 15. Ejemplo con AliasSelect l.titulo, l.agno As AÑOFrom libros l TITULO AÑO Matemáticas 2007 Lenguaje y Comunicaciones 1998 Cs. Biológicas 2003
  16. 16. GROUP BYLa cláusula GROUP BY se usa para generarvalores de agregado para cada fila delconjunto de resultados. Cuando se usan sinuna cláusula GROUP BY, las funciones deagregado sólo devuelven un valor deagregado para una instrucción SELECT. Ejemplo: SELECT nombre_columna1, nombre_columna2 FROM nombre_tabla GROUP BY nombre_columna1
  17. 17. GROUP BY: Ejemplo tienda_info nombre_tienda ventas fecha Valdivia 1500 05-jan-2010 Temuco 250 07-jan-2010 Valdivia 300 08-jan-2010 Osorno 700 08-jan-2010 RESULTADOCONSULTA ValdiviaSELECT nombre_tienda, SUM(ventas) 1800FROM tienda_info TemucoGROUP BY nombre_tienda 250 Osorno 700
  18. 18. HAVINGEspecifica una condición de búsqueda para ungrupo o agregado. HAVING sólo se puedeutilizar con la instrucción SELECT.Normalmente, HAVING se utiliza en unacláusula GROUP BY. Cuando no se utilizaGROUP BY, HAVING se comporta como unacláusula WHERE. Ejemplo: SELECT nombre_columna1, SUM(nombre_columna2) FROM nombre_tabla [ GROUP BY nombre_columna1 ] HAVING (condición de función aritmética)
  19. 19. HAVING: Ejemplo tienda_info nombre_tienda ventas fecha Valdivia 1500 05-jan-2010 Temuco 250 07-jan-2010 Valdivia 300 08-jan-2010 Osorno 700 08-jan-2010CONSULTA RESULTADOSELECT nombre_tienda, SUM(ventas) ValdiviaFROM tienda_info 1800GROUP BY nombre_tiendaHAVING SUM(ventas) > 1500
  20. 20. ORDER BYEspecifica el orden utilizado en las columnasdevueltas en una instrucción SELECT. Lacláusula ORDER BY no es válida en vistas,funciones insertadas, tablas derivadas nisubconsultas. Ejemplo: SELECT nombre_columna1, nombre_columna2 FROM nombre_tabla [ WHERE condicion] ORDER BY nombre_columna1 [ASC, DESC]
  21. 21. ORDER BY: Ejemplo tienda_info nombre_tienda ventas fecha Valdivia 1500 05-jan-2010 Temuco 250 07-jan-2010 Valdivia 300 08-jan-2010 Osorno 700 08-jan-2010 RESULTADOCONSULTA Valdivia 1500 05-SELECT nombre_tienda, ventas, fecha jan-2010FROM tienda_info Osorno 700 08-jan-2010ORDER BY ventas DESC Valdivia 300 08- jan-2010 Temuco 250 07-
  22. 22. OPERADORES LOGICOS (AND-OR) C1 C2 C1 OR C2 V V V V F VC1 C2 C1 AND C2 F V VV V VV F F F F FF V FF F F
  23. 23. OPERADORES LOGICOS: Ejemplo ANDtienda_info nombre_tienda ventas fecha Valdivia 1500 05-jan-2010 Temuco 250 07-jan-2010 Valdivia 300 08-jan-2010 Osorno 700 08-jan-2010CONSULTASELECT * RESULTADOFROM tienda_info Valdivia 1500 05-WHERE ventas > 500 jan-2010AND nombre_tienda = ‘Valdivia’
  24. 24. OPERADORES LOGICOS: Ejemplo ORtienda_info nombre_tienda ventas fecha Valdivia 1500 05-jan-2010 Temuco 250 07-jan-2010 Valdivia 300 08-jan-2010 Osorno 700 08-jan-2010CONSULTASELECT * RESULTADOFROM tienda_info Valdivia 1500 05-WHERE ventas > 500 jan-2010OR nombre_tienda = ‘Valdivia’ Valdivia 300 08- jan-2010 Osorno 700 08-jan-2010
  25. 25. Modelo de DatosPara este laboratorio usaremos la Base deDatos Biblioteca desarrollado en la claseanterior.Para ello use la imagen que se encuentra ensiveduc, “Biblioteca.png” y cargue el archivo“Biblioteca.sql” en PLSQL como se enseño en laclase anterior.

×