Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INSERT vs INSERT INTO

I have been working with T-SQL in MS SQL for some time now and somehow whenever I have to insert data into a table I tend to use syntax:

INSERT INTO myTable <something here> 

I understand that keyword INTO is optional here and I do not have to use it but somehow it grew into habit in my case.

My question is:

  • Are there any implications of using INSERT syntax versus INSERT INTO?
  • Which one complies fully with the standard?
  • Are they both valid in other implementations of SQL standard?
like image 324
kristof Avatar asked Oct 24 '08 15:10

kristof


People also ask

What is difference between insert and insert into?

If you are using Insert or Insert into both will insert the data in Table. However Insert into is basically used to fatch the data from another table using select command and insert into table where you want to insert the data.

What is the use of insert into?

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

What is the difference between insert into and select into?

INSERT INTO SELECT vs SELECT INTO: Both the statements could be used to copy data from one table to another. But INSERT INTO SELECT could be used only if the target table exists whereas SELECT INTO statement could be used even if the target table doesn't exist as it creates the target table if it doesn't exist.

What does insert into in SQL mean?

The INSERT INTO Statement in SQL allows you to insert one or more rows into an existing table, either from another existing table, or by specifying the VALUES you want to insert.


1 Answers

INSERT INTO is the standard. Even though INTO is optional in most implementations, it's required in a few, so it's a good idea to include it to ensure that your code is portable.

You can find links to several versions of the SQL standard here. I found an HTML version of an older standard here.

like image 87
Bill the Lizard Avatar answered Sep 19 '22 10:09

Bill the Lizard