Databázy (1) Prednáška 08. Alexander Šimko

Size: px
Start display at page:

Download "Databázy (1) Prednáška 08. Alexander Šimko"

Transcription

1 Databázy (1) Prednáška 08 Alexander Šimko

2 Contents I Subqueries (poddopyty) konštrukcia WITH

3 Section 1 Subqueries (poddopyty)

4 Subquery (poddopyt) Použitie SELECTu na mieste, kde sme doteraz písali: hodnotu názov sĺpca názov tabuľky... Vnorený SELECT sa uzatvára do guľatých zátvoriek: (SELECT... )

5 Skalárne subquery Skalárne subquery Je to vnorený SELECT, ktorý vracia tabuľku rozmerov: jeden riadok jeden stĺpec môže byť všade tam, kde očakávame jednu hodnotu ak vráti nula riadkov, považuje sa to za NULL hodnotu

6 Skalárne subquery Skalárne subquery Príklad Chceme získať všetky filmy natočené v najstaršom roku. Nemôžeme použiť ORDER BY a LIMIT, lebo nevieme koľko ich je SELECT * FROM films AS f WHERE f.year = (SELECT min(year) FROM films)

7 Skalárne subquery Skalárne subquery Príklad Chceme získať všetky filmy natočené v najstaršom roku. Nemôžeme použiť ORDER BY a LIMIT, lebo nevieme koľko ich je SELECT * FROM films AS f WHERE f.year = (SELECT min(year) FROM films) Ak sa vnorený SELECT neodkazuje na vonkajší SELECT vnorený SELECT je vyhodnotený samostatne jeho výsledok je dosadený do vonkajšieho SELECTu a ten sa následne spustí platí aj pre iné než skalárne subquery (na ďalších slajdoch)

8 Skalárne subquery Skalárne subquery Príklad 2 Pre každý film chceme zistiť o koľko rokov bol natočený neskôr ako najstarší film. SELECT *, year - (SELECT min(year) FROM films) AS delta FROM films AS f

9 Skalárne subquery Odkazovanie sa na stĺpce hlavného SELECTu Príklad Pre každý film chceme vedieť koľko filmov bolo vyrobených pred ním. SELECT *, (SELECT count(*) FROM films AS f2 WHERE f2.year < f.year) AS how_many FROM films AS f

10 Skalárne subquery Odkazovanie sa na stĺpce hlavného SELECTu Príklad Pre každý film chceme vedieť koľko filmov bolo vyrobených pred ním. SELECT *, (SELECT count(*) FROM films AS f2 WHERE f2.year < f.year) AS how_many FROM films AS f Ak sa vnorený SELECT odkazuje na vonkajší SELECT pre každý riadok hlavného SELECTu sa vykoná vnorený SELECT pri vykonávaní vnoreného SELECTu sa použijú hodnoty aktuálneho riadku platí aj pre iné než skalárne subquery (na ďalších slajdoch)

11 Skalárne subquery Skalárne subquery Neexistujúca hodnota Ak skalárny vnorený SELECT vráti nula riadkov, chápe sa to ako NULL hodnota Pre každý film získaj jeden film, ktorý bol natočený aspoň rok po ňom. SELECT *, (SELECT f2.name FROM films AS f2 WHERE f2.year > f.year ORDER BY f2.year ASC LIMIT 1) AS next FROM films AS f

12 Skalárne subquery Skalárne subquery Chyby Ak vnorený SELECT na mieste, kde očakávame jednu hodnotu, vráti viac riadkov (čo príklad nižšie predpokladá), SELECT *, (SELECT f2.name FROM films AS f2 WHERE f2.year > f.year ORDER BY f2.year ASC) AS next FROM films AS f dostaneme chybu ERROR: more than one row returned by a subquery used as an expression

13 Skalárne subquery Skalárne subquery Chyby Ak vnorený SELECT na mieste, kde očakávame jednu hodnotu, vracia viac stĺpcov, SELECT *, (SELECT f2.id, f2.name FROM films AS f2 WHERE f2.year > f.year ORDER BY f2.year ASC LIMIT 1) AS next FROM films AS f dostaneme chybu ERROR: subquery must return only one column

14 Subquery ako zoznam hodnôt Subquery ako zoznam hodnôt operátory ako IN, NOT IN, SOME, ALL pracujú so zoznamom hodnôt tabuľku s jednym sĺpcom môžeme chápať ako zoznam hodnôt zoznam hodnôt môžme nahradiť vnoreným SELECTom, ktorý vracia takúto tabuľku

15 Subquery ako zoznam hodnôt Operátor IN hodnota IN subquery testuje či sa hodnota na ľavej strane nachádza v zozname, ktorý vygereruje subquery

16 Subquery ako zoznam hodnôt Operátor IN Príklad SELECT * FROM films WHERE id IN (SELECT film_id FROM ratings)

17 Subquery ako zoznam hodnôt Operátor NOT IN hodnota NOT IN subquery testuje, či sa hodnota na ľavej strane nenachádza v zozname

18 Subquery ako zoznam hodnôt Operátor NOT IN Príklad SELECT * FROM departments WHERE department_id NOT IN (SELECT department_id FROM employees)

19 Subquery ako zoznam hodnôt Pozor na NULLy SELECT * FROM departments WHERE department_id NOT IN (SELECT department_id FROM employees) V našej databáze sme mali zamestnanca bez oddelenia. Čiže tento SELECT je principiálne ekvivalentný SELECTu: SELECT * FROM departments WHERE department_id NOT IN (10, 100, NULL, 50)

