Javatpoint Logo
Javatpoint Logo

INSERT Function in SQL

The INSERT string function of Structured Query Language allows you to insert the string or character within the given string at the fixed position.

Syntax of INSERT String Function

Syntax1: This syntax uses INSERT function with the column name of the SQL table:


Java Tpoint

Example 2: The following SELECT query inserts the 'C' character at the first position in the given word:



Example 3: The following SELECT query inserts the 'Capital' sub-string before 'of' word:


New Delhi is the Capital

Example 4: The following SELECT query inserts the 'Tpoint' string at the fifth position in the 'Java Excel' string:



Example 5: This example uses the INSERT function with the table in Structured query Language.

Now, we create the new table in SQL, which helps to understand each string function. The syntax for creating the new table in the SQL database is as follows:

The following CREATE statement creates the Worker_Grade table:

The below INSERT queries insert the records of Workers with Grades, Salaries, and Remarks in the Worker_Grade table:

The following SELECT statement displays the inserted records of the above Worker_Grade table:

Worder_ID First_Name Last_Name First_City Second_City New_City Attendance_Remarks Work_Remarks Grade
10 Aman Sharma Lucknow Chandigarh Ghaziabad 88 95 A2
02 Vishal Sharma Chandigarh Ghaziabad Ghaziabad 95 82 A1
07 Raj Gupta Delhi Ghaziabad Lucknow 91 95 A1
04 Yash Singhania Ghaziabad Delhi Lucknow 85 82 A2
11 Vinay Roy Delhi Kanpur Ghaziabad 95 97 A1
16 Manoj Gupta Ghaziabad Meerut Chandigarh 95 90 B1
19 Ram Gupta Lucknow Ghaziabad Chandigarh 89 95 A2

The following SELECT query uses the FORMAT function with the First_Name column of the above Worker_Grade table:

This SQL statement inserts the 'Aman' sub-string at the first position in the first name of each worker


First_Name Aman_1_5
Amanres Aman es
Vishalkush Aman lkush
Rajesh Aman h
Yashraj Aman aj
Vinaybhatt Aman bhatt
Manojjeeta Aman jeeta
Ramesh Aman h

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA