oracle

Thursday, 20 April 2017

SQL: insert into the table.

Insert into command is used to insert data into the columns of table.
We can insert data into table by two ways.
 One mathod is by spacifying the columns names. and other is without using columns name.

Syntax:

insert into table_name(col_1, col_2, col_3) values(val1, val2, val3);

In the above example. we use table name with its column names in which we want to insert the data. and values is the keyword and val1 is the value for column 1, val2 is the value for column 2 and upto so on as.

Example:

insert into authors(author_id,author_name) values (1,'Muhammad Talha Zubair');

Result:

One row is inserted.

And if we want to insert data in all the columns, then we can use insert into command without using the columns names.

Example:

insert into authors values (2,'Talha Zubair Khan');

Result:

One row is inserted.

commit;

it will save the inserted data. or changes which you performed.

Check the updated table by using Select * from authors;

Result:
Author_id          Author_name
1 Muhammad Talha Zubair

2 Talha Zubair Khan

Two rows inserted into authors table.

No comments:

Post a Comment