Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
INSERT Command
Previous  Top  Next



An INSERT statement is used to add one or more new records to a table. This is how you populate a table. Each record is subdivided into fields and each field contains a single piece of data.

Syntax

INSERT INTO [ MEMORY ] ["database_file_name".] table_name [ PASSWORD database_password ] [ ( column_name [, ...] ) ] { VALUES ( expression [, ...] ) | query }

Description

INSERT allows one to insert new rows into a table. One can insert a single row at a time or several rows as a result of a query.
The columns in the target list may be listed in any order. Each column not present in the target list will be inserted using a default value, either its declared default value or null.
If the expression for each column is not of the correct data type, automatic type conversion will be attempted.

MEMORY
If MEMORY keyword is specified before the table_name then an in-memory table is referenced, not a disk one.  

database_file_name
The database file name which must be specified only if INSERT operates with the tables from external database.  

table_name
The name of an existing table.  

PASSWORD database_password
The password to open encrypted external database specified by database_file_name.  

column _name
The name of a column in table.  

expression
An expression or value to assign to column.  
 
query
A query (SELECT statement) that supplies the rows to be inserted. Refer to the SELECT command for a description of the syntax.  

Examples:

INSERT INTO developers (code, name) VALUES (5, 'Bob');  
INSERT INTO new_developers (SELECT * FROM developers WHERE code > 5)  
INSERT INTO developers (code, name) VALUES (5, 'Bob'), (6,'John');  
 
Note:See MimeToBin function for details on how to insert binary data.  

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024