Adding Data to a Table

Adding Data to a Table To insert the data in a Table related to the courses use the SQL INSERT statement.

INSERT INTO table VALUES (value1, value2, …);

This inserts values into each of the fields of the table, in the order that the fields were created.

Alternatively, you can create a row with only some fields populated. The remaining fields will contain NULL (if allowed), or in the case of special fields such as an AUTO_INCREMENT field, the field value will be calculated automatically. To insert a row of partial data, use:

INSERT INTO table ( field1 , field2 , … ) VALUES ( value1 , value2 , … );

So you can add three rows to the Course table by inserting data into just the Course name and Duration fields (the id field will be filled automatically):

mysql > INSERT INTO Course ( Course name, Duration ) VALUES ( ‘C’, ‘3’ );
Query OK, 1 row affected
mysql > INSERT INTO fruit (Course name, Duration) VALUES ( ‘ASP.NET’, ‘6’ );
Query OK, 1 row affected
mysql > INSERT INTO fruit (Course name, Duration) VALUES ( ‘MySql’, ‘8’ );
Query OK, 1 row affected