-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMysql-studentInfo_20220403.sql
More file actions
55 lines (42 loc) ยท 2.6 KB
/
Mysql-studentInfo_20220403.sql
File metadata and controls
55 lines (42 loc) ยท 2.6 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
50
51
52
53
54
55
/*๋ชจ๋ฐ์ผ ํ๋ก๊ทธ๋๋ฐ ์์
์ ์๊ฐํ๋ ํ์๋ค์ ์ ๋ณด๋ฅผ ์ ์ฅํ ์ ์๋ ํ์ ํ
์ด๋ธ*/
CREATE TABLE IF NOT EXISTS `studentInfo`
( `stdNm` int NOT NULL AUTO_INCREMENT, -- ํ์ ๊ณ ์ ๋ฒํธ
`std_Id` int(11) NOT NULL, -- ํ์ ํ๋ฒ
-- AUTO_IMCREMENT : PK(๊ธฐ๋ณธํค)์ ํน์ง(๊ณ ์ ์ฑ)์ผ๋ก ์ธํด
-- int ํ์
์ผ๋ก ์ธ๋ฑ์ค(์ ์๊ฐ)์ ์ฌ๋ ค์ํ๋๋ฐ ์ด๋, ์ธ๋ฑ์ค๋ฅผ ์ฒดํฌํด ์๋์ผ๋ก ์ฌ๋ ค์ฃผ๋ ์ต์
`stdName` VARCHAR(10) NOT NULL, -- ํ์ ์ด๋ฆ
`stdDep` VARCHAR(15) DEFAULT NULL, -- ํ์ ํ๊ณผ
`stdPho` VARCHAR(16) DEFAULT NULL, -- ํ์ ์ ํ๋ฒํธ
`stdDB` VARCHAR(15) DEFAULT NULL, -- ํ์ mariaDB ์์ด๋
`stdDate` DATE DEFAULT NULL, -- ํ์ DB ๊ฐ์
๋ ์ง YYYY-MM-DD ๋ ์ง(์๊ฐX)
`Up_Date` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
-- ํ์ ์ ๋ณด ์
๋ฐ์ดํธ์ผ YYYY-MM-DD H:M:S ๋ ์ง(์๊ฐ ํฌํจ)
PRIMARY KEY (`stdNm`) -- ํ์์ ๊ณ ์ ๋ฒํธ ์์ฑ์ด ๊ธฐ๋ณธํค
/*PRIMARY KEY : ํ ํ
์ด๋ธ์ ์ค์ง 1๊ฐ ์กด์ฌ/ ํน์ ๋ฐ์ดํฐ๊ฐ ๊ตฌ๋ถ์๊ฐ ๋๊ธฐ ์ํด ์ค์ */
)ENGINE=MyISAM DEFAULT CHARSET = utf8;
INSERT INTO `studentInfo` -- INSERT sql 1
(std_Id, stdName, stdDep, stdPho, stdDB, stdDate, Up_Date)
VALUES(2020111698, '์์์', '์ํํธ์จ์ด์ตํฉํ๊ณผ', '01052966518', 'ay0518', '2022-03-16', current_timestamp());
INSERT INTO `studentInfo` -- INSERT sql 2
(std_Id, stdName, stdDep, stdPho, stdDB, Up_Date)
VALUES(2019100123, '๊น๊ฐ๋', '๊ฒฝ์ ํ๊ณผ', '01012345678', 'cute4', current_timestamp());
INSERT INTO `studentInfo` -- INSERT sql 3
(std_Id, stdName, stdDep, stdDB, stdDate, Up_Date)
VALUES(2021010518, '์ด๋ค๋ผ', '๋์งํธ๋ฏธ๋์ดํ๊ณผ', 'beautiful1', '2021-03-13', current_timestamp());
INSERT INTO `studentInfo` -- INSERT sql 4
(std_Id, stdName, stdDep, stdPho, stdDB, stdDate, Up_Date)
VALUES(2018987654, '๋ฐ๋ง๋ฐ', '์ํํธ์จ์ด์ตํฉํ๊ณผ', '01098765432', 'pretty98', '2020-09-08', current_timestamp());
INSERT INTO `studentInfo` -- INSERT sql 5
(std_Id, stdName, stdDep, stdPho, stdDB, stdDate, Up_Date)
VALUES(2020011222 , '์ต์ฌ์','์ ๋ณด๋ณดํธํ๊ณผ', '01005180518', '1angel4', '2022-04-02', current_timestamp());
INSERT INTO `studentInfo` -- INSERT sql 6
(std_Id, stdName, stdDep, stdPho, stdDB, stdDate, Up_Date)
VALUES(2019123456, '์์์ฐจ', '์ํํธ์จ์ด์ตํฉํ๊ณผ', '01020220403', 'avemaria', '2022-03-25', current_timestamp());
UPDATE `studentInfo` -- UPDATE sql 1
SET stdDB='avemarias2'
WHERE stdNm=6; -- stdNm์ด 6์ธ ํ์์ DB๋ช
์ 'avemarias2'๋ก ์์ / ์์์ฐจ์ DB๋ช
'avemaria' ์์
DELETE FROM `studentInfo` -- DELETE sql 1
WHERE stdDate='2020-09-08'; -- DB ๊ฐ์
๋ ์ง๊ฐ 2020-09-08 ์ธ ํ์์ ์ญ์ / ๋ฐ๋ง๋ฐ์ ๋ฐ์ดํฐ ์ญ์
SELECT std_Id, stdName, stdDB, stdDate-- SELECT sql 1
FROM `studentInfo`
WHERE stdDep = '์ํํธ์จ์ด์ตํฉํ๊ณผ' ; -- ํ๊ณผ๋ช
์ด '์ํํธ์จ์ด์ตํฉํ๊ณผ'์ธ ํ์์ ํ๋ฒ, ์ด๋ฆ, DB๋ช
, DB ๊ฐ์
๋ ์ง ๊ฒ์