Inserting rows · Insertar filas
Adding rows with INSERT
INSERT adds a new row to a table. List the columns, then a matching set of VALUES:
Text goes in single quotes; numbers do not. The values must line up with the columns, in the same order.
Agregar filas con INSERT
INSERT añade una nueva fila a una tabla. Se listan las columnas, seguidas de un conjunto coincidente de VALUES:
INSERT INTO product (code, title, price, in_stock)
VALUES ('P04', 'Ruler', 1.20, 75);
El texto se coloca entre comillas simples; los números no. Los valores deben alinearse con las columnas, en el mismo orden.
Seeing the effect
INSERT changes the data but returns no rows itself, so Run just reports how many rows changed. To see the new row, run a SELECT afterwards.
The checker does this for you: it runs your INSERT, then reads the table back to confirm your row is there.
Ver el efecto
INSERT modifica los datos pero no devuelve filas por sí mismo, por lo que Run solo informa cuántas filas cambiaron. Para ver la nueva fila, ejecute un SELECT después.
El verificador hace esto por usted: ejecuta su INSERT, luego lee la tabla de nuevo para confirmar que su fila está allí.
Common mistakes
- The values must line up with the columns in order and type.
- Quote text values with single quotes.
Errores comunes
- Los valores deben alinearse con las columnas en orden y tipo.
- Encierre los valores de texto entre comillas simples.
Add a new product to the product table: code 'P04', title 'Ruler', price 1.20, in_stock 75. · Agregue un nuevo producto a la tabla product: código 'P04', título 'Ruler', precio 1.20, en stock 75.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
Add a new customer to the customer table: id 5, name 'Eve', city 'York'. List the columns you are filling, then give the matching VALUES. · Agregue un nuevo cliente a la tabla customer: id 5, name 'Eve', city 'York'. Enumere las columnas que está rellenando, y luego proporcione los VALUES correspondientes.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.