Inserting Data Into Table with Values or another query

SQream DB supports both insertion of static literal values, or from a query.


INSERT INTO table [ ( column [, ...] ) ]
    { VALUES ( expression  [, ...] ) | query }



  • INSERT INTO customers VALUES (1,'John Smith','Male',100);
  • INSERT INTO customers (SELECT id,name,gender,code FROM old_customers);

Enclosing literals:

Strings and Date/DateTime literals should be enclosed with single apostrophes.

For example:

VALUES ('hey','1997-01-01 15:00:00.000')

Possible issues:

  1. If your literal already contains an apostrophe, escape it by using a second apostrophe.
    For example:

    INSERT INTO tablename VALUES('What''s new?')
  2. Make sure to match the column types to the literal types in the VALUES clause
  • 18
  • 27-Jul-2015