Tutorial SQL - SQL INSERT INTO
Wed Apr 11, 2018 8:53 am
SQL INSERT INTO
Inserting data into a table is done using the INSERT INTO command. This command allows the choice to include a single line at the existing base or multiple lines at once.
Insert one row at a time
To insert data into a database, there are 2 main syntaxes:
Insert a line indicating the information for each existing column (respecting the order)
Insert a line specifying the columns you wish to complete. It is possible to insert a line specifying only a part of the columns
Insert a row specifying all the columns
The syntax for filling a line with this method is as follows:
It is possible to add multiple rows to an array with a single query. To do this, use the following syntax:
Such an example on an empty table will create the following table:
[You must be registered and logged in to see this image.]
Inserting data into a table is done using the INSERT INTO command. This command allows the choice to include a single line at the existing base or multiple lines at once.
Insert one row at a time
To insert data into a database, there are 2 main syntaxes:
Insert a line indicating the information for each existing column (respecting the order)
Insert a line specifying the columns you wish to complete. It is possible to insert a line specifying only a part of the columns
Insert a row specifying all the columns
The syntax for filling a line with this method is as follows:
- Code:
INSERT INTO table VALUES ('value 1', 'value 2', ...)
It is possible to add multiple rows to an array with a single query. To do this, use the following syntax:
- Code:
INSERT INTO client (first name, last name, city, age)
VALUES
('Rebecca', 'Armand', 'Saint-Didier-des-Bois', 24),
(' Aimée ',' Hebert ',' Marigny-le-Châtel ', 36),
(' Marielle ',' Ribeiro ',' Maillères', 27),
('Hilaire', 'Savary', 'Conie-Molitard', 58);
Such an example on an empty table will create the following table:
[You must be registered and logged in to see this image.]
Permissions in this forum:
You cannot reply to topics in this forum