INSERT


INSERT

It is used to insert rows in a table.
Es usado para insertar renglones a una tabla.

Tip
When INSERT is used, any constraints placed upon a table are checked preventing the insertion of invalid data.
Cuando el comando INSERT se usa, todas las restricciones existentes en la tabla son verificadas previniendo la inserción de datos inválidos.

insert1

insert2

Problem 1
ford > (a) Modify the ford.sql file so that the script creates the table best_store with the columns: name (primary key), state and sales. (b) Write an SQL command to copy all stores that have excellent sales to the best_store table (Hint: combine SELECT with INSERT). This type of SQL commands can be used during database consolidation or backup.
(a) Modificar el archivo ford.sql para que el script cree la tabla best_store con las columnas: name (primary key), state and sales. (b) Escribir un comando SQL para copiar todas las tiendas que tienen excelentes ventas a esta nueva tabla (Sugerencia: combine SELECT con INSERT). Este tipo de comandos SQL puede ser usado durante consolidación de bases de datos o respaldo.

insert_select

SQL
SELECT name, state, sales
FROM best_store;

ford_best

Tip
A database is stored in a file in the server's hard drive. In the case of Microsoft SQL Server, each database is stored in a file with extension *.mdf. Thus, if there is a database called circuit_city created by the execution of the file circuit_city.sql, there must exist a file circuit_city.mdf where the database is stored. These files get stored in: C:\Program Files\Microsoft SQL Server\*\MSSQL\DATA.
Una base de datos se almacena en un archivo en el disco duro del servidor. En el caso de Microsoft SQL Server, cada base de datos esta almacenada en un archivo con extensión *.mdf. Así, si hay una base de datos llamada circuit_city creada al ejecutar el archivo circuit_city.sql, debe existir un archivo circuit_city.mdf donde se almacena esta base de datos. Estos archivos se almacenan en: C:\Program Files\Microsoft SQL Server\*\MSSQL\DATA.

Tip
You should always try to keep the size of your database as small as possible by storing only data that is required for the specific application. If the database is compact, it will be work efficiently and it will be very fast to create backups. Thus, never store images, videos, etc., in a database at least it is extremely necessary. Instead store the location of these files in a column of a table. For instance, it is possible locate images, videos, etc., in a Web Server, a FTP Server, a File Server or a Cloud Service such as: Drobbox, Google Drive, One Drive, etc.
Siempre trate de mantener su base de datos lo más compacta posible almacenando en esta solamente los datos que se requeridos para la aplicación deseada. Si la base de datos es compacta, funcionará eficientemente y será muy rápido crear respaldos de esta. Así, nunca guarde imágenes, videos, etc., en la base de datos a menos que sea extremadamente necesario hacerlo. En su lugar guarde la ubicación de estos archivos en una columna de una tabla. Por ejemplo, es posible colocar imágenes, videos, etc., en un Servidor Web, en un Servidor de FTP, en un Servidor de Archivos o incluso en servicios en la Nube como: Dropbox, Google Drive, One Drive, etc.

Apostrophe

To insert a text string that has an apostrophe in SQL, you should use two apostrophes, the first apostrophe is to escape the second one as shown below.
Para insertar un texto que tiene un apostrofe en SQL, usted debe usar dos apostrofes, el primero es para escapar el segundo como se muestra debajo.

Example.sql
INSERT INTO country(NAME) VALUES ('Cote d''Ivoire');


© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home