SQL INSERT INTO 1

Insert query in SQL | SQL insert statement in Oracle

Insert query in SQL

Introduction to Oracle INSERT statement

In our previous post, we learned about how to create a table in SQL by CREATE TABLE statement. After CREATE TABLE we will learn how to INSERT INTO data in SQL table. To insert a new row into a table, you can use the Oracle INSERT statement as follows:

INSERT INTO table_name (column_list)
VALUES( value_list);

In the above statement, we can see COLUMN_LIST is the name of columns in which we wanted to insert the data. While value_list shows values that we wanted to INSERT INTO the columns of SQL table mentioned above. Also, it should be noted that every value and column name should be separated by comma.

If we are inserting the same number of values as we have columns then we can skip column names in insert query like below.

INSERT INTO table_name
VALUES( value_list);

Let’s create a table EMPLOYEES first then we will insert data into the table.

CREATE TABLE EMPLOYEES (
EMPLOYEE_ID NUMBER GENERATED BY DEFAULT AS IDENTITY,
EMPLOYEE_NAME VARCHAR2(255) NOT NULL,
AGE NUMBER(3,1) NOT NULL,
JOINING_DATE DATE NOT NULL,
BRITH_DATE DATE NOT NULL);

In the above table, we have five columns in which we will use INSERT SQL statement to insert data. First column EMLOYEE_ID is an IDENTITY column in which we will not insert value as it will generate automatically. The other columns have NOT NULL conditions which means we need to insert values in SQL columns.

The following INSERT query will insert value in SQL table.

INSERT INTO EMPLOYEES(EMPLOYEE_NAME, AGE, JOINING_DATE, BIRTH_DATE)
VALUES('SAM M', 21.26, DATE '2022-01-01', DATE '2000-10-01');

In the above insert into table SQL query we insert into table values as SAM M for employees_name,21.26 as age, 2022-01-01 into Joining_date column, and 2000-10-01 into column BIRTH_DATE.

Now we will fetch data from SQL column by using SQL SELECT statement as mentioned below.

SELECT * FROM EMPLOYEES;
Insert query in SQL
Insert query in SQL

We can use SQL insert multiple rows as well by using additional values statement. insert where query in SQL.

Also, we can INSERT into SQL from another table also by using insert query in MySQL.

You can read more about insert statement in SQL from the below articles as well.

https://www.w3schools.com/sql/sql_insert.asp

https://www.tutorialspoint.com/sql/sql-insert-query.htm

2 thoughts on “Insert query in SQL | SQL insert statement in Oracle”

  1. Pingback: SELECT statement for SQL - DataWitzz

  2. Pingback: Pivot and Unpivot in SQL || How to convert rows to Columns in sql - DataWitzz

Leave a Comment

Scroll to Top