Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle query lock table and unlock, modify table field name and copy table structure and data method

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Query the locked table and unlock it in Oracle:

The code for locking table queries takes the following form:

Select count (*) from vested lockedtarget object select * from v$locked_object

See which table is locked:

Select b.owner.ownerreb. Objectkeeper namefilamenta.sessionroomidrecorda.lockedwriting mode from v$locked_object a dbathing objects b where b.object_id = a.object_id

Find out which session caused it:

Select b.username.b.sidrecoveryb.serialpaperpaperlogonedtime from v$locked_object arecoveryvaccountsession b where a.session_id = b.sid order by b.logon_time

Kill the corresponding process:

Execute command: alter system kill session'32241'; where 32 is sid,241 and serial#.

Modify the table field name in Oracle:

Assuming that the field has data, then change to nvarchar2 (20) can be executed directly:

Alter table tb modify (name nvarchar2 (20))

If you cannot modify it, use the following

Alter table sft_bfwo rename column bfwoid to wid;alter table sft_bfwo add bfwoid char (16); update sft_bfwo set bfwoid=trim (wid); alter table sft_bfwo drop column wid

Copy the table structure and table data in Oracle:

Copy the table structure and its data:

Create table table_name_new as select * from table_name_old

Copy only the table structure:

Create table table_name_new as select * from table_name_old where 1: 2

Or:

Create table table_name_new like table_name_old

Copy only table data:

If the two tables have the same structure:

Insert into table_name_new select * from table_name_old

If the structure of the two tables is different:

Insert into table_name_new (column1,column2...) Select column1,column2... From table_name_old

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report