20 Subquery ako zoznam hodnôt Pozor na NULLy department_id NOT IN (10, 100, NULL, 50) sa vyhodnotí na: FALSE pre department_id 10, 100, 50 NULL pre všetky ostatné department_id Teda sa nevyhodnotí na TRUE pre žiadne department_id a WHERE vyhodí z výsledku všetky oddelenia.

21 Subquery ako zoznam hodnôt Predčasné ukončenie Vnorený SELECT sa prestane vykonávať v momente, keď je o výsledku testu IN/NOT IN rozhodnuté nemusí načítať všetky riadky. SELECT * FROM departments AS d WHERE manager_id IN (SELECT manager_id FROM employees AS e WHERE d.id!= e.department_id)

22 Subquery ako zoznam hodnôt Operátor ANY/SOME hodnota operátor ANY subquery hodnota operátor SOME subquery testuje či sa hodnota na ľavej strane vyhodnotí daným operátorom na TRUE s aspoň jednou hodnotou v zozname, ktorý vygereruje subquery

23 Subquery ako zoznam hodnôt Operátor ANY/SOME Príklad Zoznam filmov, od ktorých existuje drahší film SELECT * FROM films AS f WHERE price < ANY (SELECT price FROM films AS f2 WHERE f2.id!= f.id)

24 Subquery ako zoznam hodnôt Operátor ALL hodnota operátor ALL subquery testuje či sa hodnota na ľavej strane vyhodnotí daným operátorom na TRUE so všetkými hodnotami v zozname, ktorý vygereruje subquery

25 Subquery ako zoznam hodnôt Operátor ALL Príklad Zoznam filmov, ktoré majú nižšiu cenu ako všetky ostatné filmy SELECT * FROM films AS f WHERE price < ALL (SELECT price FROM films AS f2 WHERE f2.id!= f.id)

26 EXISTS Operátor EXISTS EXISTS subquery vráti TRUE práve vtedy keď subquery vráti aspoň jeden riadok je jedno koľko stĺpcov subquery vracia vrátené hodnoty sa ignorujú podstatné je, či vráti nejaký riadok NOT EXISTS subquery negácia

27 EXISTS Operátor EXISTS Príklad Získame iba také filmy, pre ktoré neexistuje starší lacnejší film SELECT * FROM films AS f WHERE NOT EXISTS (SELECT NULL FROM films AS f2 WHERE f2.year < f.year AND f2.price < f.price)

28 EXISTS Operátor EXISTS Príklad 2 Pre každý film zistime, či od neho existuje starší lacnejší film SELECT *, EXISTS (SELECT NULL FROM films AS f2 WHERE f2.year < f.year AND f2.price < f.price) AS exists FROM films AS f

29 EXISTS Operátor EXISTS Predčasné ukončenie Vnorený SELECT sa prestane vykonávať v momente, keď je o výsledku testu EXISTS rozhodnuté nemusí načítať všetky riadky.

30 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky Napr. ak chceme agregovať po použití LIMIT SELECT avg(tmp.price) FROM (SELECT price FROM films ORDER BY year DESC LIMIT 10) AS tmp Vypočítana tabuľka musí mať alias

31 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky Čo ak sa chceme vo vnorenom dopyte (na pozícii názvu tabuľky) odkazovať na vonkajší dopyt?

32 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky SELECT * FROM departments AS d CROSS JOIN (SELECT * FROM employees AS e WHERE e.department_id = d.department_id ORDER BY salary DESC LIMIT 3) AS top_employees

33 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky V PostgreSQL 9.2 to možné nie je

34 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky V PostgreSQL 9.3 musíme použiť LATERAL

35 Subquery namiesto názvu tabuľky Subquery namiesto názvu tabuľky SELECT * FROM departments AS d CROSS JOIN LATERAL (SELECT * FROM employees AS e WHERE e.department_id = d.department_id ORDER BY salary DESC LIMIT 3) AS top_employees

