No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Convierte tus certificados en títulos universitarios en USA

Antes: $249

Currency
$209

Paga en 4 cuotas sin intereses

Paga en 4 cuotas sin intereses
Suscríbete

Termina en:

18 Días
14 Hrs
45 Min
57 Seg

Playground: INSERT, UPDATE y DELETE en SQL

18/34

Aportes 32

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

Me encanta que hayan incluido los playgrounds. Son sumamente dinamicos y te insita a practicar lo estudiado,

Mi solucion.

INSERT INTO lines (id, name, color)
VALUES (7, 'Nueva Linea 7', 'Naranja');

UPDATE lines
SET name = 'Linea 1'
WHERE id = 1;

DELETE FROM lines
WHERE id = 5;

SELECT * FROM lines;
`INSERT INTO lines (id, name, color) VALUES (7, "Nueva Linea 7", "Naranja");` `SELECT * FROM lines;` `UPDATE lines SET name="Linea 1" WHERE id=1;` `SELECT * FROM lines;` `DELETE FROM lines WHERE id=5;` `SELECT * FROM lines;`
Aquí mi solución ![](https://static.platzi.com/media/user_upload/image-e0f0a091-3269-4fe1-be70-13d20d141a57.jpg)
```js -- Escribe tu código aquí 👇 SELECT * FROM lines; INSERT INTO lines (id,name,color) VALUES ("7","Nueva Linea 7","Naranja"); UPDATE lines SET name="Linea 1" where id=1; delete from lines where id=5; ```-- Escribe tu código aquí 👇SELECT \* FROM lines;INSERT INTO lines (id,name,color) VALUES ("7","Nueva Linea 7","Naranja"); UPDATE  lines SET name="Linea 1"where id=1; delete from lines where id=5;
![](https://static.platzi.com/media/user_upload/imagen-b5f4c1ab-2468-42da-8c83-87b4375d0eba.jpg)

Hola , les comparto mi solución:

INSERT INTO lines (id, name, color) VALUES
(“7”, “Nueva Linea 7”, “Naranja”);

UPDATE lines
SET name = "Linea 1"
WHERE id = 1;

DELETE FROM lines
WHERE id = 5;

– Escribe tu código aquí 👇
SELECT * FROM lines;

Mi respuesta:

INSERT INTO lines (id, name, color) VALUES (7,'Nueva Linea 7', 'Naranja');
UPDATE lines SET name = 'Linea 1' WHERE id = 1;
DELETE FROM lines WHERE id = 5;
SELECT * FROM lines;
Spoiler . . . . . . . . . . . . . . . ![](https://static.platzi.com/media/user_upload/image-d9f1e58f-f01e-48c9-9660-92e540ec140a.jpg)
```js SELECT * FROM lines; INSERT INTO `lines` (id,name,color) VALUES (7, "Nueva Linea 7", "Naranja"); UPDATE `lines` SET name = "Linea 1" WHERE id = 1; DELETE FROM `lines` WHERE id=5; SELECT * FROM `lines`; ```

Les comparto mi solución y aprovecho para hacer una pregunta,

  1. ¿El SET como se interpreta en el ejercicio de actualización ?
INSERT INTO 
`lines` (
  `id`, `name`, `color`
  ) 
VALUES 
(7, "Nueva Linea 7", "Naranja");

UPDATE `lines`
SET `name` = "Linea 1"
WHERE `id` = 1;  

DELETE FROM `lines`
WHERE `id` = 5;
\-- Escribe tu código aquí 👇SELECT \* FROM lines; \--crear nuevo registro de lineaINSERT INTO `lines` (id,name,color) VALUES(7,"Nueva Linea 7", "Naranja"); \--Actualizar el registro de la linea 1UPDATE `lines` SET  name = 'Linea 1'WHERE id = 1; \--Eliminar el registro de la linea de id 5DELETE FROM `lines`WHERE id = 5; SELECT \* FROM lines;
SELECT \* FROM lines; INSERT INTO lines (id, name, color)VALUES (7, 'Nueva Linea 7', 'Naranja'); UPDATE linesSET name = 'Linea 1'WHERE id = 1; DELETE FROM linesWHERE id = 5;
Solución al problema: ```js --Query table SELECT * FROM lines; --Resolving problem one (insert data) INSERT INTO lines (id, name, color) VALUES (7, 'Nueva Linea 7','Naranja'); --Resolving problem two (update data) UPDATE lines SET name = 'Linea 1' WHERE id = 1; --Resolving problem three (delete data) DELETE FROM lines WHERE id = 5; --Query table (test) SELECT * FROM lines; ```
\-- Escribe tu código aquí 👇 SELECT \* FROM lines;INSERT INTO `lines` (id, name, color) VALUES(7,"Nueva Linea 7" ,"Naranja"); SELECT \* FROM lines; UPDATE `lines`SET name="Linea 1"WHERE id=1; SELECT \* FROM lines; DELETE FROM `lines`WHERE id=5; SELECT \* FROM lines;

Recuerden comentar con puntos para que no se vea inmediatamente la respuesta, puesto que espoilea a los que vienen a hacer el ejercicio
.
.
.
.
.

INSERT INTO `lines` (id, name, color) VALUES
(7, "Nueva Linea 7", "Naranja");

UPDATE `lines`
SET name = "Linea 1"
WHERE id = 1;

DELETE FROM `lines`
WHERE id = 5;

SELECT * FROM lines;
insert into `lines`(id,name,color)
values(7,"Linea A-20","Rosa");

como sugerencia debieron codificar el id de la tabla de prueba con el constraint AUTO INCREMENT como en las clases
perdi un par de intentos porque estaba omitiendo el id pensando que no era necesario

Excelente práctica!

.
.
.
.
.
.
.
.
.
.
.
.
.

-- INSERT
INSERT INTO lines (id, name, color)
VALUES (7, 'Nueva Linea 7', 'Naranja');

-- UPDATE
UPDATE lines
SET name = 'Linea 1'
WHERE id = 1;

-- DELETE
DELETE FROM lines
WHERE id = 5;

SELECT * FROM lines;

Facil

-- Escribe tu código aquí 👇
INSERT INTO lines(id,name, color)
VALUES(7,'Nueva Linea 7','Naranja');

UPDATE `lines`
SET name='Linea 1' WHERE id=1;

DELETE FROM `Lines`
WHERE id = 5;
SELECT * FROM lines;
SELECT * FROM lines;

INSERT INTO `lines` (id,name,color) VALUES
(7,'Nueva Linea 7', 'Naranja');

UPDATE `lines`
SET name = 'Linea 1'
WHERE id = 1;

DELETE FROM `lines`
WHERE id = 5;

Si se pudo:

-- Escribe tu código aquí 👇
INSERT INTO lines (id, name, color) VALUES
(7, "Nueva Linea 7", "Naranja");

UPDATE `lines`
SET name = "Linea 1"
WHERE id = 1;

DELETE FROM `lines`
WHERE id = 5;

-- SELECT * FROM lines;
-- Escribe tu código aquí 👇
SELECT * FROM lines;

INSERT INTO `lines` (id, name, color) VALUES
(7, "Nueva Linea 7", "Naranja");

UPDATE `lines`
SET name = "Linea 1"
WHERE id = 1;

DELETE FROM `lines`
WHERE id = 5;

– Escribe tu código aquí 👇

<SELECT * FROM lines;
INSERT INTO lines (id,name,color)
VALUES (7,"Nueva Linea 7","Naranja")
;
UPDATE lines SET name = "Linea1"
WHERE id in (1);

DELETE FROM lines WHERE id in (5);> 

Esta es mi solucion

insert into lines (name, color) values ('Nueva Linea 7','naranja');
update lines set name ='Linea 1' where id = 1;
delete from lines where id = 5;

pero el editor me arroja un error.

(SQL error) NOT NULL constraint failed: lines.id

y entiendo que es porque me esta pidiendo que incorpore el ID en el Insert de la siguiente forma

insert into lines (id, name, color) values (7,'Nueva Linea 7','naranja');

pero si el ID es un autoincremental, no encuentro que sea buena practica el “Manipular” el campo, ya que queda a mi responsabilidad que el ID se el numero que sigue, pero que pasa si al manipular el valor, me “salto” varios numeros? o reutilizo uno que elimine?, desde mi punto de vista los valores autoincrementales NO SE MANIPULAN.

Mi solucion:

-- Escribe tu código aquí 👇
SELECT * FROM lines;

INSERT INTO lines (id,name,color) VALUES(7,"Nueva Linea 7","Naranja");


UPDATE lines
SET name="Linea 1"
WHERE id=1;

DELETE FROM lines
WHERE id=5;

¡Me encantan estos ejercicios!

INSERT INTO lines (id,name,color)
VALUES
  ('7','Nueva Linea 7','Naranja');

UPDATE lines
SET name = 'Linea 1' WHERE id = 1;

DELETE FROM lines
WHERE id = 5;

SELECT * FROM lines;

😀

– Escribe tu código aquí 👇
SELECT * FROM lines;

INSERT INTO lines (id, name, color) VALUES
( 7, “Nueva Linea 7”, “Naranja”);

SELECT * FROM lines;

UPDATE lines
SET name = "Linea 1"
WHERE id = 1;

SELECT * FROM lines;

DELETE FROM lines
WHERE id = 5;

SELECT * FROM lines;

Mi solución:

-- INSERTAR NUEVO REGISTRO
INSERT INTO `lines` (id, name, color) VALUES
(7, "Nueva Linea 7", "Naranja");

-- ACTUALIZAR EL REGISTRO DE LA LÍNEA CON ID 1
UPDATE `lines`
SET name = "Linea 1"
WHERE id = 1;

-- ELIMINAR EL REGISTRO DE LA LÍNEA CON ID 5
DELETE FROM `lines` WHERE id = 5;
undefined