SQL INSERT INTO



  SQL > Table Manipulation > Insert Into Statement

In the previous sections, we have seen how to query information from tables. But how do these rows of data get into these tables in the first place? This is what this and the next section, covering the INSERT INTO statement, as well as the following section, covering tbe UPDATE statement, are about.

In SQL, there are basically two ways to INSERT data into a table: One is to insert it one row at a time, the other is to insert multiple rows at a time. In this section, we'll take a look at the first case:

The syntax for inserting data into a table one row at a time is as follows:

INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

Assuming that we have a table that has the following structure,

Table Store_Information
Column NameData Type
store_namechar(50)
Salesfloat
Datedatetime

and now we wish to insert one additional row into the table representing the sales data for Los Angeles on January 10, 1999. On that day, this store had $900 in sales. We will hence use the following SQL script:

INSERT INTO Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999');

Next: SQL INSERT INTO SELECT




Copyright © 2013 1keydata.com   All Rights Reserved.     Privacy Policy


SQL SELECT
SQL DISTINCT
SQL WHERE
SQL AND OR
SQL IN
SQL BETWEEN
SQL Wildcard
SQL LIKE
SQL ORDER BY
SQL Functions
SQL Average
SQL COUNT
SQL MAX
SQL MIN
SQL SUM
SQL GROUP BY
SQL HAVING
SQL ALIAS
SQL AS
SQL JOIN
SQL INNER JOIN
SQL OUTER JOIN
SQL LEFT OUTER JOIN
SQL CROSS JOIN
SQL SELECT UNIQUE
SQL ROUND
SQL CAST
SQL CONVERT
SQL CONCATENATE
SQL SUBSTRING
SQL INSTR
SQL TRIM
SQL LENGTH
SQL REPLACE
SQL DATEADD
SQL DATEDIFF
SQL DATEPART
SQL GETDATE
SQL SYSDATE

SQL CREATE TABLE
SQL Data Types
SQL CONSTRAINT
SQL NOT NULL
SQL DEFAULT
SQL UNIQUE
SQL CHECK
PRIMARY KEY
FOREIGN KEY
SQL View
SQL CREATE VIEW
SQL Index
SQL CREATE INDEX
SQL ALTER TABLE
SQL DROP TABLE
SQL TRUNCATE TABLE
SQL USE
SQL CREATE DATABASE
SQL DROP DATABASE
SQL INSERT INTO
SQL INSERT INTO SELECT
SQL UPDATE
SQL DELETE FROM

SQL Video Tutorial
SQL Jobs

Site Map
Resources