36 Subquery namiesto názvu tabuľky Kde všade sa môže subselect nachádzať? na veľa miestach avšak nie všade, napr. nie v CHECK obmedzení niekedy to nie je jasné ani z PostgreSQL dokumentácie:( vyvíja sa to v čase, napr. UPDATE v časti SET od verzie 9.5

37 konštrukcia WITH Section 2 konštrukcia WITH

38 konštrukcia WITH Označuje sa aj Common Table Expressions

39 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Čo je to WITH? WITH je konštrukcia, ktorá umožňuje rozbiť zložitý SQL príkaz na viac jednoduchých

40 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Motivácia Cheme hercov, ktorí hrali v TOP 10 filmoch TOP filmy podľa priemerného hodnotenia používateľmi hodnotenia obsahujú duplicity, cheme iba najnovšie hodnotenia SELECT * FROM actors WHERE EXISTS (SELECT NULL FROM plays WHERE plays.actor_id = actors.id AND plays.film_id IN (SELECT film_id FROM (SELECT DISTINCT ON (user_id, film_id) user_id, film_id, rating FROM ratings ORDER BY user_id, film_id, time DESC ) AS tmp GROUP BY film_id ORDER BY avg(rating) DESC LIMIT 10 ) )

41 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Syntax WITH názov_1 [(stĺpec_1,..., stĺpec_n1)] AS (príkaz_1),... názov_m [(stĺpec_1,..., stĺpec_nm)] AS (príkaz_m) hlavný_príkaz kde príkaz_i a hlavný_príkaz môžú byť SELECT..., INSERT..., UPDATE..., DELETE...

42 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Vyhodnocovanie akokeby sme vytvorili dočasné tabuľky názov_i môžeme použiť v pozícii tabuľky príkaz_i môže používať všetky vyššie definované názvy

43 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Motivácia Cheme hercov, ktorí hrali v TOP 10 filmoch TOP filmy podľa priemerného hodnotenia používateľmi hodnotenia obsahujú duplicity, cheme iba najnovšie hodnotenia SELECT * FROM actors WHERE EXISTS (SELECT NULL FROM plays WHERE plays.actor_id = actors.id AND plays.film_id IN (SELECT film_id FROM (SELECT DISTINCT ON (user_id, film_id) user_id, film_id, rating FROM ratings ORDER BY user_id, film_id, time DESC ) AS tmp GROUP BY film_id ORDER BY avg(rating) DESC LIMIT 10 ) )

44 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Riešenie Cheme hercov, ktorí hrali v TOP 10 filmoch WITH dist_ratings AS ( SELECT DISTINCT ON (user_id, film_id) user_id, film_id, rating FROM ratings ORDER BY user_id, film_id, time DESC ), top_10 AS ( SELECT film_id FROM dist_ratings GROUP BY film_id ORDER BY avg(rating) DESC LIMIT 10 ), top_plays AS ( SELECT * FROM plays WHERE film_id IN (SELECT * FROM top_10) ) SELECT * FROM actors WHERE EXISTS (SELECT NULL FROM top_plays WHERE actor_id = id)

45 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Pozor: Nefunguje to ako textové nahradzovanie WITH avg_salary AS ( SELECT avg(salary) FROM salaries ) SELECT avg_salary salaries user_id year salary

46 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Pri textovom nahradení by sme dostali SELECT (SELECT avg(salary) FROM salaries) salaries user_id year salary

47 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Pri textovom nahradení by sme dostali SELECT (SELECT avg(salary) FROM salaries) salaries user_id year salary avg

48 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Pozor: Nefunguje to ako textové nahradzovanie WITH avg_salary AS ( SELECT avg(salary) FROM salaries ) SELECT avg_salary salaries user_id year salary ERROR: column "avg_salary" does not exist

49 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Čo sú tie stĺpce v zátvorkách? WITH názov_1 [(stĺpec_1,..., stĺpec_n1)] AS (príkaz_1) hlavný_príkaz sú to názvy stlpcov, nie argumenty

50 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Čo sú tie stĺpce v zátvorkách? salaries user_id year salary WITH avg_salary(my_year, my_salary) AS ( SELECT year, avg(salary) FROM salaries GROUP BY year ) SELECT * from avg_salary my_year my_salary

51 konštrukcia WITH WITH na sprehľadnenie zápisu SQL príkazov Takéto niečo teda nejde spraviť salaries user_id year salary WITH avg_salary(in_year) AS ( SELECT avg(salary) FROM salaries WHERE year = in_year ) SELECT avg_salary(2015) - avg_salary(2014)

52 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE INSERT, UPDATE, DELETE štandardne nevracajú nič INSERT INTO data(a,b) values (1,1), (1,2)

53 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Čo ak chceme vrátiť dáta? RETURNING * RETURNING výraz_1 AS názov_1,..., výraz_n AS názov_n píšu sa na koniec príkazov INSERT, UPDATE, DELETE

54 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE INSERT RETURNING používa vkladané hodnoty INSERT INTO data(a,b) VALUES (1,1), (1,2) RETURNING a * 2 AS x, b - 1 AS y x y

55 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE DELETE RETURNING používa mazané hodnoty DELETE FROM data WHERE b > 1 RETURNING b AS deleted_b data a b deleted_b 2

56 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE UPDATE RETURNING používa nové hodnoty UPDATE data SET b = 3 * b RETURNING b AS new_b data a b new_b 3 6

57 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Príklad: potrebujeme zistiť automaticky vložené id CREATE TABLE users ( id SERIAL, name VARCHAR ) INSERT INTO users (name) VALUES ( john ) RETURNING id id 1

58 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Príklad: Nové hodnoty chceme zaznamenať ako históriu CREATE TABLE users ( id SERIAL, name VARCHAR, salary numeric ) CREATE TABLE salary_history ( user_id SERIAL, date date, salary numeric ) INSERT INTO salary_history (user_id, date, salary) UPDATE users SET salary = 1.1 * salary RETURNING id, current_date, salary

59 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Problém Takto sa to ale nedá, nakoľko INSERT INTO akceptuje iba SELECT

60 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Neúspešná oprava CREATE TABLE users ( id SERIAL, name VARCHAR, salary numeric ) CREATE TABLE salary_history ( user_id SERIAL, date date, salary numeric ) INSERT INTO salary_history (user_id, date, salary) SELECT * FROM ( UPDATE users SET salary = 1.1 * salary RETURNING id, current_date, salary )

61 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Problém Aj toto zlyhá, nakoľko UPDATE nie je SELECT

62 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Riešenie: Treba použiť WITH WITH... názov_i... AS (príkaz_i),... hlavný_príkaz kde príkaz_i a hlavný_príkaz môžú byť SELECT..., INSERT..., UPDATE..., DELETE...

63 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Riešenie: Treba použiť WITH CREATE TABLE users ( id SERIAL, name VARCHAR, salary numeric ) CREATE TABLE salary_history ( user_id SERIAL, date date, salary numeric ) WITH updated_salaries AS ( UPDATE users SET salary = 1.1 * salary RETURNING id, current_date, salary ) INSERT INTO salary_history (user_id, date, salary) SELECT * FROM updated_salaries

64 konštrukcia WITH WITH v kombinácii s INSERT, UPDATE, DELETE Koniec Koniec

Databázové systémy. SQL Window functions

Databázové systémy. SQL Window functions Databázové systémy SQL Window functions Scores Tabuľka s bodmi pre jednotlivých študentov id, name, score Chceme ku každému doplniť rozdiel voči priemeru 2 Demo data SELECT * FROM scores ORDER BY score

More information

Databázy (1) Prednáška 11. Alexander Šimko

Databázy (1) Prednáška 11. Alexander Šimko Databázy (1) Prednáška 11 Alexander Šimko simko@fmph.uniba.sk Contents I Aktualizovanie štruktúry databázy Section 1 Aktualizovanie štruktúry databázy Aktualizácia štruktúry databázy Štruktúra databázy

More information

Spájanie tabuliek. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Spájanie tabuliek. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) Spájanie tabuliek Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 Úvod pri normalizácii rozdeľujeme databázu na viacero tabuliek prepojených cudzími kľúčmi SQL umožňuje tabuľky opäť spojiť

