insert/update/delete multiple tables in single SQL statement

insert, update delete query in mysql
insert, update, delete query in sql server
sql delete and insert in one statement
insert and update in one query in sql
sql update
is it possible to insert, update and delete within one select statement?
insert, update, and delete statements can be referred to as
delete from one table and insert into another sql server

When I use JMeter with JDBC request on Oracle DB it doesn't allow ; in statement.

SQL query. Do not enter a trailing semi-colon.

For example

insert into a select '1' from dual;
insert into b select '1' from dual

Will produce exception (while it work when split to 2 separate request):

 java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

If I want to execute clear/insert of test data I can't insert multiple tables using 1 JDBC request and I must create at least 1 request per table (can be with multiple values per table).

Is there a way to insert/update/delete except using a callable statement ?

Is this limitation connected to solely to SQL injection?

Insert would work, using INSERT ALL, such as

insert all
  into a (col) values ('1')
  into b (col) values ('2')
select * From dual

Update and delete wouldn't; I'm afraid that you'll have to use one statement per table, unless you want to use PL/SQL and call a procedure which will do all that job.

SQL INSERT, UPDATE, DELETE, Need to insert one or multiple rows of data from one table into another table? You can use the INSERT INTO SELECT statement. Let's say  The ; isn't part of "sql" it's a terminator for the program that is sending the sql. In sqldev/sqlcl/sqlplus the ";" is seen to know the end of the statement to sent everything up to that point to the database as a statement. Then process the next set of text until the next ";" or "/" This example presents to the database as one big string such as:

Why not try : Insert Into tableA a, tableB b Value (a.field = (Select '1' From Dual), b.field = (Select '1' From Dual)), I'm not totally sure but I think it can work.

MySQL DELETE JOIN: Deleting Data from Multiple Tables, A single DELETE statement on multiple related tables which the child table have an TABLE t2 ( id VARCHAR(20) PRIMARY KEY, ref INT NOT NULL ); INSERT We often use the LEFT JOIN clause in the SELECT statement to find rows in the INSERT INTO SELECT · Insert On Duplicate Key Update · INSERT IGNORE​  SQL Query for Multiple Table SELECT, INSERT, UPDATE and DELETE WITH JOIN CLAUSE. by Kapil Khandelwal · July 9, 2017 · 3,064 Views

I found INSERT ALL with multiple tables works:

INSERT ALL
 Into a (a) values ('1')
 into b (b) values('1')
 SELECT * FROM dual

You can also use the INSERT ALL statement to insert multiple rows into more than one table in one command.

4. Inserting, Updating, Deleting, For example, you can delete rows in one table depending on whether or not they Use the INSERT statement with the VALUES clause to insert one row at a time: of inserting one row at a time or multiple rows at a time by including multiple  I want to update multiple table in a single statement how will I do it? The answer is – No, You cannot and you should not. SQL Server does not support deleting or updating from two tables in a single update. If you want to delete or update two different tables – you may want to write two different delete or update statements for it.

The ; isn't part of "sql" it's a terminator for the program that is sending the sql. In sqldev/sqlcl/sqlplus the ";" is seen to know the end of the statement to sent everything up to that point to the database as a statement. Then process the next set of text until the next ";" or "/"

This example presents to the database as one big string such as:

"insert into a select '1' from dual; insert into b select '1' from dual"

To perform 2 statements in 1 call to the database, it'll need a begin/end around to convert it to an executable block such as

BEGIN
insert into a select '1' from dual;
insert into b select '1' from dual;
END;

Then in JMeter change to "Callable Statement"

Manipulating Data Using Insert, Update, and Delete in SQL Server , SQL Server Reporting Services (SSRS) This guide explains how to insert, update, and delete records from tables using SQL statements. of certain fields in one or more rows, you will come across the UPDATE statement. The MERGE statement is used to manipulate (INSERT, UPDATE, DELETE) a target table by referencing a source table for the matched and unmatched rows. The MERGE statement can be very useful for synchronizing the table from any source table.

Using MERGE in SQL Server to insert, update and delete at the , Using MERGE in SQL Server to insert, update and delete at the same time or on multiple tables, even the performance degrades significantly with this approach. use MERGE command to perform these operations in a single statement. --MERGE SQL statement - Part 1 --Create a target table CREATE  Using DELETE statement in SQL. Delete statement has a syntax similar to that of an update statement. The difference is DELETE removes the record from the table. Another point worth noting is that since DELETE is used to remove one or more records from the table, we need not specify column names to be deleted in the DELETE statement.

SQL DELETE - Deleting Data in a Table or Multiple Tables, The DELETE statement removes one or more rows in a table permanently. The syntax of the DELETE SQL DELETE – deleting related rows in multiple tables. It becomes more this tutorial helpful ? YesNo. Previous Tutorial: SQL INSERT – Inserting One or More Rows Into a Table · Next Tutorial: SQL UPDATE Statement​  SQL HOME SQL Intro SQL Syntax SQL Select SQL Select Distinct SQL Where SQL And, Or, Not SQL Order By SQL Insert Into SQL Null Values SQL Update SQL Delete SQL Select Top SQL Min and Max SQL Count, Avg, Sum SQL Like SQL Wildcards SQL In SQL Between SQL Aliases SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Self Join SQL

SQL INSERT, SQL UPDATE, SQL DELETE – Oh My!, SQL INSERT , UPDATE , and DELETE statements—what are they all about INSERT is your go-to for adding single or multiple rows to a table. Insert records into a table. There are essentially two methods for adding records to a table. The first is to add one record at a time; the second is to add many records at a time. In both cases, you use the SQL statement INSERT INTO to accomplish the task. INSERT INTO statements are commonly referred to as append queries.

Comments
  • I just answer similar, you still need to remove ; for it to work
  • Well, ; is a terminator which is OK as far as (Oracle) is concerned. If it shouldn't/can't be used in you Java program, remove it. insert all is what counts, I presume :) I've removed it.
  • Different error: ORA-00926: missing VALUES keyword, tried also Insert Into tableA a, tableB b Values (a.field = (Select '1' From Dual), b.field = (Select '1' From Dual))
  • So replace Value by Values, we're not here to do all your job !