Evaluacion Pratica Mysql Sandra Uribe
Evaluacion Pratica Mysql Sandra Uribe
Evaluacion Pratica Mysql Sandra Uribe
SOGAMOSO-BOYACA
2020
DIAGRAMA ENTIDAD RELACIÒN
CLIENTE
COCHE
documento INT
matricula INT
nombre VARCHAR (45)
marca VARCHAR (20)
----------------------------------- dirección VARCHAR (45)
modelo INT
ciudad (20)
color VARCHAR (15)
teléfono (20)
precio DECIMAL
códigoInterno INT (AU)
cliente_documento INT
REVISION
código INT
coche_matricula INT
Evaluación Práctica de Consultas de Bases de Datos
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`CLIENTE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS CLIENTE (
'documento' INT NOT NULL,
'nombre' VARCHAR(45) NOT NULL,
'direccion' VARCHAR(45) NOT NULL,
-- -----------------------------------------------------
-- Table `mydb`.`COCHE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS COCHE (
'matricula` INT NOT NULL,
'marca` VARCHAR(45) NOT NULL,
'modelo' INT NOT NULL,
'color' VARCHAR(45) NOT NULL,
'precio' DECIMAL NOT NULL,
'CLIENTE_documento' INT NOT NULL,
PRIMARY KEY (`matricula`),
INDEX `fk_COCHE_CLIENTE_idx` (`CLIENTE_documento` ASC) ,
CONSTRAINT `fk_COCHE_CLIENTE`
FOREIGN KEY (`CLIENTE_documento`)
REFERENCES `mydb`.`CLIENTE` (`documento`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`REVISION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS REVISION (
'codigo' INT NOT NULL,
'tipoRevision' VARCHAR(50) NOT NULL,
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO
use mydb;
Insert into cliente values (1, 'Pedro', 'Carrera 12 N 1-21', 'Sogamoso', 332423, 12 );
Insert into cliente values (2, 'María', 'Carrera 13 N 2-22', 'Cali', 243556, 34 );
Insert into cliente values (3, 'Carlos', 'Carrera 14 N 3-23', 'Yopal', 234664, 35 );
Insert into cliente values (4, 'Samanta', 'Carrera 15 N 4-24', 'Bogotá', 323424, 45 );
Insert into cliente values (5, 'Camilo', 'Carrera 16 N 5-25', 'Villavicencio', 243673, 32 );
Insert into cliente values (6, 'Raúl', 'Carrera 17 N 6-26', 'Manizales', 233890,43 );
Insert into cliente values (7, 'Andrés', 'Carrera 18 N 7-27', 'Cajamarca', 24858, 49 );
Insert into cliente values (8, 'Oscar', 'Carrera 19 N 8-28', 'Tunja', 249000, 32 );
Insert into cliente values (9, 'Jhon', 'Carrera 20 N 9-29', 'Pereira', 2457809, 31 );
Insert into cliente values (10,'Marina', 'Carrera 21 N 10-30', 'San Andrés' 267890, 43 );
Insert into coche values (1, 'Toyota', 1999, 'Azul', 80000000, 1);
Insert into coche values (2, 'Renault', 1900, 'Rojo', 90000000, 2);
Insert into coche values (3, 'Sandero', 2000, 'Gris', 100000000, 3);
Insert into coche values (4, 'Mitsubishi', 2001, 'Negro', 190000000, 4 );
Insert into coche values (5, 'Mazda', 2002, 'Violeta', 20000000, 5);
Insert into coche values (6, 'Clio', 1997, 'Amarillo', 30000000, 6 );
Insert into coche values (7, 'Ford', 2004, 'Naranja', 60000000, 7);
Insert into coche values (8, 'Sprint', 2010, 'Cafe', 70000000, 8);
Insert into coche values (9, 'Spark', 2008, 'Rosado', 40000000, 9);
Insert into coche values (10, 'Aveo Emotion ', 2019, 'Verde', 50.000.000, 10 );
CONSULTAS
3. /*Mostrar los datos de los clientes cuyo nombre inicie con la letra c */
Select * from cliente where nombre = `C%`;
Select *from cliente where nombre like `nombre`; order by documento desc;
PROCEDIMIENTOS ALMACENADOS