简体   繁体   中英

How to add 10000 to existing column?

I have a table called stock and one of the column is called stock_code. The stock_code is all 5 digit int (I believe), but now I'm running out of numbers, I need to change all the code to 10 digit. So I need to add 10000 to all the stock_code. Can someone help me please?

If it's a number:

UPDATE stock SET stock_code = 1000000000 + stock_code;

or, to keep a better view on the number of zeros:

UPDATE stock SET stock_code = (10000 * 10000) + stock_code;

For Oracle:

update your_table set stock_code=concat(10000,stock_code)

For NexusDB

 update your_table SET stock_code = '10000' + stock_code

Try this, (hope your stock_code column is string)

UPDATE stock SET stock_code = '10000' + stock_code

this will concatenate 10000 to your existing column stock_code .

If the stock_code column is numeric , then you can simply use the below query

UPDATE stock SET stock_code = 1000000000 + stock_code

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