More information

Poradové a agregačné window funkcie. ROLLUP a CUBE

Poradové a agregačné window funkcie. ROLLUP a CUBE Poradové a agregačné window funkcie. ROLLUP a CUBE 1) Poradové a agregačné window funkcie 2) Extrémy pomocou DENSE_RANK(), TOP() - Príklady 3) Spriemernené poradia 4) Kumulatívne súčty 5) Group By a Datepart,

More information

Joining tables. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Joining tables. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) Joining tables Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 Introduction Normalization process tears the database into multiple tables related using foreign keys SQL provides means to join

More information

EXISTS NOT EXISTS WITH

EXISTS NOT EXISTS WITH Subquery II. Objectives After completing this lesson, you should be able to do the following: Write a multiple-column subquery Use scalar subqueries in SQL Solve problems with correlated subqueries Update

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

Introduction to Oracle9i: SQL

Introduction to Oracle9i: SQL Oracle 1z0-007 Introduction to Oracle9i: SQL Version: 22.0 QUESTION NO: 1 Oracle 1z0-007 Exam Examine the data in the EMPLOYEES and DEPARTMENTS tables. You want to retrieve all employees, whether or not

More information

Databázy (2) Prednáška 08. Alexander Šimko

Databázy (2) Prednáška 08. Alexander Šimko Databázy (2) Prednáška 08 Alexander Šimko simko@fmph.uniba.sk Contents I Funkcie Zložené typy PL/pgSQL Agregačné funkcie Funkcie Section 1 Funkcie Funkcie PostgreSQL umožňuje vytvoriť si vlastné databázové

More information

Alkérdések II. Copyright 2004, Oracle. All rights reserved.

Alkérdések II. Copyright 2004, Oracle. All rights reserved. Alkérdések II. Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Write a multiple-column subquery Use scalar subqueries in SQL

More information

Intermediate SQL: Aggregated Data, Joins and Set Operators

Intermediate SQL: Aggregated Data, Joins and Set Operators Intermediate SQL: Aggregated Data, Joins and Set Operators Aggregated Data and Sorting Objectives After completing this lesson, you should be able to do the following: Identify the available group functions

More information

Creating Other Schema Objects

Creating Other Schema Objects Creating Other Schema Objects Objectives After completing this lesson, you should be able to do the following: Create simple and complex views Retrieve data from views Database Objects Object Table View

More information

Jazyk SQL. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Jazyk SQL. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) Jazyk SQL Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 Jazyk SQL - Structured Query Language SQL je počítačový jazyk určený na komunikáciu s relačným SRBD neprocedurálny (deklaratívny) jazyk

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL

More information

SQL Data Query Language

SQL Data Query Language SQL Data Query Language André Restivo 1 / 68 Index Introduction Selecting Data Choosing Columns Filtering Rows Set Operators Joining Tables Aggregating Data Sorting Rows Limiting Data Text Operators Nested

More information

kucharka exportu pro 9FFFIMU

kucharka exportu pro 9FFFIMU požiadavky na export kodek : Xvid 1.2.1 stable (MPEG-4 ASP) // výnimočne MPEG-2 bitrate : max. 10 Mbps pixely : štvorcové (Square pixels) rozlíšenie : 1920x1080, 768x432 pre 16:9 // výnimočne 1440x1080,

More information

1 Vytvorenie tabuľky

