login

Inserting Data into a Table

Once table created, It is empty and contains no data. In order to insert data into a database table you use INSERT statement. With INSERT statement you can insert one or more rows per time into a table. Here is the syntax of INSERT statement:

INSERT INTO table_name(col1,col2,..)
VALUES(val1,val2,...)

INSERT INTO table_name(col1,col2,..) VALUES
(val1,val2,...)
(val1,val2,...)
(val1,val2,...)
...

For example, you can insert data into stock table by using the following query:

INSERT INTO stock(item_id,quantity)
VALUES(3,20)

You can insert more than 1 record per time like following:

INSERT INTO stock(item_id,quantity) VALUES
(4,16) 
(9,12)

If all the columns of the table have default values so you can use default values to insert into the table by this query:

INSERT INTO table_name DEFAULT VALUES