In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
            
                    
                
2025-11-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In order to verify the related functions of TOAST, through lpad, rpad and other methods, because the repetition rate is too high to see the effect, it is necessary to generate random strings to fill the data.
A sample function for generating random strings
CREATE OR REPLACE FUNCTION sf_generate_randomstring (length int4) RETURNS textAS $$declare chars text []: ='{0force1, RETURNS textAS $$declare chars text []: ='{0force1, RETURNS textAS $$declare chars text []: ='{0Power1, 2, 4, 5, 5, 8, 9, A, B, C, D, 5, 8, 5, 5, 4, 5, 5, 4, 5, 8, 9, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 5, 7, 7, 8, 7, 7, 8, 7, 7, 7, 7, 8, Wre xrem y re z}' Ret text: =''; I integer: = 0; lenofarray int: = array_length (chars, 1); begin if length < 0 then raise exception 'invalid input parameter, please re-enter!' ; end if; for i in 1..length loop ret: = ret | | chars [1+random () * (lenofarray-1)]; end loop; return ret;end;$$ LANGUAGE 'plpgsql'
This function randomly generates a string composed of a-zA-Z0-9 characters whose length is determined by the input parameter length. Of course, you can also add other characters, such as Chinese characters, to the array chars.
The effect is as follows:
[local]: 5432 pg12@testdb=# select sf_generate_randomstring Sf_generate_randomstring -hmski6FmSCcRPcfmSkC3aaX7Ay3QlmTz0497pitHNjLcU8KdKVtO7ysmoqRnwM2Dc9VuPnOxGfUgTX6lIdplRciYETic4GrdRqD1 (1 row) Time: 2.022 ms [local]: 5432 pg12@testdb=# select length (sf_generate_randomstring (40000)) Length-40000 (1 row) Time: 174.529 ms [local]: 5432 pg12@testdb=#
references
How to quickly build a large amount of realistic Test data by PostgreSQL
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





            
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.