1 Vytvorenie tabuľky Základy jazyka SQL (Structured Query Language) - vyvinula IBM začiatkom 70-tych rokov - je to deklaratívny jazyk (popisuje čo urobiť, nie ako) - je súčasťou veľkých databázových systémov (Informix, Oracle,

More information

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved. Restricting and Sorting Data Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the rows that are retrieved by a query Use

More information

Aplikačný dizajn manuál

Aplikačný dizajn manuál Aplikačný dizajn manuál Úvod Aplikačný dizajn manuál je súbor pravidiel vizuálnej komunikácie. Dodržiavaním jednotných štandardov, aplikácií loga, písma a farieb pri prezentácii sa vytvára jednotný dizajn,

More information

Join, Sub queries and set operators

Join, Sub queries and set operators Join, Sub queries and set operators Obtaining Data from Multiple Tables EMPLOYEES DEPARTMENTS Cartesian Products A Cartesian product is formed when: A join condition is omitted A join condition is invalid

More information

ÇALIŞMA TEST SORULARI

ÇALIŞMA TEST SORULARI 1. A table has the following definition: EMPLOYEES( EMPLOYEE_ID NUMBER(6) NOT NULL, LAST_NAME VARCHAR2(10) NOT NULL, MANAGER_ID VARCHAR2(6)) and contains the following rows: (1001, 'Bob Bevan', '200')

More information

Retrieving Data from Multiple Tables

Retrieving Data from Multiple Tables Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 5 Retrieving Data from Multiple Tables Eng. Mohammed Alokshiya November 2, 2014 An JOIN clause

More information

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints

WHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints SQL KEREM GURBEY WHAT IS SQL Database query language, which can also: Define structure of data Modify data Specify security constraints DATA DEFINITION Data-definition language (DDL) provides commands

More information

STRUCTURED QUERY LANGUAGE (SQL)

STRUCTURED QUERY LANGUAGE (SQL) STRUCTURED QUERY LANGUAGE (SQL) EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY SQL TIMELINE SCOPE OF SQL THE ISO SQL DATA TYPES SQL identifiers are used

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

More information

1Z0-007 ineroduction to oracle9l:sql

1Z0-007 ineroduction to oracle9l:sql ineroduction to oracle9l:sql Q&A DEMO Version Copyright (c) 2007 Chinatag LLC. All rights reserved. Important Note Please Read Carefully For demonstration purpose only, this free version Chinatag study

More information

Normalizácia a normálne formy

Normalizácia a normálne formy Normalizácia a normálne formy normalizácia je proces, pomocou ktorého sa dá databáza zbaviť štrukturálnych vád normalizácie je súhrnom niekoľkých tzv. normálnych foriem - množín pravidiel, ktoré hovoria

More information

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects. Set Theory Set theory is a branch of mathematics that studies sets. Sets are a collection of objects. Often, all members of a set have similar properties, such as odd numbers less than 10 or students in

More information

Textový formát na zasielanie údajov podľa 27 ods. 2 písm. f) zákona

Textový formát na zasielanie údajov podľa 27 ods. 2 písm. f) zákona Popis textového formátu a xsd schémy na zasielanie údajov podľa 27 ods. 2 písm. f) zákona (formu na zaslanie údajov si zvolí odosielateľ údajov) Textový formát na zasielanie údajov podľa 27 ods. 2 písm.

More information

KORA. RDBMS Concepts II

KORA. RDBMS Concepts II RDBMS Concepts II Outline Querying Data Source With SQL Star & Snowflake Schemas Reporting Aggregated Data Using the Group Functions What Are Group Functions? Group functions operate on sets of rows to

More information

Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami)

Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami) I2AI: Lecture 04 Constraint satisfaction problems (problémy s obmedzujúcimi podmienkami) Lubica Benuskova Reading: AIMA 3 rd ed. chap. 6 ending with 6.3.2 1 Constraint satisfaction problems (CSP) We w

More information

1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions

1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions 1Z0-051 Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions Table of Contents Introduction to 1Z0-051 Exam on Oracle Database 11g - SQL Fundamentals I 2 Oracle 1Z0-051 Certification

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

More information

Oracle Database SQL Basics

Oracle Database SQL Basics Oracle Database SQL Basics Kerepes Tamás, Webváltó Kft. tamas.kerepes@webvalto.hu 2015. február 26. Copyright 2004, Oracle. All rights reserved. SQL a history in brief The relational database stores data

More information

What Are Group Functions? Reporting Aggregated Data Using the Group Functions. Objectives. Types of Group Functions

What Are Group Functions? Reporting Aggregated Data Using the Group Functions. Objectives. Types of Group Functions What Are Group Functions? Group functions operate on sets of rows to give one result per group. Reporting Aggregated Data Using the Group Functions Maximum salary in table Copyright 2004, Oracle. All rights

More information

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery Database Systems CSE 303 Lecture 06: SQL 2016 Subquery Outline What is a Subquery Subquery in WHERE clause >ALL, >ANY, >=ALL,

More information

Spôsoby zistenia ID KEP

Spôsoby zistenia ID KEP Spôsoby zistenia ID KEP ID KEP (kvalifikovaný elektronický podpis) je možné zistiť pomocou napr. ovládacieho panela, prostredíctvom prehliadača Internet Expolrer, Google Chrome alebo Mozilla Firefox. Popstup

More information

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002. CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 10 DUE: Run the following queries in Oracle Application Express. Paste a copy of each query Into this word document below the questions or notepad.txt

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Advanced SQL Lecture 07 zain 1 Select Statement - Aggregates ISO standard defines five aggregate functions: COUNT returns number of values in specified column. SUM returns sum

More information

Copyright 2016 by Martin Krug. All rights reserved.

