Bases de Datos Relacionales Preparó: Ismael Castañeda Fuentes Fuentes:Manuales Sybase Manuales SQL Server Manuales Oracle BATCHS.

Slides:



Advertisements
Presentaciones similares
CREATE VIEW nombre [ ( columna [,...n ] ) ] AS sentencia_select [ WITH CHECK OPTION ] 1.nombre Es el nombre de la vista. 2.Se debe tener permisos CREATE.
Advertisements

You need to improve the way you write and think in Spanish - Time This is an interactive presentation. You need your work sheet, your pencil, and your.
Maestría en Data Mining
Mr. Redaelli OnlineTaco.com. To Have - Tener Yo tengo – I have Tú tienes – You have (Informal) Usted tiene – You have (Formal) El tiene – He has Ella.
Meta: be able to write with no errors on infinitive triggers and agreement Entrada: Escribir-reflecion Escribir de la casa Para salir: use an infinitve.
Telling Time Grammar Essential #8.
Modo Subjuntivo Hay 3 modos en Español:
The Subjunctive In this slide show, we are going to look at a verb form that has all but disappeared from English – the subjunctive!
FUNDAMENTALS OF THE JAVA PROGRAMMING LANGUAGE (SL-110) CAPÍTULO 7: OPERADORES Y ESTRUCTURAS DE SELECCION Ing. Ronald Criollo.
The Subjunctive In this slide show, we are going to look at a verb form that has all but disappeared from English – the subjunctive!
El mandato afirmativo (tú)
1 3 WAYS TO ASK A QUESTION 1.Add question marks to a statement. 2.Add a tag word to a statement. 3.Use a question word.
Ser part 2. Subject Pronouns in Spanish Singular Plural_______ Yo = I Nosotros = We (masculine/mixed group) Nosotras =We (feminine) Tú = You Él=He Ellos.
2003 HYPACK MAX Training Seminar1 Sample Case la Entrada manual de Datos de la Línea de la costa El Metodo de MANUAL –DIG Objectos –Boya (Roja)
2003 HYPACK MAX Training Seminar1 Sample Belgium Test Inputting Tag Line information into HYPACK® MAX In the old days, a Tag Line was anchored to.
Affirmative and Negative Words
In both English and Spanish, the verb to be (ser) and numbers are used to tell time. Copyright © 2008 Vista Higher Learning. All rights reserved.
Cómo escoger libros Justo para Mí 1. Mira la portada. 2. Lee el título y el autor. 3. Lee la contra- portada. 4. Hojea el libro. 5. Lee la primera página.
Delete en tablas: titulacion. Puedo eliminar cualquier fila de una tabla? Restriccion de integridad: Restrict/Cascade.
¿Qué hora es? Capítulo – Para Empezar. ¿Qué hora es? To state the time in Spanish, one must use the phrase Es la… or Son las… To state the time in Spanish,
Query Direcciones SELECT Nombre, Apellido, Ciudad FROM Direcciones;
Trabajo con subconsultas
Introducción a Transact-SQL
Arquitectura de Computadores I
Direct and Indirect Object Pronouns
Copyright © 2008 Vista Higher Learning. All rights reserved Negative words deny the existence of people and things or contradict statements, for.
Si (If) clauses describe a condition or event upon which another condition or event depends. Sentences with si clauses consist of a si clause and a main.
Procedimientos Almacenados y Disparadores
ALC 11 lunes el 26 de septiembre. Bienvenida lunes el 26 de septiembre Front row face the back row. Back row will read the words on the screen in the.
STARTER: ¡Encuentra al intruso!
When we ask what time it is in Spanish, we say “¿Qué hora es?”
SQL Base de Datos LENGUAJES DE CONSULTA AR y CR no pueden ser tomados como base para implementar porque: Poseen sintaxis compleja No permiten.
PL/SQL Francisco Moreno Universidad Nacional. Funciones Si un procedimiento tiene solo un parámetro de salida, se puede remplazar por una función y esta.
El 27 de noviembre de Tienes 5 minutos para escribir 5 líneas por lo menos en un papel sobre tus vacaciones del día de gracias.
TEMA 2.- INTRODUCCIÓN A LOS MÉTODOS ÓPTICOS PROPIEDADES DE LA RADIACION ELECTROMAGNETICA Muchas de las propiedades de la radiación electromagnética.
Antonio Gámir TSP – Windows Client Microsoft Ibérica.
Herramientas de Oracle para realizar Tuning de Sentencias SQL
ESTRUCTURAS DE CONTROL
Seminario de Lenguajes A – Opción Ada Seminario de Lenguajes A – Opción Ada – Raúl Champredonde1 Overloading de subprogramas procedure Put(Item: in integer;
Seminario de Lenguajes A – Opción Ada Estructura general de programas –Especificación de contexto –Encabezado –Declaraciones –Cuerpo Seminario de Lenguajes.
Seminario de Lenguajes A – Opción Ada
PL/SQL Francisco Moreno Universidad Nacional.
BASES DE DATOS Ejercicio No. 6. Ejecutar las siguientes sentencias SELECT nombre, ueldo FROM user.tabla_profesor WHERE filtro 1 UPDATE user.tabla_profesor.
Características Objeto Relacionales en Oracle
Administración de Servidores de Bases de Datos Bases de Datos de Usuarios Caso particular Adaptive Server Enterprise.
Telling time in Spanish: Explanation Practice exercise index McCarron.
La Lección del Repaso Antes de entrar en la clase de Español IV, necesita saber esta información.
Articles, nouns and contractions oh my!. The POWER of the article THE 1. There are four ways to express THE in Spanish 2. The four ways are: El La Los.
1 Day 4- Present tense conjugations of Regular –AR verbs An Online Learning Module Adapted from PowerShow.com Los Verbos Regulares.
In Spanish, adverbial clauses are commonly introduced by conjunctions
P In this slide show, we are going to look at a verb form that has all but disappeared from English – the subjunctive! In this slide show, we.
 Making complete sentences How to make complete sentences in Spanish. The following presentation is designed to help you learn how to do the following:
Expresiones afirmativas y negativas
The Subjunctive In this slide show, we are going to look at a verb form that has all but disappeared from English – the subjunctive!
 1. Why should a person learn Spanish? Give at least 3 reasons in your explanation.  2. What Spanish experiences have you had? (None is not an option.
Lección 10: Gramática Los participios pasados Pretérito perfecto
ANTE TODO ¿Dibujas mucho? ¿También tomas tú geografía?
Quantity How much? How many?
Los números Mathematical problem solving Existence/Non-existence Quantity How much? How many?
¿Qué hora es? What time is it?. ¿Qué hora es? It’s 1:00 Es la una (notice we do not say uno for time but una) 1:00 is the ONLY time where we say “Es la…”
PL/SQL Francisco Moreno Universidad Nacional.
CURSORES Preparó: Ismael Castañeda Fuentes Fuentes: Manuales Sybase
PL/SQL Francisco Moreno Universidad Nacional. Introducción al PL/SQL ¿Por qué PL/SQL? A pesar de que SQL tiene mecanismos de control condicional (cláusula.
Aislamiento Bloqueo.
16/04/ Sesión 11 Funciones y procedimientos Ing. Ricardo Inquilla.
PL/SQL Francisco Moreno Universidad Nacional.
Características Objeto Relacionales en Oracle
BASE DE DATOS IUPSM CLASE PRACTICA. PROF. ING. JOSE L GUZMAN H.
UN DISPARADOR O TRIGGER es un procedimiento que se ejecuta cuando se cumple una condición establecida al realizar una operación. Es una rutina autónoma.
Oracle Pl/SQl Developer – Nivel 1
Transcripción de la presentación:

Bases de Datos Relacionales Preparó: Ismael Castañeda Fuentes Fuentes:Manuales Sybase Manuales SQL Server Manuales Oracle BATCHS

Ambiente de ejecución El código se puede ejecutar en: – Cliente – Servidor Ventajas de programar en el lado cliente – Atiende usuarios finales con diferentes necesidades – Evita tráfico en la red – Se distribuye una parte del procesamiento – Puede facilitar la interacción del usuario Ventajas de programar en el lado servidor – Se tiene concentración de los recursos – Uniformisa la aplicación de las reglas del negocio – Se puede actualizar más fácilmente el código

Batch Una o más sentencias enviadas y ejecutadas como una sola Ejemplo: delete sales where stor_id = "5023" and ord_num = "AB-123-DEF-425-1Z3" delete salesdetail where stor_id = "5023" and ord_num = "AB-123-DEF-425-1Z3" select * from sales where stor_id = "5023" select * from salesdetail where stor_id = "5023" go

Restriciones de los batch Esta sentencias deben tener su propio batch: – create default – create rule – create procedure – create trigger – declare cursor No se puede borrar y recrear un objeto en el mismo batch sentencia use No se puede asignar una regla o default a una columna e insertarle valores en el mismo batch

Comentarios Porción de código ignorado por el servidor Usados para documentar Dos formas: -- comentario hasta el final de una línea /* comentario multilínea */

Variables locales Variable local: nombre de una posición de memoria para almacenar un valor Uso típico de las variables locales – Para facilitar el uso repetido de valores constantes – Para ejecutar bifurcamiento en código SQL – Para capturar mensajes que contienen información variable – Para intercambio de información con stored procedures – Para evitar el uso de subquerys

Variables locales - Asignación con select y expresiones Sintaxis simplificada: select variable_name = expression [, variable_name = expression...] Ejemplos: int = Si select no retorna valores, la variable no cambia su valor

Variables locales - Asignación con select y valores de tabla Sintaxis simplificada: select variable_name = column_name from table_name [where condition] Ejemplos: char(11) = au_id from authors where au_fname = "Ann" and au_lname = "Dull" Si el select retorna múltiples valores, solamente toma el último

Variables locales - Asignación con update Sintaxis simplificada: update table_name set {column_name | variable_name } = expression [, {column_name | variable_name } = expression... ] [where condition] Ejemplos: varchar(40) update publishers set city = "Escanaba", state = = pub_name where pub_id = "0736" Si update modifica múltiples filas, solamente el último asignado permanece en la variable

Variables locales – Declaración - Ejemplo Las variables se deben declarar antes de usarlas Ejemplo: select pub_id from publishers = total_sales from titles where title_id = "BU2075" Server Message: Number 137, Severity 15 Line 3: Must declare variable

Variables locales – Concordancia - Ejemplo Los valores de las variables deben de concordar con el tipo de dato de la variable Ejemplo: int = title from titles where title_id = "BU2075" Server Message: Number 257, Severity 16 Line 2: Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed. Use the CONVERT function to run this query.

Variables locales – Retorno de un select - Ejemplo Si el select no retorna valores, la variable no cambia Ejemplo: int = total_sales from titles where title_id = "BU2075" as "BU2075 sales" = total_sales from titles where title_id = "BU11"-- should be "BU1111" as "BU1111 sales" Primer query:Segundo query: BU2075 salesBU1111 sales

Variables locales - Alcance -Ejemplo Las variables locales se borran al terminar el batch que las crea -- Declare a local variable: char(4) -- Assign the variable a value from a table: = pub_id from pubs2..publishers where pub_name = "New Age Books" -- View the variables value: --- Use the variable in a select statement: select title_id, title, pub_id from pubs2..titles where pub_id -- Execute the batch. (Users of SQL Advantage do -- not need to enter "go" to complete this step): go

Variables globales Variable global: nombre de una posición de memoria para almacenar un valor definido y mantenido por el servidor

Variables globales - Ejemplo Ejemplo_1: delete from titles where type = "popular_comp" select Ejemplo_2: delete from titles where type = "popular_comp" select

Variables globales – Ejemplo con Ejemplo: -- The word "from" is misplaced delete titles from where type = "psychology" Server Message: Number 156, Severity 15 Line 4: Incorrect syntax near the keyword 'where'. select

Variables globales – Ejemplo con Crear una tabla: select * into mytitles from pubs2..titles Intentar borrar una tabla inexistente : delete from no_table select Ejecutar un delete con una condición que nunca se cumple: delete from mytitles where 1 = 2 select ¿El segundo delete generate un error? ¿Por qué o por qué no? Borrar los objetos de bases de datos creados: drop table mytitles

Sentencias de control de flujo Por default los servidores ejecutan las sentencias en el orden en que ellas aparecen Las siguientes son sentencias de control de flujo: – if...else – begin...end – if exists – while – break – continue – return

if...else Sintaxis simplificada: if condition block_to_execute_when_condition_is_true [ else block_to_execute_when_condition_is_false ] Ejemplo: delete from titles where type = "mod_cook" if <> 0 select "An error has occurred!" else select "The delete was successful."

Condiciones anidadas Ejemplo: delete from titles where type = "mod_cook" if = 0 select "No rows were deleted." else if = 1 select "One row was deleted." else select "Multiple rows were deleted."

begin...end Sintaxis: begin statement... end Ejemplo:... = "TC4203" begin = "trad_cook" delete titles where type = "trad_cook" end else begin select "Title has already been deleted" end

if exists Sintaxis simplificada: if [ not ] exists ( select_statement ) code_to_execute_when_condition_is_true [ else code_to_execute_when_condition_is_false ] Ejemplo_1: if exists (select * from titles where price > $50.00) update titles set price = price * $0.90 else select "All titles priced under $50.00 Ejemplo_2 : if exists (select * from sysobjects where name = "vw_utah_authors" and type = "V") drop view vw_utah_authors go create view vw_utah_authors as select * from authors where state = "UT" with check option

Sentencias if Ejemplo: if (select avg(price) from pubs2..titles) > $25 select "These books are expensive." else select "These books are a bargain." Ejemplo : drop table mysales Ejemplo : if exists (select * from sysobjects where name = "mysales and type = "U") drop table mysales

while Sintaxis: while condition block_to_execute Ejemplo_1: while (select avg(price) from titles) < $40 begin update titles set price = price + $2 end Ejemplo_2: money = price from titles where title_id = "PS1372" < $30 begin update titles set price = price * $1.10 where title_id = "PS1372" end -- The loop updates the price of PS1372, but -- never updates the value Because -- the loop condition is based -- execution of the loop would never terminate.

break Ejemplo: -- While the average price is greater than -- $20, this loop cuts all prices in half. -- However, if the maximum price falls below -- $40, the loop is immediately terminated. while (select avg(price) from titles) > $20 begin update titles set price = price / 2 if (select max(price) from titles) < $40 break end

continue Ejemplo: -- is less than $20, this loop adds -- $1 If there are 5 or more titles -- it restarts the loop. Otherwise, -- it increases all books priced by 10%.... < $20.00 begin + $1.00 if (select count(price) from titles where price >= 5 continue else update titles set price = price * $1.10 where price end

return Ejemplo: is declared and set to the average -- price in titles. If the average is less than -- $10, execution exits the entire batch. -- Otherwise, it continues execution. money = avg(price) from titles < $10 return < $20 begin update titles set price = price * $0.95 = avg(price) from titles end

Ciclos while Ejemplo: money = $0 < (select max(price) from pubs2..titles) begin + $1 select "Titles less than select price, title from pubs2..titles where price end

select Sintaxis simplificada: select { "user_message" | variable_name | column_list } Ejemplo: select "The average price is too low." select "The average price is select "The average price is ", avg(price) from titles Puede retornar texto, valores variables, y datos de tabla en cualquier combinación