Oracle database frequently used but poorly remembered statements

Source: Internet
Author: User

1. association Update table Operations
For example, we need to work on a table, generally update it, but sometimes the condition must be related, this oracle and MySQL have some differences, I directly say Oracle:
Update Sys_role T
Set T.password = ' q3qtuxgsi7b5u60nfmu+qa== '
where exists (select 1
From Tempstaff S
where T.userid = S.userid
and T.operatorid = S.operatorid)
This example is my error operation, and then through the snapshot too long to find the wrong modification of the thousands of data, associated back to change the password back, then unified operation.

2. Backup table Data
This is very simple, but also very good to remember, I will write. Backup table is TestTable1
CREATE TABLE TestTable1 as SELECT * from BaseTable;

3. Add a table field
I add a collectdate field to the Downsheet_flag_record table as follows:
ALTER TABLE Downsheet_flag_record Add (collectdate varchar2 (30));

4, to see if one of the fields is Chinese, because sometimes for example, employee table it is not real-name system, casually write, to deal with the inspection we will find out, take a name, called the King Eight, King eggs, cattle, cattle two, Zhang Wei and so on
Select T.userid,t.operatorname, ASCII (SUBSTRB (Trim (t.operatorname), up)) from Sys_user t where AscII (SUBSTRB (Trim ( T.operatorname) <>32;
This is the ASC code to judge, 32 is the Chinese language.

5. Delete a column
ALTER TABLE ipms_parameters DROP COLUMN endtime;

6, Ching:
Select object_name,machine,s.sid,s.serial#
From V$locked_object l,dba_objects O, v$session s
where l.object_id = o.object_id and l.session_id=s.sid;

Alter system kill session ' 2684,53431 ';

7. Modify the field type
ALTER TABLE ALARMMSG Modify (sm_text varchar (100));

8. Modify field names
Alter downsheet_flag rename column loid to BUSI_NBR;

Oracle database frequently used but poorly remembered statements

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.