Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL populates the foreign key table with random data

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Reference:

http://blog.itpub.net/29254281/viewspace-1686302/

prepare the environment

1. Creating a Numeric Auxiliary Table

create table nums(id int not null primary key);

delimiter $$

create procedure pFastCreateNums(cnt int)

begin

declare s int default 1;

truncate table nums;

insert into nums select s;

while s*2 select rand_string(12,5) random_string;

-- +---------------+

-- | random_string |

-- +---------------+

-- | 3KzGJCUJUplw |

-- +---------------+

-- 1 row in set (0.00 sec)

DECLARE i int UNSIGNED DEFAULT 0;

DECLARE v_chars varchar(64) DEFAULT '0123456789';

DECLARE result varchar (2000) DEFAULT '';

IF l_type = 1 THEN

SET v_chars = '0123456789';

ELSEIF l_type = 2 THEN

SET v_chars = 'abcdefghijklmnopqrstuvwxyz';

ELSEIF l_type = 3 THEN

SET v_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

ELSEIF l_type = 4 THEN

SET v_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

ELSEIF l_type = 5 THEN

SET v_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

ELSE

SET v_chars = '0123456789';

END IF;

WHILE i

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report