ComenzarEmpieza gratis

Inserting data to person and order history

Next, you will insert data into the two newly generated tables, Person and History. Enter the following orders:

  1. Andrew Anderson bought an iPhone XS for 1000
  2. Sam Smith bought a MacBook Pro for 1800

When inserting the customers and their orders into the tables make sure that:

  • the primary key is unique
  • you use the correct foreign key

Este ejercicio forma parte del curso

Hierarchical and Recursive Queries in SQL Server

Ver curso

Instrucciones del ejercicio

  • Insert new data for the person with ID=1, Andrew Anderson.
  • Insert new data for the second person with ID=2, Sam Smith.
  • Insert a new order for Andrew Anderson: iPhone XS for 1000.
  • Insert a new order for Sam Smith: MacBook Pro for 1800.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

-- Insert new data into the table Person
___ INTO ___ 
___ (1,___,'Anderson','Union Ave 10','New York','1986-12-30');
___ ___ Person 
VALUES (___,___,___,'Flushing Ave 342','New York','1986-12-30');

-- Insert new data into the table History
___ ___ History 
___ (1,'iPhone XS',___,___);
INSERT ___ ___ 
___ (___,'MacBook Pro',1800,___);

SELECT * 
FROM History;
Editar y ejecutar código