Copyright 2016 by Martin Krug. All rights reserved. MS Managed Service Copyright 2016 by Martin Krug. All rights reserved. Reproduction, or translation of materials without the author's written permission is prohibited. No content may be reproduced without

More information

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL)

Introduction. Sample Database SQL-92. Sample Data. Sample Data. Chapter 6 Introduction to Structured Query Language (SQL) Chapter 6 Introduction to Structured Query Language (SQL) Introduction Structured Query Language (SQL) is a data sublanguage that has constructs for defining and processing a database It can be Used stand-alone

More information

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved. Restricting and Sorting Data Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort

More information

Vnorené SQL. Autor prezentácie: Peter Šípoš

Vnorené SQL. Autor prezentácie: Peter Šípoš Vnorené SQL Autor prezentácie: Peter Šípoš Literatúra Programmatic SQL od Pearson Ed Embedded SQL: http://download.oracle. com/docs/cd/b10501_01/appdev.920/a97269/pc_06sql.htm Oracle Dynamic SQL: http://download.oracle.

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 2-1 Objectives This lesson covers the following objectives: Apply the concatenation operator to link columns to other columns, arithmetic expressions, or constant values to

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (3) 1 Topics Aggregate Functions in Queries count sum max min avg Group by queries Set Operations in SQL Queries Views 2 Aggregate Functions Tables are collections

More information

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter

More information

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved.

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved. Displaying Data from Multiple Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data

More information

1 Komplexný príklad využitia OOP

1 Komplexný príklad využitia OOP 1 Komplexný príklad využitia OOP Najčastejším využitím webových aplikácií je komunikácia s databázovým systémom. Komplexný príklad je preto orientovaný práve do tejto oblasti. Od verzie PHP 5 je jeho domovskou

More information

Aggregate Functions. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Dept. Database Lab (ECOM 4113)

Aggregate Functions. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Dept. Database Lab (ECOM 4113) Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 4 Aggregate Functions Eng. Mohammed Alokshiya October 26, 2014 Unlike single-row functions, group

More information

LECTURE10: DATA MANIPULATION IN SQL, ADVANCED SQL QUERIES

LECTURE10: DATA MANIPULATION IN SQL, ADVANCED SQL QUERIES LECTURE10: DATA MANIPULATION IN SQL, ADVANCED SQL QUERIES Ref. Chapter5 From Database Systems: A Practical Approach to Design, Implementation and Management. Thomas Connolly, Carolyn Begg. 1 IS220: D a

More information

Data Manipulation Language (DML)

Data Manipulation Language (DML) In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 3 Data Manipulation Language (DML) El-masry 2013 Objective To be familiar

More information

Assignment Grading Rubric

Assignment Grading Rubric Final Project Outcomes addressed in this activity: Overview and Directions: 1. Create a new Empty Database called Final 2. CREATE TABLES The create table statements should work without errors, have the

More information

Anycast. Ľubor Jurena CEO Michal Kolárik System Administrator

Anycast. Ľubor Jurena CEO Michal Kolárik System Administrator Anycast Ľubor Jurena CEO jurena@skhosting.eu Michal Kolárik System Administrator kolarik@skhosting.eu O nás Registrátor Webhosting Serverové riešenia Správa infraštruktúry Všetko sa dá :-) Index Čo je

More information

Recipient Configuration. Štefan Pataky MCP, MCTS, MCITP

Recipient Configuration. Štefan Pataky MCP, MCTS, MCITP Recipient Configuration Štefan Pataky MCP, MCTS, MCITP Agenda Mailbox Mail Contact Distribution Groups Disconnected Mailbox Mailbox (vytvorenie nového účtu) Exchange Management Console New User Exchange

More information

Database Technology. Topic 3: SQL. Olaf Hartig.

Database Technology. Topic 3: SQL. Olaf Hartig. Olaf Hartig olaf.hartig@liu.se Structured Query Language Declarative language (what data to get, not how) Considered one of the major reasons for the commercial success of relational databases Statements

