Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-06-01 03:30:38 10月13日 Update

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.

Tags: Structure data content fields queries two learning code value commands that is form more articles processes links changes references work support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Shulou Tech Info Shulou Information Apple