MySQL

Creación de Base de Datos en MySQL MySQL MySQL es un sistema de gestión de base de datos relacional, multihilo y multius

Views 151 Downloads 1 File size 1MB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

Creación de Base de Datos en MySQL MySQL MySQL es un sistema de gestión de base de datos relacional, multihilo y multiusuario con más de seis millones de instalaciones.MySQL AB desde enero de 2008 una subsidiaria de Sun Microsystems y ésta a su vez de Oracle Corporation desde abril de 2009 desarrolla MySQL como software libre en un esquema de licenciamiento dual. Por un lado se ofrece bajo la GNU GPL para cualquier uso compatible con esta licencia, pero para aquellas empresas que quieran incorporarlo en productos privativos deben comprar a la empresa una licencia específica que les permita este uso. Está desarrollado en su mayor parte en ANSI C. MySQL es propietario y está patrocinado por una empresa privada, que posee el copyright de la mayor parte del código. Esto es lo que posibilita el esquema de licenciamiento anteriormente mencionado. Además de la venta de licencias privativas, la compañía ofrece soporte y servicios.

Aplicaciones MySQL es muy utilizado en aplicaciones web, como Drupal o phpBB, en plataformas (Linux/Windows-Apache-MySQL-PHP/Perl/Python), y por herramientas de seguimiento de errores como Bugzilla. Su popularidad como aplicación web está muy ligada a PHP, que a menudo aparece en combinación con MySQL. MySQL es una base de datos muy rápida en la lectura cuando utiliza el motor no transaccional MyISAM, pero puede provocar problemas de integridad en entornos de alta concurrencia en la modificación. En aplicaciones web hay baja concurrencia en la modificación de datos y en cambio el entorno es intensivo en lectura de datos, lo que hace a MySQL ideal para este tipo de aplicaciones.

Caracteristicas Principales                

Un amplio subconjunto de ANSI SQL 99, y varias extensiones. Soporte a multiplataforma Procedimientos almacenados Cursores Vistas actualizables Soporte a VARCHAR INFORMATION_SCHEMA Modo Strict Soporte X/Open XA de transacciones distribuidas; transacción en dos fases como parte de esto, utilizando el motor InnoDB de Oracle Motores de almacenamiento independientes (MyISAM para lecturas rápidas, InnoDB para transacciones e integridad referencial) Transacciones con los motores de almacenamiento InnoDB, BDB Y Cluster; puntos de recuperación (savepoints) con InnoDB Soporte para SSL Query caching Sub-SELECTs (o SELECTs anidados) Réplica con un maestro por esclavo, varios esclavos por maestro, sin soporte automático para múltiples maestros por esclavo. indexing y buscando campos de texto completos usando el motor de almacenamiento MyISAM

   

Embedded database library Soporte completo para Unicode Conforme a las reglas ACID usando los motores InnoDB, BDB y Cluster Shared-nothing clustering through MySQL Cluster

Instalación DBMS

Configuración

Interface

MySQL Administrator

MySQL Query Browser

Creación de Bases de Datos

Creación de la Base Consultas, Vistas, Procedimientos, Updates y Deletes Script Consultas y Vistas VISTAS.use Northwind;

1. Crear una vista con la lista de productos create view vista1 AS SELECT Products.*, Categories.CategoryName FROM Categories JOIN Products ON Categories.CategoryID = Products.CategoryID WHERE (((Products.Discontinued)=0)) DROP VIEW vista1 select * from vista1