More information

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 10: INTRODUCTION TO SQL FULL RELATIONAL OPERATIONS MODIFICATION LANGUAGE Union, Intersection, Differences (select

More information

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 1 NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE More Complex SQL Retrieval Queries Self-Joins Renaming Attributes and Results Grouping, Aggregation, and Group Filtering

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

COSC344 Database Theory and Applications. Lecture 6 SQL Data Manipulation Language (1)

COSC344 Database Theory and Applications. Lecture 6 SQL Data Manipulation Language (1) COSC344 Database Theory and Applications Lecture 6 SQL Data Manipulation Language (1) COSC344 Lecture 56 1 Overview Last Lecture SQL - DDL This Lecture SQL - DML INSERT DELETE (simple) UPDATE (simple)

More information

Introduction to Oracle9i: SQL

Introduction to Oracle9i: SQL Exam : 1Z0-007 Title : Introduction to Oracle9i: SQL Version : DEMO 1 / 10 1. What does the FORCE option for creating a view do? A.creates a view with constraints B.creates a view even if the underlying

More information

Unit 1 - Chapter 4,5

Unit 1 - Chapter 4,5 Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn

More information

VYLEPŠOVANIE KONCEPTU TRIEDY

VYLEPŠOVANIE KONCEPTU TRIEDY VYLEPŠOVANIE KONCEPTU TRIEDY Typy tried class - definuje premenné a metódy (funkcie). Ak nie je špecifikovaná inak, viditeľnosť členov je private. struct - definuje premenné a metódy (funkcie). Ak nie

More information

Database design process

Database design process Database technology Lecture 2: Relational databases and SQL Jose M. Peña jose.m.pena@liu.se Database design process 1 Relational model concepts... Attributes... EMPLOYEE FNAME M LNAME SSN BDATE ADDRESS

More information

Fundamentals of Database Systems

Fundamentals of Database Systems Fundamentals of Database Systems Assignment: 2 Due Date: 18th August, 2017 Instructions This question paper contains 10 questions in 6 pages. Q1: Consider the following schema for an office payroll system,

More information

Microsoft Azure platforma pre Cloud Computing. Juraj Šitina, Microsoft Slovakia

Microsoft Azure platforma pre Cloud Computing. Juraj Šitina, Microsoft Slovakia Microsoft Azure platforma pre Cloud Computing Juraj Šitina, Microsoft Slovakia m Agenda Cloud Computing Pohľad Microsoftu Predstavujeme platformu Microsoft Azure Benefity Cloud Computingu Microsoft je

More information

REPORT DESIGNER 1 VYTVORENIE A ÚPRAVA FORMULÁRA. úprava formulárov v Money S4 / Money S Vytvorenie formulára

REPORT DESIGNER 1 VYTVORENIE A ÚPRAVA FORMULÁRA. úprava formulárov v Money S4 / Money S Vytvorenie formulára REPORT DESIGNER úprava formulárov v Money S4 / Money S5 Informačný systém Money S4/S5 umožňuje upraviť tlačové zostavy tak, aby plne vyhovovali potrebám používateľa. Na úpravu tlačových zostáv slúži doplnkový

More information

DEFAULT Values, MERGE, and Multi-Table Inserts. Copyright 2009, Oracle. All rights reserved.

DEFAULT Values, MERGE, and Multi-Table Inserts. Copyright 2009, Oracle. All rights reserved. DEFAULT Values, MERGE, and Multi-Table Inserts What Will I Learn? In this lesson, you will learn to: Understand when to specify a DEFAULT value Construct and execute a MERGE statement Construct and execute

More information

1) 2) 3) 4) 5) 6) 7) XML. 8) 9) 10) 11) CRUD

1) 2) 3) 4) 5) 6) 7) XML. 8) 9) 10) 11) CRUD OBSAH 1) Úvod do SQL Server, množinové operácie 2) Uložené procedúry, funkcie 3) Pohľady a CTE 4) Rekurzia a transitívny uzáver 5) Triggery. Transakcie. 6) Kurzory.Pivot tabuľky 7) XML. B-stromy a indexy

More information

Relational Database Management Systems for Epidemiologists: SQL Part I

Relational Database Management Systems for Epidemiologists: SQL Part I Relational Database Management Systems for Epidemiologists: SQL Part I Outline SQL Basics Retrieving Data from a Table Operators and Functions What is SQL? SQL is the standard programming language to create,

More information

Testovanie bieleho šumu

Testovanie bieleho šumu Beáta Stehlíková FMFI UK Bratislava Opakovanie z prednášky Vygenerujeme dáta Vygenerujeme dáta: N

More information

Jeden z variantov príkazu priradenia nám umožňuje zadať za sebou aj viacej vstupných hodnôt, ako napríklad

Jeden z variantov príkazu priradenia nám umožňuje zadať za sebou aj viacej vstupných hodnôt, ako napríklad Príkaz priradenia Príkaz priradenia slúži na priradenie hodnoty premennej. Má tvar premenná = výraz, kde premenná je identifikátor, znak = sa číta priraď a vyhodnotením výrazu sa získa hodnota určitého

More information

Sun Certified MySQL Associate

Sun Certified MySQL Associate 310-814 Sun Certified MySQL Associate Version 3.1 QUESTION NO: 1 Adam works as a Database Administrator for a company. He creates a table named Students. He wants to create a new table named Class with

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

Obsah. SOA REST REST princípy REST výhody prest. Otázky

Obsah. SOA REST REST princípy REST výhody prest. Otázky REST Peter Rybár Obsah SOA REST REST princípy REST výhody prest Otázky SOA implementácie WEB (1990) CORBA (1991) XML-RPC (1998) WS-* (1998) SOAP RPC/literal SOAP Document/literal (2001) REST (2000) SOA

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 10-4 Objectives This lesson covers the following objectives: Identify when correlated subqueries are needed. Construct and execute correlated subqueries. Construct and execute

More information

Desatinné čísla #1a. Decimal numbers #1b. How much larger is 21,8 than 1,8? Desatinné čísla #2a. Decimal numbers #2b. 14 divided by 0,5 equals...

Desatinné čísla #1a. Decimal numbers #1b. How much larger is 21,8 than 1,8? Desatinné čísla #2a. Decimal numbers #2b. 14 divided by 0,5 equals... Desatinné čísla #1a Mravec išiel 5,5 cm presne na sever, potom 3,4 cm na východ, 1,8 cm na juh, 14,3 cm na západ, 1,3 cm na sever a 10,9 cm na východ. Najmenej koľko cm musí teraz prejsť, aby sa dostal

More information

Chapter 6. SQL Data Manipulation

Chapter 6. SQL Data Manipulation Chapter 6 SQL Data Manipulation Pearson Education 2014 Chapter 6 - Objectives Purpose and importance of SQL. How to retrieve data from database using SELECT and: Use compound WHERE conditions. Sort query

