As in other DBMS, INSERT statement is used in DB2 to perform inserting records in tables, then check the syntax that is used.

INSERT INTO [Table] VALUES ([Values])

INSERT INTO [Table] ([Columns]) VALUES ([Values])

Both syntaxes work properly, the detail is that in the first example shown is necessary to inform a series of data that is compatible with the creation order of the columns in the database.

As a practical example we will use two examples inserting records in a table that stores sales of online store.

INSERT INTO Sales VALUES (‘John’, 3000)

INSERT INTO Sales (Seller, Total) VALUES (‘John’, 3000)

You still have the option of performing an insert from a query in the database as shown in the example below.

INSERT INTO Sales (Seller, Total)

SELECT Seller, Total

FROM old_Sales

In the example given, an old table sales being migrated to the new table and all records will be restored through the command shown.

ibm-db2

DB2 has become very popular in web development environments, so it is important that you understand its operation. Discover now the advantages of working with DB2 on PHP projects, visit our official site.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.