Difference between revisions of "Insert Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Changes keyword ambiguity)
Line 4: Line 4:
  
 
<SyntaxHighlight lang=sql>
 
<SyntaxHighlight lang=sql>
  INSERT INTO table
+
  INSERT INTO table_name
 
  (field1, field2, field3)
 
  (field1, field2, field3)
 
  VALUES
 
  VALUES
Line 12: Line 12:
 
==Alternative Method==
 
==Alternative Method==
 
<SyntaxHighlight lang=sql>
 
<SyntaxHighlight lang=sql>
  INSERT INTO table
+
  INSERT INTO table_name
 
  VALUES
 
  VALUES
 
  (value1, value2, value3);
 
  (value1, value2, value3);
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 19:46, 23 October 2017

INSERT adds rows to an existing table, there can be different syntax depending on specific version of SQL etc. For exam questions use one of the methods below. Also remember the values inserted should match the data types of the table fields.

Best Method

 INSERT INTO table_name
 (field1, field2, field3)
 VALUES
 (value1, value2, value3);

Alternative Method

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