----------RESULTADOS: ----------1, 'Chai', 1, 1, '10 boxes x 20 bags', 18, 39, 0, 10, '', 'Beverages' 2, 'Chang', 1, 1, '24 - 12 oz bottles', 19, 17, 40, 25, '', 'Beverages' 34, 'Sasquatch Ale', 16, 1, '24 - 12 oz bottles', 14, 111, 0, 15, '', 'Beverages' 35, 'Steeleye Stout', 16, 1, '24 - 12 oz bottles', 18, 20, 0, 15, '', 'Beverages' 38, 'Côte de Blaye', 18, 1, '12 - 75 cl bottles', 263.5, 17, 0, 15, '', 'Beverages' 39, 'Chartreuse verte', 18, 1, '750 cc per bottle', 18, 69, 0, 5, '', 'Beverages' 43, 'Ipoh Coffee', 20, 1, '16 - 500 g tins', 46, 17, 10, 25, '', 'Beverages' 67, 'Laughing Lumberjack Lager', 16, 1, '24 - 12 oz bottles', 14, 52, 0, 10, '', 'Beverages' 70, 'Outback Lager', 7, 1, '24 - 355 ml bottles', 15, 15, 10, 30, '', 'Beverages' 75, 'Rhönbräu Klosterbier', 12, 1, '24 - 0.5 l bottles', 7.75, 125, 0, 25, '', 'Beverages' 76, 'Lakkalikööri', 23, 1, '500 ml', 18, 57, 0, 20, '', 'Beverages' 3, 'Aniseed Syrup', 1, 2, '12 - 550 ml bottles', 10, 13, 70, 25, '', 'Condiments' 4, 'Chef Anton's Cajun Seasoning', 2, 2, '48 - 6 oz jars', 22, 53, 0, 0, '', 'Condiments' 6, 'Grandma's Boysenberry Spread', 3, 2, '12 - 8 oz jars', 25, 120, 0, 25, '', 'Condiments' 8, 'Northwoods Cranberry Sauce', 3, 2, '12 - 12 oz jars', 40, 6, 0, 0, '', 'Condiments' 15, 'Genen Shouyu', 6, 2, '24 - 250 ml bottles', 15.5, 39, 0, 5, '', 'Condiments' 44, 'Gula Malacca', 20, 2, '20 - 2 kg bags', 19.45, 27, 0, 15, '', 'Condiments' 61, 'Sirop d'érable', 29, 2, '24 - 500 ml bottles', 28.5, 113, 0, 25, '', 'Condiments' 63, 'Vegie-spread', 7, 2, '15 - 625 g jars', 43.9, 24, 0, 5, '', 'Condiments' 65, 'Louisiana Fiery Hot Pepper Sauce', 2, 2, '32 - 8 oz bottles', 21.05, 76, 0, 0, '', 'Condiments' 66, 'Louisiana Hot Spiced Okra', 2, 2, '24 - 8 oz jars', 17, 4, 100, 20, '', 'Condiments' 77, 'Original Frankfurter grüne Soße', 12, 2, '12 boxes', 13, 32, 0, 15, '', 'Condiments' 16, 'Pavlova', 7, 3, '32 - 500 g boxes', 17.45, 29, 0, 10, '', 'Confections' 19, 'Teatime Chocolate Biscuits', 8, 3, '10 boxes x 12 pieces', 9.2, 25, 0, 5, '', 'Confections' 20, 'Sir Rodney's Marmalade', 8, 3, '30 gift boxes', 81, 40, 0, 0, '', 'Confections' 21, 'Sir Rodney's Scones', 8, 3, '24 pkgs. x 4 pieces', 10, 3, 40, 5, '', 'Confections' 25, 'NuNuCa Nuß-Nougat-Creme', 11, 3, '20 - 450 g glasses', 14, 76, 0, 30, '', 'Confections' 26, 'Gumbär Gummibärchen', 11, 3, '100 - 250 g bags', 31.23, 15, 0, 0, '', 'Confections' 27, 'Schoggi Schokolade', 11, 3, '100 - 100 g pieces', 43.9, 49, 0, 30, '', 'Confections' 47, 'Zaanse koeken', 22, 3, '10 - 4 oz boxes', 9.5, 36, 0, 0, '', 'Confections' 48, 'Chocolade', 22, 3, '10 pkgs.', 12.75, 15, 70, 25, '', 'Confections' 49, 'Maxilaku', 23, 3, '24 - 50 g pkgs.', 20, 10, 60, 15, '', 'Confections' 50, 'Valkoinen suklaa', 23, 3, '12 - 100 g bars', 16.25, 65, 0, 30, '', 'Confections' 62, 'Tarte au sucre', 29, 3, '48 pies', 49.3, 17, 0, 0, '', 'Confections' 68, 'Scottish Longbreads', 8, 3, '10 boxes x 8 pieces', 12.5, 6, 10, 15, '', 'Confections' 11, 'Queso Cabrales', 5, 4, '1 kg pkg.', 21, 22, 30, 30, '', 'Dairy Products' 12, 'Queso Manchego La Pastora', 5, 4, '10 - 500 g pkgs.', 38, 86, 0, 0, '', 'Dairy Products' 31, 'Gorgonzola Telino', 14, 4, '12 - 100 g pkgs', 12.5, 0, 70, 20, '', 'Dairy Products' 32, 'Mascarpone Fabioli', 14, 4, '24 - 200 g pkgs.', 32, 9, 40, 25, '', 'Dairy Products' 33, 'Geitost', 15, 4, '500 g', 2.5, 112, 0, 20, '', 'Dairy Products' 59, 'Raclette Courdavault', 28, 4, '5 kg pkg.', 55, 79, 0, 0, '', 'Dairy Products' 60, 'Camembert Pierrot', 28, 4, '15 - 300 g rounds', 34, 19, 0, 0, '', 'Dairy Products' 69, 'Gudbrandsdalsost', 15, 4, '10 kg pkg.', 36, 26, 0, 15, '', 'Dairy Products' 71, 'Fløtemysost', 15, 4, '10 - 500 g pkgs.', 21.5, 26, 0, 0, '', 'Dairy Products' 72, 'Mozzarella di Giovanni', 14, 4, '24 - 200 g pkgs.', 34.8, 14, 0, 0, '', 'Dairy Products' 22, 'Gustaf's Knäckebröd', 9, 5, '24 - 500 g pkgs.', 21, 104, 0, 25, '', 'Grains/Cereals' 23, 'Tunnbröd', 9, 5, '12 - 250 g pkgs.', 9, 61, 0, 25, '', 'Grains/Cereals' 52, 'Filo Mix', 24, 5, '16 - 2 kg boxes', 7, 38, 0, 25, '', 'Grains/Cereals' 56, 'Gnocchi di nonna Alice', 26, 5, '24 - 250 g pkgs.', 38, 21, 10, 30, '', 'Grains/Cereals' 57, 'Ravioli Angelo', 26, 5, '24 - 250 g pkgs.', 19.5, 36, 0, 20, '', 'Grains/Cereals' 64, 'Wimmers gute Semmelknödel', 12, 5, '20 bags x 4 pieces', 33.25, 22, 80, 30, '', 'Grains/Cereals' 54, 'Tourtière', 25, 6, '16 pies', 7.45, 21, 0, 10, '', 'Meat/Poultry' 55, 'Pâté chinois', 25, 6, '24 boxes x 2 pies', 24, 115, 0, 20, '', 'Meat/Poultry' 7, 'Uncle Bob's Organic Dried Pears', 3, 7, '12 - 1 lb pkgs.', 30, 15, 0, 10, '', 'Produce' 14, 'Tofu', 6, 7, '40 - 100 g pkgs.', 23.25, 35, 0, 0, '', 'Produce' 51, 'Manjimup Dried Apples', 24, 7, '50 - 300 g pkgs.', 53, 20, 0, 10, '', 'Produce' 74, 'Longlife Tofu', 4, 7, '5 kg pkg.', 10, 4, 20, 5, '', 'Produce' 10, 'Ikura', 4, 8, '12 - 200 ml jars', 31, 31, 0, 0, '', 'Seafood' 13, 'Konbu', 6, 8, '2 kg box', 6, 24, 0, 5, '', 'Seafood' 18, 'Carnarvon Tigers', 7, 8, '16 kg pkg.', 62.5, 42, 0, 0, '', 'Seafood' 30, 'Nord-Ost Matjeshering', 13, 8, '10 - 200 g glasses', 25.89, 10, 0, 15, '', 'Seafood' 36, 'Inlagd Sill', 17, 8, '24 - 250 g jars', 19, 112, 0, 20, '', 'Seafood' 37, 'Gravad lax', 17, 8, '12 - 500 g pkgs.', 26, 11, 50, 25, '', 'Seafood' 40, 'Boston Crab Meat', 19, 8, '24 - 4 oz tins', 18.4, 123, 0, 30, '', 'Seafood' 41, 'Jack's New England Clam Chowder', 19, 8, '12 - 12 oz cans', 9.65, 85, 0, 10, '', 'Seafood' 45, 'Røgede sild', 21, 8, '1k pkg.', 9.5, 5, 70, 15, '', 'Seafood' 46, 'Spegesild', 21, 8, '4 - 450 g glasses', 12, 95, 0, 0, '', 'Seafood' 58, 'Escargots de Bourgogne', 27, 8, '24 pieces', 13.25, 62, 0, 20, '', 'Seafood' 73, 'Röd Kaviar', 17, 8, '24 - 150 g jars', 15, 101, 0, 5, '', 'Seafood'

2. Crear una vista con la lista de productos que están sobre el precio promedio ordenados por precio unitario create view vista2 AS SELECT Products.ProductName, Products.UnitPrice FROM Products WHERE Products.UnitPrice>(SELECT AVG(UnitPrice) From Products) ORDER BY Products.UnitPrice DESC DROP VIEW vista2 select * from vista2

----------RESULTADOS: ----------'Côte de Blaye', 263.5 'Thüringer Rostbratwurst', 123.79 'Mishi Kobe Niku', 97 'Sir Rodney's Marmalade', 81 'Carnarvon Tigers', 62.5 'Raclette Courdavault', 55 'Manjimup Dried Apples', 53 'Tarte au sucre', 49.3 'Ipoh Coffee', 46 'Rössle Sauerkraut', 45.6 'Schoggi Schokolade', 43.9 'Vegie-spread', 43.9 'Northwoods Cranberry Sauce', 40 'Alice Mutton', 39 'Queso Manchego La Pastora', 38 'Gnocchi di nonna Alice', 38 'Gudbrandsdalsost', 36 'Mozzarella di Giovanni', 34.8 'Camembert Pierrot', 34 'Wimmers gute Semmelknödel', 33.25 'Perth Pasties', 32.8 'Mascarpone Fabioli', 32 'Gumbär Gummibärchen', 31.23 'Ikura', 31 'Uncle Bob's Organic Dried Pears', 30

3. Crear una vista con los productos por categoría que todavía están siendo comprados create view vista3 AS SELECT Categories.CategoryName, Products.ProductName, Products.QuantityPerUnit,Products.UnitsInStock, Products.Discontinued FROM Categories JOIN Products ON Categories.CategoryID = Products.CategoryID WHERE Products.Discontinued 1

DROP VIEW vista3

select * from vista3

----------RESULTADOS: ----------'Beverages', 'Chai', '10 boxes x 20 bags', 39, '' 'Beverages', 'Chang', '24 - 12 oz bottles', 17, '' 'Beverages', 'Sasquatch Ale', '24 - 12 oz bottles', 111, '' 'Beverages', 'Steeleye Stout', '24 - 12 oz bottles', 20, '' 'Beverages', 'Côte de Blaye', '12 - 75 cl bottles', 17, '' 'Beverages', 'Chartreuse verte', '750 cc per bottle', 69, '' 'Beverages', 'Ipoh Coffee', '16 - 500 g tins', 17, '' 'Beverages', 'Laughing Lumberjack Lager', '24 - 12 oz bottles', 52, '' 'Beverages', 'Outback Lager', '24 - 355 ml bottles', 15, '' 'Beverages', 'Rhönbräu Klosterbier', '24 - 0.5 l bottles', 125, '' 'Beverages', 'Lakkalikööri', '500 ml', 57, '' 'Condiments', 'Aniseed Syrup', '12 - 550 ml bottles', 13, '' 'Condiments', 'Chef Anton's Cajun Seasoning', '48 - 6 oz jars', 53, '' 'Condiments', 'Grandma's Boysenberry Spread', '12 - 8 oz jars', 120, '' 'Condiments', 'Northwoods Cranberry Sauce', '12 - 12 oz jars', 6, '' 'Condiments', 'Genen Shouyu', '24 - 250 ml bottles', 39, '' 'Condiments', 'Gula Malacca', '20 - 2 kg bags', 27, '' 'Condiments', 'Sirop d'érable', '24 - 500 ml bottles', 113, '' 'Condiments', 'Vegie-spread', '15 - 625 g jars', 24, '' 'Condiments', 'Louisiana Fiery Hot Pepper Sauce', '32 - 8 oz bottles', 76, '' 'Condiments', 'Louisiana Hot Spiced Okra', '24 - 8 oz jars', 4, '' 'Condiments', 'Original Frankfurter grüne Soße', '12 boxes', 32, '' 'Confections', 'Pavlova', '32 - 500 g boxes', 29, '' 'Confections', 'Teatime Chocolate Biscuits', '10 boxes x 12 pieces', 25, '' 'Confections', 'Sir Rodney's Marmalade', '30 gift boxes', 40, '' 'Confections', 'Sir Rodney's Scones', '24 pkgs. x 4 pieces', 3, '' 'Confections', 'NuNuCa Nuß-Nougat-Creme', '20 - 450 g glasses', 76, '' 'Confections', 'Gumbär Gummibärchen', '100 - 250 g bags', 15, '' 'Confections', 'Schoggi Schokolade', '100 - 100 g pieces', 49, '' 'Confections', 'Zaanse koeken', '10 - 4 oz boxes', 36, '' 'Confections', 'Chocolade', '10 pkgs.', 15, '' 'Confections', 'Maxilaku', '24 - 50 g pkgs.', 10, '' 'Confections', 'Valkoinen suklaa', '12 - 100 g bars', 65, '' 'Confections', 'Tarte au sucre', '48 pies', 17, '' 'Confections', 'Scottish Longbreads', '10 boxes x 8 pieces', 6, '' 'Dairy Products', 'Queso Cabrales', '1 kg pkg.', 22, '' 'Dairy Products', 'Queso Manchego La Pastora', '10 - 500 g pkgs.', 86, '' 'Dairy Products', 'Gorgonzola Telino', '12 - 100 g pkgs', 0, '' 'Dairy Products', 'Mascarpone Fabioli', '24 - 200 g pkgs.', 9, '' 'Dairy Products', 'Geitost', '500 g', 112, '' 'Dairy Products', 'Raclette Courdavault', '5 kg pkg.', 79, '' 'Dairy Products', 'Camembert Pierrot', '15 - 300 g rounds', 19, '' 'Dairy Products', 'Gudbrandsdalsost', '10 kg pkg.', 26, '' 'Dairy Products', 'Fløtemysost', '10 - 500 g pkgs.', 26, '' 'Dairy Products', 'Mozzarella di Giovanni', '24 - 200 g pkgs.', 14, '' 'Grains/Cereals', 'Gustaf's Knäckebröd', '24 - 500 g pkgs.', 104, '' 'Grains/Cereals', 'Tunnbröd', '12 - 250 g pkgs.', 61, '' 'Grains/Cereals', 'Filo Mix', '16 - 2 kg boxes', 38, '' 'Grains/Cereals', 'Gnocchi di nonna Alice', '24 - 250 g pkgs.', 21, '' 'Grains/Cereals', 'Ravioli Angelo', '24 - 250 g pkgs.', 36, '' 'Grains/Cereals', 'Wimmers gute Semmelknödel', '20 bags x 4 pieces', 22, '' 'Meat/Poultry', 'Tourtière', '16 pies', 21, '' 'Meat/Poultry', 'Pâté chinois', '24 boxes x 2 pies', 115, '' 'Produce', 'Uncle Bob's Organic Dried Pears', '12 - 1 lb pkgs.', 15, '' 'Produce', 'Tofu', '40 - 100 g pkgs.', 35, '' 'Produce', 'Manjimup Dried Apples', '50 - 300 g pkgs.', 20, '' 'Produce', 'Longlife Tofu', '5 kg pkg.', 4, '' 'Seafood', 'Ikura', '12 - 200 ml jars', 31, '' 'Seafood', 'Konbu', '2 kg box', 24, '' 'Seafood', 'Carnarvon Tigers', '16 kg pkg.', 42, '' 'Seafood', 'Nord-Ost Matjeshering', '10 - 200 g glasses', 10, '' 'Seafood', 'Inlagd Sill', '24 - 250 g jars', 112, '' 'Seafood', 'Gravad lax', '12 - 500 g pkgs.', 11, '' 'Seafood', 'Boston Crab Meat', '24 - 4 oz tins', 123, '' 'Seafood', 'Jack's New England Clam Chowder', '12 - 12 oz cans', 85, '' 'Seafood', 'Røgede sild', '1k pkg.', 5, '' 'Seafood', 'Spegesild', '4 - 450 g glasses', 95, '' 'Seafood', 'Escargots de Bourgogne', '24 pieces', 62, '' 'Seafood', 'Röd Kaviar', '24 - 150 g jars', 101, ''

4. Crear una vista con los clientes y proveedores /*select * from customers Create view vista4 AS SELECT City, CompanyName, ContactName, 'Customers' AS Relationship FROM Customers UNION SELECT City, CompanyName, ContactName, 'Suppliers' FROM Suppliers /* DROP VIEW vista4 select * from vista4 ----------RESULTADOS: ----------'Berlin', 'Alfreds Futterkiste', 'Maria Anders', 'Customers' 'México D.F.', 'Ana Trujillo Emparedados y helados', 'Ana Trujillo', 'Customers' 'México D.F.', 'Antonio Moreno Taquería', 'Antonio Moreno', 'Customers' 'London', 'Around the Horn', 'Thomas Hardy', 'Customers' 'Luleå', 'Berglunds snabbköp', 'Christina Berglund', 'Customers' 'Mannheim', 'Blauer See Delikatessen', 'Hanna Moos', 'Customers' 'Strasbourg', 'Blondel père et fils', 'Frédérique Citeaux', 'Customers' 'Madrid', 'Bólido Comidas preparadas', 'Martín Sommer', 'Customers' 'Marseille', 'Bon app'', 'Laurence Lebihan', 'Customers' 'Tsawassen', 'Bottom-Dollar Markets', 'Elizabeth Lincoln', 'Customers' 'London', 'B's Beverages', 'Victoria Ashworth', 'Customers' 'Buenos Aires', 'Cactus Comidas para llevar', 'Patricio Simpson', 'Customers' 'México D.F.', 'Centro comercial Moctezuma', 'Francisco Chang', 'Customers' 'Bern', 'Chop-suey Chinese', 'Yang Wang', 'Customers' 'São Paulo', 'Comércio Mineiro', 'Pedro Afonso', 'Customers' 'London', 'Consolidated Holdings', 'Elizabeth Brown', 'Customers' 'Aachen', 'Drachenblut Delikatessen', 'Sven Ottlieb', 'Customers' 'Nantes', 'Du monde entier', 'Janine Labrune', 'Customers' 'London', 'Eastern Connection', 'Ann Devon', 'Customers' 'Graz', 'Ernst Handel', 'Roland Mendel', 'Customers' 'São Paulo', 'Familia Arquibaldo', 'Aria Cruz', 'Customers' 'Madrid', 'FISSA Fabrica Inter. Salchichas S.A.', 'Diego Roel', 'Customers' 'Lille', 'Folies gourmandes', 'Martine Rancé', 'Customers' 'Bräcke', 'Folk och fä HB', 'Maria Larsson', 'Customers' 'München', 'Frankenversand', 'Peter Franken', 'Customers' 'Nantes', 'France restauration', 'Carine Schmitt', 'Customers' 'Torino', 'Franchi S.p.A.', 'Paolo Accorti', 'Customers' 'Lisboa', 'Furia Bacalhau e Frutos do Mar', 'Lino Rodriguez ', 'Customers' 'Barcelona', 'Galería del gastrónomo', 'Eduardo Saavedra', 'Customers' 'Sevilla', 'Godos Cocina Típica', 'José Pedro Freyre', 'Customers' 'Campinas', 'Gourmet Lanchonetes', 'André Fonseca', 'Customers' 'Eugene', 'Great Lakes Food Market', 'Howard Snyder', 'Customers' 'Caracas', 'GROSELLA-Restaurante', 'Manuel Pereira', 'Customers' 'Rio de Janeiro', 'Hanari Carnes', 'Mario Pontes', 'Customers' 'San Cristóbal', 'HILARIÓN-Abastos', 'Carlos Hernández', 'Customers' 'Elgin', 'Hungry Coyote Import Store', 'Yoshi Latimer', 'Customers' 'Cork', 'Hungry Owl All-Night Grocers', 'Patricia McKenna', 'Customers' 'Cowes', 'Island Trading', 'Helen Bennett', 'Customers' 'Brandenburg', 'Königlich Essen', 'Philip Cramer', 'Customers' 'Versailles', 'La corne d'abondance', 'Daniel Tonini', 'Customers' 'Toulouse', 'La maison d'Asie', 'Annette Roulet', 'Customers' 'Vancouver', 'Laughing Bacchus Wine Cellars', 'Yoshi Tannamuri', 'Customers' 'Walla Walla', 'Lazy K Kountry Store', 'John Steel', 'Customers' 'Frankfurt a.M. ', 'Lehmanns Marktstand', 'Renate Messner', 'Customers' 'San Francisco', 'Let's Stop N Shop', 'Jaime Yorres', 'Customers' 'Barquisimeto', 'LILA-Supermercado', 'Carlos González', 'Customers' 'I. de Margarita', 'LINO-Delicateses', 'Felipe Izquierdo', 'Customers' 'Portland', 'Lonesome Pine Restaurant', 'Fran Wilson', 'Customers' 'Bergamo', 'Magazzini Alimentari Riuniti', 'Giovanni Rovelli', 'Customers'

'Bruxelles', 'Maison Dewey', 'Catherine Dewey', 'Customers' 'Montréal', 'Mère Paillarde', 'Jean Fresnière', 'Customers' 'Leipzig', 'Morgenstern Gesundkost', 'Alexander Feuer', 'Customers' 'London', 'North/South', 'Simon Crowther', 'Customers' 'Buenos Aires', 'Océano Atlántico Ltda.', 'Yvonne Moncada', 'Customers' 'Anchorage', 'Old World Delicatessen', 'Rene Phillips', 'Customers' 'Köln', 'Ottilies Käseladen', 'Henriette Pfalzheim', 'Customers' 'Paris', 'Paris spécialités', 'Marie Bertrand', 'Customers' 'México D.F.', 'Pericles Comidas clásicas', 'Guillermo Fernández', 'Customers' 'Salzburg', 'Piccolo und mehr', 'Georg Pipps', 'Customers' 'Lisboa', 'Princesa Isabel Vinhos', 'Isabel de Castro', 'Customers' 'Rio de Janeiro', 'Que Delícia', 'Bernardo Batista', 'Customers' 'São Paulo', 'Queen Cozinha', 'Lúcia Carvalho', 'Customers' 'Cunewalde', 'QUICK-Stop', 'Horst Kloss', 'Customers' 'Buenos Aires', 'Rancho grande', 'Sergio Gutiérrez', 'Customers' 'Albuquerque', 'Rattlesnake Canyon Grocery', 'Paula Wilson', 'Customers' 'Reggio Emilia', 'Reggiani Caseifici', 'Maurizio Moroni', 'Customers' 'Rio de Janeiro', 'Ricardo Adocicados', 'Janete Limeira', 'Customers' 'Genève', 'Richter Supermarkt', 'Michael Holz', 'Customers' 'Madrid', 'Romero y tomillo', 'Alejandra Camino', 'Customers' 'Stavern', 'Santé Gourmet', 'Jonas Bergulfsen', 'Customers' 'Boise', 'Save-a-lot Markets', 'Jose Pavarotti', 'Customers' 'London', 'Seven Seas Imports', 'Hari Kumar', 'Customers' 'København', 'Simons bistro', 'Jytte Petersen', 'Customers' 'Paris', 'Spécialités du monde', 'Dominique Perrier', 'Customers' 'Lander', 'Split Rail Beer & Ale', 'Art Braunschweiger', 'Customers' 'Charleroi', 'Suprêmes délices', 'Pascale Cartrain', 'Customers' 'Portland', 'The Big Cheese', 'Liz Nixon', 'Customers' 'Butte', 'The Cracker Box', 'Liu Wong', 'Customers' 'Münster', 'Toms Spezialitäten', 'Karin Josephs', 'Customers' 'México D.F.', 'Tortuga Restaurante', 'Miguel Angel Paolino', 'Customers' 'São Paulo', 'Tradição Hipermercados', 'Anabela Domingues', 'Customers' 'Kirkland', 'Trail's Head Gourmet Provisioners', 'Helvetius Nagy', 'Customers' 'Århus', 'Vaffeljernet', 'Palle Ibsen', 'Customers' 'Lyon', 'Victuailles en stock', 'Mary Saveley', 'Customers' 'Reims', 'Vins et alcools Chevalier', 'Paul Henriot', 'Customers' 'Stuttgart', 'Die Wandernde Kuh', 'Rita Müller', 'Customers' 'Oulu', 'Wartian Herkku', 'Pirkko Koskitalo', 'Customers' 'Resende', 'Wellington Importadora', 'Paula Parente', 'Customers' 'Seattle', 'White Clover Markets', 'Karl Jablonski', 'Customers' 'Helsinki', 'Wilman Kala', 'Matti Karttunen', 'Customers' 'Warszawa', 'Wolski Zajazd', 'Zbyszek Piestrzeniewicz', 'Customers' 'London', 'Exotic Liquids', 'Charlotte Cooper', 'Suppliers'

5. Consulta sobre las ordenes que fueron enviados a México create view vista5 AS SELECT Orders.OrderID, Orders.CustomerID, Orders.EmployeeID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate, Orders.ShipVia, Orders.Freight, Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode, Orders.ShipCountry, Customers.CompanyName, Customers.Address, Customers.City, Customers.Region, Customers.PostalCode, Customers.Country FROM Customers JOIN Orders ON Customers.CustomerID = Orders.CustomerID where ShipCountry= 'Mexico' DROP VIEW vista5 select * from vista5

----------RESULTADOS: ----------10308, 'ANATR', 7, '1996-09-18 00:00:00', '1996-10-16 00:00:00', '1996-09-24 00:00:00', 3, 1.61, 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico', 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico' 10625, 'ANATR', 3, '1997-08-08 00:00:00', '1997-09-05 00:00:00', '1997-08-14 00:00:00', 1, 43.9, 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico', 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico' 10759, 'ANATR', 3, '1997-11-28 00:00:00', '1997-12-26 00:00:00', '1997-12-12 00:00:00', 3, 11.99, 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico', 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico' 10926, 'ANATR', 4, '1998-03-04 00:00:00', '1998-04-01 00:00:00', '1998-03-11 00:00:00', 3, 39.92, 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico', 'Ana Trujillo Emparedados y helados', 'Avda. de la Constitución 2222', 'México D.F.', '', '05021', 'Mexico' 10365, 'ANTON', 3, '1996-11-27 00:00:00', '1996-12-25 00:00:00', '1996-12-02 00:00:00', 2, 22, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10507, 'ANTON', 7, '1997-04-15 00:00:00', '1997-05-13 00:00:00', '1997-04-22 00:00:00', 1, 47.45, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10535, 'ANTON', 4, '1997-05-13 00:00:00', '1997-06-10 00:00:00', '1997-05-21 00:00:00', 1, 15.64, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10573, 'ANTON', 7, '1997-06-19 00:00:00', '1997-07-17 00:00:00', '1997-06-20 00:00:00', 3, 84.84, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10677, 'ANTON', 1, '1997-09-22 00:00:00', '1997-10-20 00:00:00', '1997-09-26 00:00:00', 3, 4.03, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10682, 'ANTON', 3, '1997-09-25 00:00:00', '1997-10-23 00:00:00', '1997-10-01 00:00:00', 2, 36.13, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10856, 'ANTON', 3, '1998-01-28 00:00:00', '1998-02-25 00:00:00', '1998-02-10 00:00:00', 2, 58.43, 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico', 'Antonio Moreno Taquería', 'Mataderos 2312', 'México D.F.', '', '05023', 'Mexico' 10259, 'CENTC', 4, '1996-07-18 00:00:00', '1996-08-15 00:00:00', '1996-07-25 00:00:00', 3, 3.25, 'Centro comercial Moctezuma', 'Sierras de Granada 9993', 'México D.F.', '', '05022', 'Mexico', 'Centro comercial Moctezuma', 'Sierras de Granada 9993', 'México D.F.', '', '05022', 'Mexico' 10322, 'PERIC', 7, '1996-10-04 00:00:00', '1996-11-01 00:00:00', '1996-10-23 00:00:00', 3, 0.4, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 10354, 'PERIC', 8, '1996-11-14 00:00:00', '1996-12-12 00:00:00', '1996-11-20 00:00:00', 3, 53.8, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 10474, 'PERIC', 5, '1997-03-13 00:00:00', '1997-04-10 00:00:00', '1997-03-21 00:00:00', 2, 83.49, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 10502, 'PERIC', 2, '1997-04-10 00:00:00', '1997-05-08 00:00:00', '1997-04-29 00:00:00', 1, 69.32, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 10995, 'PERIC', 1, '1998-04-02 00:00:00', '1998-04-30 00:00:00', '1998-04-06 00:00:00', 3, 46, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 11073, 'PERIC', 2, '1998-05-05 00:00:00', '1998-06-02 00:00:00', '', 2, 24.95, 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', '', '05033', 'Mexico' 10276, 'TORTU', 8, '1996-08-08 00:00:00', '1996-08-22 00:00:00', '1996-08-14 00:00:00', 3, 13.84, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10293, 'TORTU', 1, '1996-08-29 00:00:00', '1996-09-26 00:00:00', '1996-09-11 00:00:00', 3, 21.18, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10304, 'TORTU', 1, '1996-09-12 00:00:00', '1996-10-10 00:00:00', '1996-09-17 00:00:00', 2, 63.79, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10319, 'TORTU', 7, '1996-10-02 00:00:00', '1996-10-30 00:00:00', '1996-10-11 00:00:00', 3, 64.5, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10518, 'TORTU', 4, '1997-04-25 00:00:00', '1997-05-09 00:00:00', '1997-05-05 00:00:00', 2, 218.15, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10576, 'TORTU', 3, '1997-06-23 00:00:00', '1997-07-07 00:00:00', '1997-06-30 00:00:00', 3, 18.56, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10676, 'TORTU', 2, '1997-09-22 00:00:00', '1997-10-20 00:00:00', '1997-09-29 00:00:00', 2, 2.01, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10842, 'TORTU', 1, '1998-01-20 00:00:00', '1998-02-17 00:00:00', '1998-01-29 00:00:00', 3, 54.42, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 10915, 'TORTU', 2, '1998-02-27 00:00:00', '1998-03-27 00:00:00', '1998-03-02 00:00:00', 2, 3.51, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico' 11069, 'TORTU', 1, '1998-05-04 00:00:00', '1998-06-01 00:00:00', '1998-05-06 00:00:00', 2, 15.67, 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', '', '05033', 'Mexico'

Script Procedimientos PROCEDIMIENTOS ALMACENADOS.Use Northwind; /* Procedimiento 1 */ DELIMITER $$ DROP PROCEDURE IF EXISTS `Northwind`.`Price of Products`$$ CREATE PROCEDURE `Northwind`.`Price of Products` () SELECT Products.ProductName AS TenMostExpensiveProducts, Products.UnitPrice FROM Products ORDER BY Products.UnitPrice DESC DELIMITER ; call `Ten Most Expensive Products` (); /* Procedimiento 2 */ DELIMITER $$ DROP PROCEDURE IF EXISTS `Northwind`.`Products by categories`$$ CREATE PROCEDURE `Northwind`.`Products by categories` () SELECT Categories.CategoryName, Products.ProductName, Products.QuantityPerUnit, Products.UnitsInStock, Products.Discontinued FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID WHERE Products.Discontinued 1 DELIMITER ; call `Products by categories` (); /* Procedimiento 3 */ DELIMITER $$ DROP PROCEDURE IF EXISTS `Northwind`.`Quarterly Orders`$$ CREATE PROCEDURE `Northwind`.`Quarterly Orders` () SELECT DISTINCT Customers.CustomerID, Customers.CompanyName, Customers.City, Customers.Country FROM Customers RIGHT JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Orders.OrderDate BETWEEN '19970101' And '19971231' DELIMITER ; call `Quarterly Orders` (); /* Procedimiento 4 */ DELIMITER $$ DROP PROCEDURE IF EXISTS `Northwind`.`Customer and Suppliers`$$ CREATE PROCEDURE `Northwind`.`Customer and Suppliers` () SELECT City, CompanyName, ContactName, 'Customers' AS Relationship FROM Customers UNION SELECT City, CompanyName, ContactName, 'Suppliers'

FROM Suppliers DELIMITER ; call `Customer and Suppliers` (); /* Procedimiento 5 */ DELIMITER $$ DROP PROCEDURE IF EXISTS `Northwind`.`list of products`$$ CREATE PROCEDURE `Northwind`.`list of products` () SELECT Products.*, Categories.CategoryName FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID WHERE (((Products.Discontinued)=0)) DELIMITER ; call `list of products` ();

Script Updates y Deletes use northwind; UPDATES./*Actualizar el precio unitario (UnitPrice) de los productos cuyo SupplierID es 3 en la tabla PRODUCTS al doble*/ Antes del Update: SELECT * FROM products p order by SupplierID

Después del Update: UPDATE products p SET UnitPrice = UnitPrice *2 WHERE SupplierID = 3 Order by SupplierID

/*Actualizar el código postal a 5022 para las Regiones SP de la tabla CUSTOMERS*/ Antes del Update: SELECT * FROM customers c order by Region

Después del Update: UPDATE customers c SET PostalCode = 5022 WHERE Region = 'SP' Order by Region

/*En la tabla EMPLOYEES actualizar la ciudad de Fuller Andrew a London*/ Antes del Update: SELECT * FROM employees e

Después del Update: UPDATE employees e SET City = 'London' WHERE LastName = 'Fuller' and FirstName = 'Andrew'

/*Actualizar la descripción de la categoria 'Dairy Products' a 'Cheeses and Milk' en la tabla CATEGORIES*/ Antes del Update: SELECT * FROM categories c

Después del Update: UPDATE categories c SET Description = 'Cheeses and Milk' WHERE CategoryName = 'Dairy Products'

/*Actualizar el número de unidades en stock (UnitsInStock) a 20 del producto Tofu en la tabla PRODUCTS*/ Antes del Update: SELECT * FROM products p

Después del Update: UPDATE products p SET UnitsInStock = 20 WHERE ProductName = 'Tofu'

DELETE./*Borrar de la tabla PRODUCTS el producto 'Chai'*/ Antes del Delete: SELECT * FROM products p

Después del Delete: DELETE FROM products WHERE ProductName = 'Chai'

/*Borrar al empleado ‘King Robert’ de la tabla EMPLOYEES*/ Antes del Delete: SELECT * FROM employees e

Después del Delete: DELETE FROM employees WHERE LastName = 'King' and FirstName = 'Robert'

/*Borrar los registro de la tabla CUSTOMERS cuyo país sea Argentina*/ Antes del Delete: SELECT * FROM customers c ORDER BY country

Después del Delete: DELETE FROM customers WHERE country = 'Argentina'

/*Borrar los registros de la tabla ORDERS cuyo EmployeeID es 3*/ Antes del Delete: SELECT * FROM orders o ORDER BY EmployeeID

Después del Delete: DELETE FROM orders WHERE EmployeeID = 3

/*Borrar los registros de la tabla SUPPLIERS de la compania ‘Tokyo Traders’*/ Antes del Delete: SELECT * FROM suppliers s

Después del Delete: DELETE FROM suppliers WHERE CompanyName = 'Tokyo Traders'