More information

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO INSERT INTO DEPT VALUES(4, 'Prog','MO'); The result

More information

Using the Set Operators. Copyright 2006, Oracle. All rights reserved.

Using the Set Operators. Copyright 2006, Oracle. All rights reserved. Using the Set Operators Objectives After completing this lesson, you should be able to do the following: Describe set operators Use a set operator to combine multiple queries into a single query Control

More information

Database Foundations. 6-9 Joining Tables Using JOIN. Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Database Foundations. 6-9 Joining Tables Using JOIN. Copyright 2014, Oracle and/or its affiliates. All rights reserved. Database Foundations 6-9 Roadmap Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML Transaction Control Language (TCL)

More information

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved.

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved. Creating Other Schema Objects Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Create simple and complex views Retrieve data

More information

Structured Query Language (SQL)

Structured Query Language (SQL) Structured Query Language (SQL) SQL Chapters 6 & 7 (7 th edition) Chapters 4 & 5 (6 th edition) PostgreSQL on acsmysql1.acs.uwinnipeg.ca Each student has a userid and initial password acs!

More information

SQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances

SQL Queries. COSC 304 Introduction to Database Systems SQL. Example Relations. SQL and Relational Algebra. Example Relation Instances COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general

More information

Registrácia účtu Hik-Connect

Registrácia účtu Hik-Connect Registrácia účtu Hik-Connect Tento návod popisuje postup registrácie účtu služby Hik-Connect prostredníctvom mobilnej aplikácie a webového rozhrania na stránke www.hik-connect.comg contents in this document

More information

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH 2017 Institute of Aga Network Database LECTURER NIYAZ M. SALIH Database: A Database is a collection of related data organized in a way that data can be easily accessed, managed and updated. Any piece of

More information

Lecture10: Data Manipulation in SQL, Advanced SQL queries

Lecture10: Data Manipulation in SQL, Advanced SQL queries IS220 / IS422 : Database Fundamentals : Data Manipulation in SQL, Advanced SQL queries Ref. Chapter5 Prepared by L. Nouf Almujally & Aisha AlArfaj College of Computer and Information Sciences - Information

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved.

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved. What Will I Learn? In this lesson, you will learn to: Apply SQL syntax to restrict the rows returned from a query Demonstrate application of the WHERE clause syntax Explain why it is important, from a

More information

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

ITCertMaster.  Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way! ITCertMaster Safe, simple and fast. 100% Pass guarantee! http://www.itcertmaster.com IT Certification Guaranteed, The Easy Way! Exam : 1Z0-870 Title : MySQL 5.0, 5.1 and 5.5 Certified Associate Exam Vendors

More information

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig.

Database Technology. Topic 2: Relational Databases and SQL. Olaf Hartig. Topic 2: Relational Databases and SQL Olaf Hartig olaf.hartig@liu.se Relational Data Model Recall: DB Design Process 3 Relational Model Concepts Relational database: represent data as a collection of relations

More information

RETRIEVING DATA USING THE SQL SELECT STATEMENT

RETRIEVING DATA USING THE SQL SELECT STATEMENT RETRIEVING DATA USING THE SQL SELECT STATEMENT Course Objectives List the capabilities of SQL SELECT statements Execute a basic SELECT statement Development Environments for SQL Lesson Agenda Basic SELECT

More information

CSE 530A SQL. Washington University Fall 2013

CSE 530A SQL. Washington University Fall 2013 CSE 530A SQL Washington University Fall 2013 SELECT SELECT * FROM employee; employee_id last_name first_name department salary -------------+-----------+------------+-----------------+-------- 12345 Bunny

More information

COSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems SQL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Queries Querying with SQL is performed using a SELECT statement. The general

More information

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH Institute of Aga 2018 Microsoft SQL Server LECTURER NIYAZ M. SALIH Database: A Database is a collection of related data organized in a way that data can be easily accessed, managed and updated. Any piece

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Database Programming with SQL

Database Programming with SQL Database Programming with SQL 12-2 Objectives In this lesson, you will learn to: Construct and execute an UPDATE statement Construct and execute a DELETE statement Construct and execute a query that uses

More information

Lecture 6 - More SQL

Lecture 6 - More SQL CMSC 461, Database Management Systems Spring 2018 Lecture 6 - More SQL These slides are based on Database System Concepts book and slides, 6, and the 2009/2012 CMSC 461 slides by Dr. Kalpakis Dr. Jennifer

More information

Introduction to SQL. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

Introduction to SQL. ECE 650 Systems Programming & Engineering Duke University, Spring 2018 Introduction to SQL ECE 650 Systems Programming & Engineering Duke University, Spring 2018 SQL Structured Query Language Major reason for commercial success of relational DBs Became a standard for relational

More information

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014 Lecture 5 Last updated: December 10, 2014 Throrought this lecture we will use the following database diagram Inserting rows I The INSERT INTO statement enables inserting new rows into a table. The basic

More information

CIS 363 MySQL. Chapter 12 Joins Chapter 13 Subqueries

CIS 363 MySQL. Chapter 12 Joins Chapter 13 Subqueries CIS 363 MySQL Chapter 12 Joins Chapter 13 Subqueries Ch.12 Joins TABLE JOINS: Involve access data from two or more tables in a single query. The ability to join two or more tables together is called a

More information