Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL question

Re: SQL question

From: Stephane Faroult <sfaroult_at_oriole.com>
Date: Wed, 21 Nov 2001 09:22:42 -0800
Message-ID: <F001.003CAE9C.20011121090520@fatcity.com>

"Malik, Fawzia" wrote:
>
> Hi,
>
> Can you tell me if its possible to write some sql to change some data.
> Basically I need to run a scritp to change data of column: id from 12345678
> to the last four digits. Is this possible to do in sql/plsql??
>
> Any advice/hints would be greatly appreciated
>
> Rgds
>
> Fawzia
>

I assume that id is a number.

  1. If it happens to be a PK, drop all the FK constraints refering it, and the PK itself.
  2. Update T set id = to_number(substr(to_char(number), length(to_char(number)) - 4))

    should do the trick (give or take a parenthese).

-- 
Regards,

Stephane Faroult
Oriole Corporation
Voice:  +44  (0) 7050-696-269 
Fax:    +44  (0) 7050-696-449 
Performance Tools & Free Scripts
--------------------------------------------------------------
http://www.oriole.com, designed by Oracle DBAs for Oracle DBAs
--------------------------------------------------------------
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Stephane Faroult
  INET: sfaroult_at_oriole.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Nov 21 2001 - 11:22:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US