[英]How to add 10000 to existing column?
I have a table called stock and one of the column is called stock_code.我有一个名为 stock 的表,其中一列名为 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. stock_code 都是 5 位整数(我相信),但是现在我的数字用完了,我需要将所有代码更改为 10 位。 So I need to add 10000 to all the stock_code.所以我需要将 10000 添加到所有 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对于 NexusDB
update your_table SET stock_code = '10000' + stock_code
Try this, (hope your stock_code
column is string)试试这个,(希望你的stock_code
列是字符串)
UPDATE stock SET stock_code = '10000' + stock_code
this will concatenate 10000
to your existing column stock_code
.这会将10000
连接到您现有的列stock_code
。
If the stock_code column is numeric
, then you can simply use the below query如果 stock_code 列是numeric
,那么您可以简单地使用以下查询
UPDATE stock SET stock_code = 1000000000 + stock_code
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.