Alibabacloud.com offers a wide variety of articles about update column from another table in oracle, easily find your update column from another table in oracle information here online.
--oracle Table Error Update flashback operation test Environment--select * from V$database;--select * from V$version;The first step of operation1. Enable row migration with the following commandALTER TABLE test_a enable row movement;2. The following command flashes back to a certain point in timeFlashback
, Customer_type) = (select B.city_name,b.customer_type from tmp_cust_city b where b.customer_id=a.customer_id) where exists ( select 1 from tmp_cust_city b where B.customer_id=a.customer_id) --方法1. UPDATE表2 SET 表2.C=(SELECTBFROM表1WHERE表1.A=表2.A) WHERE EXISTS(SELECT1FROM表1WHERE表1.A=表2.A)--方法2 MERGEINTO表2 USING表1 ON (表2.A=表1.A)--条件是A相同 WHENMATCHEDTHENUPDATESET表2.C=表1.B--匹配的时候,更新TwoOracle Random Read n data method in
Oracle Multiple Table Association UPDATE statement
1 The simplest form of SQL code
--confirmed that all customer_id less than 1000 of the Customers table are ' Beijing '
Within the--1000 are the company to the country before the old customers in the city:
Update customers
Early this morning because to do some operations in the database, is about the two tables associated with the update, but the statement how to write is not correct, always error, so scared (afraid not to complete the operation in time) to check, NND, the original SQL written in SQL Server under the unique form, This syntax does not work under Oracle, and is quickly changed back to complete the task in time.
First look at our data:
SQL> select count (1) from Dave where cust_tel like '2013 ';
Count (1)
----------
2723
In our Dave table, cust_tel had 0551 records starting with 2723. Now we have changed these records to 0556.
Let's test it using the following method:
SQL> select * from V $ version;
There are many writing methods, and the key is to pay attention to efficiency issues, especially when the data volume to be updated is large.
In addition, we
C # Gets the SQL statement for the column name and data type of a table in the Oracle database: Select Column_name,data_type, Data_length,data_precision,data_scale from User_tab_ columns [where table_name= table name] Description of this SQL statement: column_name: A table
can use ROWID Update, the UPDATE statement is as follows:
Update Test a
set (col1,col2) =
(select Trim (b.col1), Trim (b.col2) from Test b
where A.rowid=b.rowid)
where exists
(select 1 from Test b
where A.rowid=b.rowid)
Multiple Table Association Delete
1 use in or not to delete data
Delete from Tes
MERGE is a composite statement used to implement INSERT, UPDATE, and DELETE operations at a time. Syntax: merge into table/view using (TABLE/VIEW/SUBQUERY) ON (condition) [when metched then update set column = expr/DEFAULT [WHERE condition] www.2cto.com [delete where conditi
About Oracle Update multiple table problemsThere are several ways to achieve this:One is:Update table1Set (field1,field2 ...) =(Select field1,field2 .....)From table2where Table1.field1=table2.field1)where Table1.field1 in (select Field1 from table2)
Two kinds are:Create a primary key primary key or union key for the table1,table2 associated fieldUpdate (Select t
Yesterday, we found that the data analysis results in the program were incorrect. After the analysis was performed again, the original data was still there and the fields with values were accumulated. The heart said, No, It was analyzed only after record generation. Forgot to DELETE? Check the code and find a delete statement. Therefore, the query analyzer executes the statement and reports an error. I have tried it several times. Now, Delete From does not recognize the
Yesterday, we found that the data analysis results in the program were incorrect. After the analysis was performed again, the original data was still there and the fields with values were accumulated. The heart said, No, It was analyzed only after record generation. Forgot to DELETE? Check the code and find a delete statement. Therefore, the query analyzer executes the statement and reports an error. I have tried it several times. Now, Delete From does not recognize the
ORACLE cannot use variables as column names and table names some of the individual validations are:1 DECLARE2Ename1 Emp.ename%TYPE;3TYPE Index_emp_type is TABLE of VARCHAR2( -)INDEX byPls_integer;4 index_emp Index_emp_type;5 BEGIN 6Index_emp (1) := 'E.ename';7 SELECTIndex_emp (1) intoEname1 fromEMP EWHEREE.empno=7369
两种方法:--方法1.UPDATE表2SET表2.C=(SELECTBFROM表1WHERE表1.A=表2.A)WHEREEXISTS(SELECT1FROM表1WHERE表1.A=表2.A)--方法2MERGEINTO 表2USING表1ON(表2.A=表1.A)--条件是A相同WHENMATCHEDTHENUPDATESET表2.C=表1.B--匹配的时候,更新Oracle Association Two table write update statements
How to kill session 1 when an Oracle table update is locked. view the locked table SELECT p. spid,. serial #, c. object_name, B. session_id, B. oracle_username, B. OS _user_name FROM v $ process p, v $ session a, v $ locked_object B, all_objects c WHERE p. addr =. paddr AND. process = B. process AND c. object_id = B. o
b.customer_id=a.customer_id)And(select 1 from tmp_cust_city bwhere b.customer_id=a.customer_id)is two independent subqueries, to view the execution plan, the B/Index scan 2;If you discard the where condition, the default is to make a table full tableUpdated, but becauseSQL Code1 Select from where b.customer_id=a.customer_id It may not be possible to provide a "sufficient" value because tmp_cust_city is only part of the customer's information, so an
Oracle's UPDATE statement does not pass MSSQL so simple and easy to write, even if written out, but the execution may be reported that this is because the set where the subquery detected multiple rows of data values, Oracle rules to update data one to the other, so the prompt error. To resolve this it must be ensured that the value one by one corresponds to the c
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.