简体   繁体   中英

Delete first character in whole column in PL/SQL

I have a problem with deleting first character in a one column of my table and updating my table with new values. I wanna do it in on query (remove first character in string in one column and update table). Anyone can help?

My table:

ID | column1 | column2
L12| 5       | 10
L14| 6       | 12

My desired output:

ID | column1 | column2
12| 5       | 10
14| 6       | 12

A simple update with substr :

Before:

SQL> select * from your_table;

ID     COLUMN1    COLUMN2
--- ---------- ----------
L12          5         10
L14          6         12

Update:

SQL> update your_table set
  2    id = substr(id, 2);

2 rows updated.

After:

SQL> select * from your_table;

ID     COLUMN1    COLUMN2
--- ---------- ----------
12           5         10
14           6         12

SQL>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM