joseleonweb

Untitled

May 10th, 2021
862
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE DATABASE DatosCoches;
  2. USE DatosCoches;
  3. CREATE TABLE PROPIETARIOS (DNI VARCHAR(10),
  4. Nombre VARCHAR(40),
  5. Edad INTEGER,
  6. UNIQUE KEY(DNI));
  7. CREATE TABLE COCHES (Matricula VARCHAR(10) ,
  8.  Marca VARCHAR(20),
  9.  Precio INTEGER,
  10.  DNI VARCHAR (10),
  11. UNIQUE KEY(Matricula),
  12.  FOREIGN KEY (DNI) References Propietarios(DNI));
  13. INSERT INTO Propietarios values('1A','Pepe',30);
  14. INSERT INTO Propietarios values('1B','Ana',40);
  15. INSERT INTO Propietarios values('1C','Maria',50);
  16. INSERT INTO Coches values('MA-1111','Opel',1000,'1A');
  17. INSERT INTO Coches values('MA-2222','Renault',2000,'1A');
  18. INSERT INTO Coches values('BA-3333', 'Seat', 3000,'1B');
  19. Describe Propietarios;
  20. Describe Coches;
  21. Select * from Propietarios;
  22. Select * from Coches;
  23. Select * from Propietarios, Coches
  24. where Propietarios.DNI=Coches.DNI;
RAW Paste Data