Back to photostream

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.

 

datawitzz.com/insert-query-in-sql/

10 views
0 faves
0 comments
Uploaded on January 15, 2022
Taken on January 13, 2022