• The INSERT INTO statement is used to insert new records in a table.


    It is possible to write the INSERT INTO statement in two forms.

    The first form does not specify the column names where the data will be inserted, only their values:

    INSERT INTO table_name
    VALUES (value1,value2,value3,...);

    The second form specifies both the column names and the values to be inserted:

    INSERT INTO table_name (column1,column2,column3,...)
    VALUES (value1,value2,value3,...);


    eg.

    CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
    87Wartian HerkkuPirkko KoskitaloTorikatu 38Oulu90110Finland
    88Wellington ImportadoraPaula ParenteRua do Mercado, 12Resende08737-363Brazil
    89White Clover MarketsKarl Jablonski305 - 14th Ave. S. Suite 3BSeattle98128USA
    90

    Wilman KalaMatti KarttunenKeskuskatu 45Helsinki21240Finland
    91

    WolskiZbyszekul. Filtrowa 68Walla01-012Poland


    INSERT INTO:

    INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
    VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');

    The selection from the "Customers" table will now look like this:

    CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
    87Wartian HerkkuPirkko KoskitaloTorikatu 38Oulu90110Finland
    88Wellington ImportadoraPaula ParenteRua do Mercado, 12Resende08737-363Brazil
    89White Clover MarketsKarl Jablonski305 - 14th Ave. S. Suite 3BSeattle98128USA
    90

    Wilman KalaMatti KarttunenKeskuskatu 45Helsinki21240Finland
    91

    WolskiZbyszekul. Filtrowa 68Walla01-012Poland
    92CardinalTom B. ErichsenSkagen 21Stavanger4006Norway

    Insert Data Only in Specified Columns:

    It is also possible to only insert data in specific columns.
    The following SQL statement will insert a new row, but only insert data in the "CustomerName", "City", and "Country" columns (and the CustomerID field will of course also be updated automatically):

    INSERT INTO Customers (CustomerName, City, Country)
    VALUES ('Cardinal', 'Stavanger', 'Norway');


    CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
    87Wartian HerkkuPirkko KoskitaloTorikatu 38Oulu90110Finland
    88Wellington ImportadoraPaula ParenteRua do Mercado, 12Resende08737-363Brazil
    89White Clover MarketsKarl Jablonski305 - 14th Ave. S. Suite 3BSeattle98128USA
    90

    Wilman KalaMatti KarttunenKeskuskatu 45Helsinki21240Finland
    91

    WolskiZbyszekul. Filtrowa 68Walla01-012Poland
    92Cardinalnullnull StavangernullNorway


  • Sorry No animation Yet.

    We are Working On this


OUR PARTNERS&Website builderuCoz