INSERT INTO Query in SQL

The statement INSERT is used to insert the records into a table. The table chosen for inserting data has to have the same number of columns and values. In this tutorial segment, we’ll discuss with an example the syntax of the Insert sentence.

A Brief on the Insert Command in SQL

Upon creation of the table, the next step is to insert values according to its constraints. The statement in the insert consists of two ways.

Just values: The value of the data to be added is indicated with the names of the columns.

Column names and values: the name of the column is given, and the values are then inserted.

In this tutorial section, we use the only method for values. The values entered in only values must be in an order according to the column.

Syntax:

INSERT INTO tablename VALUES (value1, value2,….valueN);

Where the keywords are INSERT INTO and VALUES and the tablename is the table name; value1 to valueN is the set of values, followed by a semicolon.

Values for each column are given, respectively. Whenever a character of variable length appears the values are entered in a single quote. And when an integer appears, that is just how it is written.

As our employee table is created, let’s insert values into it

Insert into employee values(1,’sam’,30000,26,’male,’operation’);

Insert Into query in SQL
  • After the query is written, click the execute button to check for errors
  • Upon execution of the application, a message will appear as ‘Commands completed successfully’
  • Repeat the procedure, and create five more entry sets. Once the records are entered, the table of employees will be shown as follows:
INSERT INTO in SQL

Finally, the values in our table are ready. We have inserted six documents, and this is how the Insert query functions in SQL.

Leave a Reply