The query is a statement written to perform some operation on selected data from a SQL table or an HQL object. You can perform various operations by writing queries, like CRUD operations (create, read, update, delete) and many more. Using queries, we can do multiple operations, not only these basic operations, and make the database much more powerful and flexible.
As its name suggests, an insert clause is used to insert records in the database. You can insert data anywhere in the database using the insert clause. By putting some conditions in the insert query, you can add the records anywhere in the database.
Insert into table_name (column_name) select object.column from table_name object_name
Query query = session.createQuery (“insert into EMP(emp_id, emp_name)” + “select emp_no, emp_nm from backup_emp” );
Int result = query.executeUpdate();