-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuserinfo.sql
More file actions
49 lines (43 loc) · 1.27 KB
/
Copy pathuserinfo.sql
File metadata and controls
49 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CREATE TABLE userinfo (
id INT NOT NULL AUTO_INCREMENT,
name varchar(64) NOT NULL DEFAULT '',
email varchar(64) NOT NULL ,
password varchar(64) NOT NULL DEFAULT '',
dob date DEFAULT NULL,
address varchar(255) NOT NULL DEFAULT '',
city varchar(64) NOT NULL DEFAULT '',
state_id INT NOT NULL DEFAULT '0',
zip varchar(8) NOT NULL DEFAULT '',
country_id INT NOT NULL DEFAULT '0',
account_type varchar(32) NOT NULL DEFAULT '',
closest_airport varchar(3) NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE KEY email (email)
)
ENGINE=InnoDB;
-- insert data using procedure
DELIMITER $$
CREATE PROCEDURE InsertUserInfo(IN max_count INT)
BEGIN
DECLARE x INT DEFAULT 0;
DECLARE state_id INT DEFAULT 0;
WHILE x < max_count DO
SET state_id = state_id + 1;
INSERT INTO userinfo (`name`, `email`, `password`, `dob`, `address`, `city`, `state_id`, `zip`, `country_id`, `account_type`, `closest_airport`)
VALUES (
CONCAT('John', x),
CONCAT('johnsmith',x,'@email.com'),
'1234',
'1986-02-14',
'1795 Santiago de Compostela Way',
'Austin',
state_id,
'18743',
1,
'customer account',
'aut'
);
SET x = x + 1;
END WHILE;
END $$
DELIMITER ;