Suppose we have two tables: test1 and Test2.
Create
Table
Test1 (No
Number
, Name
Varchar2
(
10
));
Create
Table
Test2 (No
Number
, Name
Varchar2
(
10
));
Insert
Into
Test1
Values
(
1
,
'
A
'
);
Insert
Into
Test1
Values
(
2
,
'
B
'
);
Insert
Into
Test1
Values
(
3
,
'
C
'
);
Insert
Into
Test2
Values
(
1
,
'
AA
'
);
Insert
Into
Test2
Values
(
2
1, UPDATE nowait Apply the following scenario: Query a data and open database transactions to it. If the current data for the query is not locked, the result is returned correctly and the current data is locked, if the current data for the query is already locked in the transaction. But return exception information: Prompt data has been locked. SQL statement:
SQL code :
Copy Code code as follows:
SELECT *
From Hold_mc_site_product_pic p
Build a Test tableCREATE TABLE T_table nologging as SELECT * from Dba_objects;create table T_table_1 nologging as SELECT * from Dba_tables;--Create a log recordCreate materialized view Log on t_table with ROWID, sequence (Object_name,object_type,owner) including new Values;create MA terialized View Log on T_table_1 with rowid,sequence (table_name) including new values;--Creating materialized viewsCreate materialized view mv_t_table nologging refresh fast on Demand with rowID START with To_date (
The situation I encountered:When querying a table with a SELECT statement, followed by for update,SELECT * from table for updateWhen the data in the table is modified, but no commit is turned off PL/SQL, and the next time you open it, you will be stuck.First, the lock tableTo view the lock table process SQL statement:If there is a record, you can find the following lock table recordSecond, unlockKill the Lock table process:Record the SID and Serial#
"How to update with views"There is a need for a table, B table, the Name field in table B is updated to the name in table A, two tables have ID associated with the code as follows:Update (select A.name aname, B.name bname from a, b b where a.id = b.id) Set aname = bname;--Note: The two-table association attribute ID must be unique index or PR Imary KeyThis article is from the "Technical Exchange only" blog, please be sure to keep this source http://ga
Tags: how the body cond directly is what ACL logic commonly used blogMotivation:You want to do insert/update directly with an SQL statement in Oracle.DescriptionWhen writing SQL statements, we often encounter a large number of simultaneous insert/update statements, that is, when there is a record, it is updated (update), when no data exists, insert (insert).Actua
DEFINETABLE: SCORE: Keys: thebaseinformationofstudentsDEFINECOLUMNS: STUNO: thestudentsIDintheUniversitySTUNAME: studentsnameCOURSENAME: coursenameCOURSESCORE: t
Define table: SCORE: using for save the students score informations STUDENTS: the base information of students define columns: STUNO: the students 'Id in theUniversity STUNAME: students 'name COURSENAME: course name COURSESCORE: t
Define table:
SCORE: using for save the students 'score informations
STUDENTS: the base information
As follows:
Create or replace procedure p_xlstooracle is
V_file utl_file.file_type;
Out_v varchar2 (4000 );
V_id number;
V_service_competition number;
V_cu_market_share number (6, 4 );
V_ct_market_share number (6, 4 );
V_cm_market_share number (6, 4 );
V_other_market_share number (6, 4 );
Begin
If utl_file.is_open (v_file) then
Utl_file.fclose (v_file );
End if;
V_file: = utl_file.fopen ('utl _ file_dir ',' I _exch_info2.xls ', 'R ');
Loop
Begin
Utl_file.get_line (v_file, out_v );
Exception
When
Because Oracle does not support the update or delete from statement, Oracle's Multiple Table association update and delete must be supported by subqueries, and, similarly, Oracle does not support simultaneous update or delete multiple tables, typically using the following:
This is one of the Oracle's original brothers asked me a question, and then some people asked the question:
Use Oracle internal principles to describe the following procedures:
1, Sqlplus GYJ/GYJ@ORCL
2, Updatet_gyj set name= ' gyj1 ' where id=1;
3, commit;
4, exit
A look at this question is not often complicated, Ali Department of children's shoes especially like to use similar topics such as interviewing people, from which you can quickly dete
1. The most common one is update t1 set B = (select B from t2 where t1.a = t2.a). However, pay attention to the impact of null values. If you are afraid of the impact of null values, update t1 set tname = (select sname from t2 where t1.id = t2.id) where exists www.2cto.com (select 1 from t2 where t1.id = t2.id ); 2. UPDATE (select/* + use_hash (t1, t2) */t1.tname
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 condition] [when not matched then insert [(column,...)] VALUES (v ,...) [WHERE condition] [log errors [into table (...)] [reject limit num/UNL
OracleTwo table associated batch updateOne of the table data method one (Recommended): update table 2 set table 2. C = ( select B from Table 1 where table 1. A = table 2. A) where exists ( select 1
from table 1 where table 1. A = table 2. A); In particular, it is important to note that the final outer where condition is the scope of locking its bulk update data.Method Two: into
On the itpub see a forall execute update post, feel a little meaning, simple record.
Previously studied INSERT statements in ForAll, found that the statement through the binding array, the way to achieve a batch binding, a run of the way, thereby increasing the efficiency of execution.
However, for an UPDATE statement, Oracle implementations and inserts are dif
There are two tables: update the Val value of the row with the same ID value in Table tab1 and that in Table tab2 to the Val value in table 2.Select * From tab1;
Select * From tab2
The most common mistake is: Update tab1 set val = (select Val from tab2 where tab1.id = tab2.id );The updated result is: Select * From tab1, which has rows in tab1. If no corresponding row exists in tab2, the value i
We may have encountered in peacetime work, multiple table cascade Update, I also saw a lot of methods on the Internet, but the use of these methods generally did not succeed, so today I introduce you to a slightly troublesome method, the need for friends can refer to the next
With cursors, I think it's definitely safer.- -first set a cursor to store some of the data that needs to be used in the cursor:
Copy Code code as follows:
Declare
CURSOR
UPDATE
1, the first backup data (security, improve performance).
2, batch update, small batch submission, to prevent the lock table.
3, if the updated automatically indexed, the amount of updated data is very large, the first to cancel the index, and then recreate.
4, the whole table data update, if the table is very large, it is recommended to create a n
Date type, you can modify it in the following way, only to change the year and the day, not change the minutes and seconds
SELECT * from T_bdqc t where Hphm = ' Shaan aw1nw0 '
//Modify for custom time
UPDATE t_bdqc SET gxsj = to_date (To_char (
' 201 6-11-03 ', ' yyyy-mm-dd '), ' yyyy-mm-dd ') | |
To_char (GXSJ, ' hh24:mi:ss '), ' Yyyy-mm-dd hh24:mi:ss ')
where hphm= ' Shaan aw1nw0 ';
If the current time is changed:
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.