tutorial net
*********WOOOOOOW *********
We're happy to see you're enjoying our races (already 5 pages viewed today)! You can keep checking out by becoming a member of the tutorial net community. It's free!
You will also be able to keep track of your race progress, practice on exercises, and chat with other members.

Share
Go down
Admin
Posts : 207
Join date : 2017-11-11
Age : 28
Location : algeria
View user profilehttp://www.tutorial-net.com

Tutorial SQL - SQL INSERT INTO

on 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:

Code:
INSERT INTO table VALUES ('value 1', 'value 2', ...)
Insert multiple rows at a time

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);
Note: when the field to be filled is of type VARCHAR or TEXT you must indicate the text in single quotation mark. On the other hand, when the column is a numeric such as INT or BIGINT there is no need to use a quotation mark, it is enough just to indicate the number.

Such an example on an empty table will create the following table:
[You must be registered and logged in to see this image.]
Back to top
Permissions in this forum:
You cannot reply to topics in this forum